Go to Post we used to walk barefoot through five feet of snow to get to school, uphill both ways, with just barbed wire for mittens, and we liked it! - dlavery [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 25-06-2016, 12:43
balloman balloman is offline
Sophomore Programmer
AKA: Bernard
FRC #0034 (Rockets)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2016
Location: Athens, AL
Posts: 14
balloman is on a distinguished road
Network Tables with c++

I have vision code in c++ that I would like to send to the roborio with network tables. My only problem is that there are no tutorials on the wpilib website to do this in C++.
Reply With Quote
  #2   Spotlight this post!  
Unread 25-06-2016, 13:35
connor.worley's Avatar
connor.worley connor.worley is offline
Registered User
FRC #0973 (Greybots)
Team Role: Mentor
 
Join Date: Mar 2011
Rookie Year: 2010
Location: Berkeley/San Diego
Posts: 601
connor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond repute
Re: Network Tables with c++

https://www.google.com/search?q=networktables+c%2B%2B
__________________
Team 973 (2016-???)
Team 5499 (2015-2016)
Team 254 (2014-2015)

Team 1538 (2011-2014)
2014 Driver (25W 17L 1T)
日本語でOK
Reply With Quote
  #3   Spotlight this post!  
Unread 25-06-2016, 14:54
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 312
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Network Tables with c++

I'll assume your C++ project is not built with WPILib.

First, git clone the NetworkTables repository: https://github.com/wpilibsuite/ntcore
Then build it for whatever you're running this on (arm or native) with gradle. See the readme file for how.
Then, find the static library file for whatever you built it for. For example, a x64 native build would be located at ntcore\native\build\binaries\ntcoreStaticLibrary\x 64\ntcore.lib
Also find the includes folder at ntcore\include

Now you're ready to use it in your C++ project. Add the includes folder as an include path, the folder containing ntcore.lib as a library path, and tell the linker to use ntcore as a library (-lntcore on GCC)

Then in your cpp file add these includes
Code:
#include <ntcore.h>
#include <networktables/NetworkTable.h>
Documentation for NetworkTable is included in WPILib documentation here: http://first.wpi.edu/FRC/roborio/rel...workTable.html

For example, to publish a string value to the roboRIO's SmartDashboard you can do
Code:
#include <ntcore.h>
#include <networktables/NetworkTable.h>
using std::shared_ptr;
int main() {
    NetworkTable::SetClientMode();
    NetworkTable::SetIPAddress("10.te.am.2");
    NetworkTable::Initialize();
    shared_ptr<NetworkTable> myTable = NetworkTable::GetTable("SmartDashboard");
    myTable->PutString("ExampleString", "Sample Text");
    NetworkTable::Shutdown();
    return 0;
}
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
Reply With Quote
  #4   Spotlight this post!  
Unread 26-06-2016, 02:24
balloman balloman is offline
Sophomore Programmer
AKA: Bernard
FRC #0034 (Rockets)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2016
Location: Athens, AL
Posts: 14
balloman is on a distinguished road
Re: Network Tables with c++

Quote:
Originally Posted by euhlmann View Post
I'll assume your C++ project is not built with WPILib.

First, git clone the NetworkTables repository: https://github.com/wpilibsuite/ntcore
Then build it for whatever you're running this on (arm or native) with gradle. See the readme file for how.
Then, find the static library file for whatever you built it for. For example, a x64 native build would be located at ntcore\native\build\binaries\ntcoreStaticLibrary\x 64\ntcore.lib
Also find the includes folder at ntcore\include

Now you're ready to use it in your C++ project. Add the includes folder as an include path, the folder containing ntcore.lib as a library path, and tell the linker to use ntcore as a library (-lntcore on GCC)

Then in your cpp file add these includes
Code:
#include <ntcore.h>
#include <networktables/NetworkTable.h>
Documentation for NetworkTable is included in WPILib documentation here: http://first.wpi.edu/FRC/roborio/rel...workTable.html

For example, to publish a string value to the roboRIO's SmartDashboard you can do
Code:
#include <ntcore.h>
#include <networktables/NetworkTable.h>
using std::shared_ptr;
int main() {
    NetworkTable::SetClientMode();
    NetworkTable::SetIPAddress("10.te.am.2");
    NetworkTable::Initialize();
    shared_ptr<NetworkTable> myTable = NetworkTable::GetTable("SmartDashboard");
    myTable->PutString("ExampleString", "Sample Text");
    NetworkTable::Shutdown();
    return 0;
}
Thank you so much, this is exactly what I was looking for. I kept searching on google BEFORE I posted this, but couldn't find anything.
Reply With Quote
Reply


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 04:16.

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