Go to Post I think the GDC just saw Inception. - ATannahill [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 07-03-2016, 21:21
jreneew2's Avatar
jreneew2 jreneew2 is offline
Alumni of Team 2053 Tigertronics
AKA: Drew Williams
FRC #2053 (TigerTronics)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Vestal, NY
Posts: 213
jreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura about
Send data from raspberry pi to roboRIO using c++

Hello, we are working on a raspberry pi and trying to get vision working on it. We already have c++ code that works, we just need to transfer the data from the raspberry pi to the roboRIO over networks tables. Ive seen the python network tables, however, we would prefer not porting our vision code to python because we do not have that much experience with python.

Any options?
Drew
  #2   Spotlight this post!  
Unread 07-03-2016, 22:33
snekiam snekiam is offline
Registered User
FRC #3322 (Eagle Imperium)
Team Role: Programmer
 
Join Date: Dec 2015
Rookie Year: 2010
Location: SE Michigan
Posts: 96
snekiam has a spectacular aura aboutsnekiam has a spectacular aura aboutsnekiam has a spectacular aura about
Re: Send data from raspberry pi to roboRIO using c++

What you want is probably the network tables located here. You will need to make a teamforge account to do a git clone and download the source, but I believe this is exactly what you will need.
  #3   Spotlight this post!  
Unread 07-03-2016, 22:34
jreneew2's Avatar
jreneew2 jreneew2 is offline
Alumni of Team 2053 Tigertronics
AKA: Drew Williams
FRC #2053 (TigerTronics)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Vestal, NY
Posts: 213
jreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura about
Re: Send data from raspberry pi to roboRIO using c++

Alright thanks!
  #4   Spotlight this post!  
Unread 08-03-2016, 02:01
Peter Johnson Peter Johnson is offline
WPILib Developer
FRC #0294 (Beach Cities Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 268
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++

Near identical thread: http://www.chiefdelphi.com/forums/sh...d.php?t=144496

Essentially, the code is also on github (https://github.com/PeterJohnson/ntcore) and you should be able to use cmake and gcc 4.8+ to build it.
__________________
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)
  #5   Spotlight this post!  
Unread 18-03-2016, 18:30
jreneew2's Avatar
jreneew2 jreneew2 is offline
Alumni of Team 2053 Tigertronics
AKA: Drew Williams
FRC #2053 (TigerTronics)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Vestal, NY
Posts: 213
jreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura about
Re: Send data from raspberry pi to roboRIO using c++

Hello, I have successfully built and installed the NetworkTables on the raspberry pi. However, I am having trouble getting it integrated with my vision program.

I am a bit of a newbie when it comes to linux, compilers, and stuff like that. I don't really know what to include in program. Right now I have

#include <ntcore/ntcore_cpp.h>

but it says it cannot find it. Also, when I am compiling the code I use this command

g++ -std=c++0x -lntcore vision2.cpp -o vision2 'pkg-config --cflags --libs opencv'

It does not work because it cannot file the include.

Also, I cant seem to find any documentation on how to use NetworkTables to send information from the server side. I have looked through the source code but that doesn't help me that much.

Any help is appreciated!

-Drew
  #6   Spotlight this post!  
Unread 19-03-2016, 01:19
Peter Johnson Peter Johnson is offline
WPILib Developer
FRC #0294 (Beach Cities Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 268
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
I am a bit of a newbie when it comes to linux, compilers, and stuff like that. I don't really know what to include in program. Right now I have

#include <ntcore/ntcore_cpp.h>

but it says it cannot find it. Also, when I am compiling the code I use this command

g++ -std=c++0x -lntcore vision2.cpp -o vision2 'pkg-config --cflags --libs opencv'

It does not work because it cannot file the include.

Also, I cant seem to find any documentation on how to use NetworkTables to send information from the server side. I have looked through the source code but that doesn't help me that much.
You need to add -I<path to ntcore/include directory> to the g++ command line, and the include line should just be #include <ntcore.h> (which will bring in both ntcore_c.h and ntcore_cpp.h).

Even better, if you #include <networktables/NetworkTable.h>, you'll get the same classes/functions you use on the robot program, so e.g. you can call NetworkTable::GetTable() et al. The only difference between this and your robot program is you'll need to run NetworkTables as a client rather than as the server, so first call NetworkTable::SetTeam() and then NetworkTable::SetClientMode() prior to calling NetworkTable::GetTable().
__________________
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)
  #7   Spotlight this post!  
