View Single Post
  #12   Spotlight this post!  
Unread 21-03-2016, 12:20
Peter Johnson Peter Johnson is online now
WPILib Developer
FRC #0294 (Beach Cities Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 255
Peter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud of
Re: Send data from raspberry pi to roboRIO using c++

Quote:
Originally Posted by jreneew2 View Post
Alright, I got the code to compile and I am trying to send the actual data now. However, I am not getting any values in the outline viewer. Here is my setup:

- Raspberry pi hooked up through ethernet to router which is also connected to roborio.

- Here is my code on the robot side:

Robot.cpp
Code:
static std::shared_ptr<NetworkTable> table;
NetworkTable::SetIPAddress("10.20.53.21");
NetworkTable::SetClientMode();
NetworkTable::Initialize();
table = NetworkTable::GetTable("vision");
GoalAlign.cpp
Code:
distanceToCenter = Robot::table->GetNumber("center", 0.0);
- On the raspberry pi side
Code:
std::shared_ptr<NetworkTable> visionTable;
visionTable = NetworkTable::GetTable("vision");
visionTable->PutNumber("center", distanceCenter);
I'm not sure if I am doing this correctly. I'm not getting any errors but I'm not getting any values either.
Your robot needs to be the server. There's actually code in some of the top-level classes which preconfigures it to be a server before it enters your code, and that's what the driver station dashboards etc assume. The raspberry pi should be set up as the client. So you should move the
Code:
NetworkTable::SetIPAddress("10.20.53.21");
NetworkTable::SetClientMode();
NetworkTable::Initialize();
lines to your raspberry pi, changing the IP address to the robot IP (or robot name, e.g. "roborio-2053-frc.local"). Using NetworkTable::SetTeam(2053) should do the latter for you.
__________________
Author of cscore - WPILib CameraServer for 2017+
Author of ntcore - WPILib NetworkTables for 2016+
Creator of RobotPy - Python for FRC

2010 FRC World Champions (294, 67, 177)
2007 FTC World Champions (30, 74, 23)
2001 FRC National Champions (71, 294, 125, 365, 279)