Unread 19-03-2016, 06:23
jreneew2's Avatar
jreneew2 jreneew2 is offline
Alumni of Team 2053 Tigertronics
AKA: Drew Williams
FRC #2053 (TigerTronics)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Vestal, NY
Posts: 213
jreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura about
Re: Send data from raspberry pi to roboRIO using c++

Thanks! I'll try this when I get to robotics today!
  #8   Spotlight this post!  
Unread 19-03-2016, 11:51
jreneew2's Avatar
jreneew2 jreneew2 is offline
Alumni of Team 2053 Tigertronics
AKA: Drew Williams
FRC #2053 (TigerTronics)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Vestal, NY
Posts: 213
jreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura about
Re: Send data from raspberry pi to roboRIO using c++

I tried adding the -I<ntcore/include> file but I am still getting an error:

Code:
/usr/lib/gcc/arm-linux-gnueabihf/4.9/../../../arm-linux-gnueabihf/crtl.o: In function `_start': /build/glibc-H706YU/glibc-2.19/csu/../ports/sysdeps/arm/start.S:119: undefined reference to main `main' collect2: error: ld returned 1 exit status
this is what I used to compile:

g++ -std=c++0x -I<ntcore/include> -lntcore vision.cpp -o test_colour `pkg-config --cflags --libs opencv`

We think the reason is because it cannot find a main function even though we have a main function in vision.cpp

EDIT: when we added the library path, we forgot to source it to make the program see the lib path.

Thanks for your help!

Last edited by jreneew2 : 19-03-2016 at 11:55. Reason: Working now!
  #9   Spotlight this post!  
Unread 20-03-2016, 02:11
Peter Johnson Peter Johnson is offline
WPILib Developer
FRC #0294 (Beach Cities Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 268
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
This is what I used to compile:

g++ -std=c++0x -I<ntcore/include> -lntcore vision.cpp -o test_colour `pkg-config --cflags --libs opencv`
To be clear, I didn't literally mean "-I<ntcore/include>" but rather the location where the ntcore/include directory is, e.g. -I/home/something/ntcore/include. Also it may have trouble finding -lntcore without a -L/home/something/ntcore/build/...
__________________
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)
  #10   Spotlight this post!  
Unread 20-03-2016, 10:31
jreneew2's Avatar
jreneew2 jreneew2 is offline
Alumni of Team 2053 Tigertronics
AKA: Drew Williams
FRC #2053 (TigerTronics)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Vestal, NY
Posts: 213
jreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura about
Re: Send data from raspberry pi to roboRIO using c++

Yep. Thank you for the help.
  #11   Spotlight this post!  
Unread 21-03-2016, 11:58
jreneew2's Avatar
jreneew2 jreneew2 is offline
Alumni of Team 2053 Tigertronics
AKA: Drew Williams
FRC #2053 (TigerTronics)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Vestal, NY
Posts: 213
jreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura about
Re: Send data from raspberry pi to roboRIO using c++

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.

- Drew
  #12   Spotlight this post!  
Unread 21-03-2016, 12:20
Peter Johnson Peter Johnson is offline
WPILib Developer
FRC #0294 (Beach Cities Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 268
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)
  #13   Spotlight this post!  
Unread 21-03-2016, 13:04
jreneew2's Avatar
jreneew2 jreneew2 is offline
Alumni of Team 2053 Tigertronics
AKA: Drew Williams
FRC #2053 (TigerTronics)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Vestal, NY
Posts: 213
jreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura about
Re: Send data from raspberry pi to roboRIO using c++

Alright, now I'm getting the error:

NT: ERROR: select() to roboRIO-2053-frc.local
port 1735 error 111 - Connection refused (TCPConnector.cpp:157)
  #14   Spotlight this post!  
Unread 21-03-2016, 13:09
Peter Johnson Peter Johnson is offline
WPILib Developer
FRC #0294 (Beach Cities Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 268
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, now I'm getting the error:

NT: ERROR: select() to roboRIO-2053-frc.local
port 1735 error 111 - Connection refused (TCPConnector.cpp:157)
Do you have robot code running with the SetClientMode lines removed? You will get this error on the client (it should retry about once a second) until the robot code is running and thus the NetworkTable server is running.
__________________
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)
  #15   Spotlight this post!  
Unread 21-03-2016, 13:13
jreneew2's Avatar
jreneew2 jreneew2 is offline
Alumni of Team 2053 Tigertronics
AKA: Drew Williams
FRC #2053 (TigerTronics)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Vestal, NY
Posts: 213
jreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura about
Re: Send data from raspberry pi to roboRIO using c++

Yep. I removed them. All I have is:
std::shared_ptr<NetworkTable> visionTable;
visionTable = NetworkTable::GetTable("vision");
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:56.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi