pynetworktables: python wrappers for NetworkTables

The RobotPy project has a new github repo that contains SIP-based python wrappers for NetworkTables that will work on your PC. Currently only the server (robot) side of the wrappers work, but in theory the client side should work with a bit of patching. I won’t be able to work on fixing that until next week.

https://github.com/robotpy/pynetworktables

Feedback and patches welcome.

Ok, found the client bug in WPILib. The python wrappers now will do server and client mode, and there are samples included with the source code that demonstrate this functionality.

For the bug, see http://firstforge.wpi.edu/sf/go/artf1600?nav=1&_pagenum=1&returnUrlKey=1358981339674 .

I am curious if I could do this with Python 2.7 (I know SIP supports it)?

I ask because I was thinking about using SimpleCV for vision and it would make life much easier.

I haven’t tried it, but I don’t have any reason to believe it wouldn’t work.

Use the following commands to build pynetworktables. Do the following on
Windows:

set ROBOTPY=c:\path	o\robotpy\src

What do you mean by src

Why is this different than the unix version?

Read it out loud. It is not meant to be a literal path. It is the path to the robotpy source directory. It is different from the unix one by accident.

I did read it out loud being different is what confused me. Thanks I got it.

Excellent. I’ve changed the documentation too, so it doesn’t confuse anyone else :slight_smile:

Rookie team here, very confused.

First, is this necessary to use SmartDashboard from Python?

Second, RobotPy has a simple installable on firstforge which we used. Is there something comparable for this pynetworktables, or do I need to build from scratch?

Third, if I do have to build it, do I need to build+install robotpy from source too, or does the pynetworktables build process give me something I add on to my robotpy install?

Thanks!

This allows you to use NetworkTables/SmartDashboard from python on your PC. This code does **not **run on the Robot.

This code would be useful if you had something on your driver station or programming laptop that wanted to communicate with your robot code via NetworkTables, or if you were running unit tests on your PC (using fake-wpilib) that use SmartDashboard.

There currently are no binary distributions of pynetworktables, so if you wanted to use it, then you would need to compile it yourself.

Ah, so smart dashboard should work from stock robotpy without modification? … then I have some debugging to do… :slight_smile:

Thanks!

I am trying to build the network tables using the instructions on a ODROID-U2 ubuntu - linaro 12.3

linaro@linaro-ubuntu-desktop:~/pynetworktables$ ROBOTPY="/home/linaro/robotpy/" python setup.py build
running build
running build_ext
building ‘pynetworktables’ extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablescmodule.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablescmodule.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesEntryValue.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesEntryValue.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesSmartDashboard.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesSmartDashboard.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesSendableChooser.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesSendableChooser.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesNamedSendable.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesNamedSendable.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesSendable.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesSendable.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesWriteManager.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesWriteManager.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesTransactionDirtier.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesTransactionDirtier.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesOutgoingEntryReceiver_NULL_t.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesOutgoingEntryReceiver_NULL_t.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesNetworkTableEntry.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesNetworkTableEntry.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesOutgoingEntryReceiver.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesOutgoingEntryReceiver.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesTableListenerManager.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesTableListenerManager.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesStringArray.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesStringArray.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesNumberArray.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesNumberArray.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesNetworkTableEntryTypeManager.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesNetworkTableEntryTypeManager.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesNetworkTableEntryType.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesNetworkTableEntryType.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesBooleanArray.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesBooleanArray.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesArrayEntryType.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesArrayEntryType.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesComplexEntryType.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesComplexEntryType.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesArrayData.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesArrayData.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesComplexData.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesComplexData.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesPeriodicNTThread.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesPeriodicNTThread.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesNTThread.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesNTThread.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/linaro/pynetworktables/src -I/home/linaro/pynetworktables/sip -I/home/linaro/robotpy/Packages/wpilib -I/home/linaro/robotpy/Packages/wpilib/WPILib -I/usr/include/python2.7 -I/usr/include/python2.7 -c build/temp.linux-armv7l-2.7/sippynetworktablesDefaultThreadManager.cpp -o build/temp.linux-armv7l-2.7/build/temp.linux-armv7l-2.7/sippynetworktablesDefaultThreadManager.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
/home/linaro/robotpy/Packages/wpilib/WPILib/networktables2/thread/DefaultThreadManager.h: In member function ‘virtual NTThread* sipDefaultThreadManager::newBlockingPeriodicThread(PeriodicRunnable*, const char*)’:
/home/linaro/robotpy/Packages/wpilib/WPILib/networktables2/thread/DefaultThreadManager.h:23:20: error: ‘virtual NTThread* DefaultThreadManager::newBlockingPeriodicThread(PeriodicRunnable*, const char*)’ is private
build/temp.linux-armv7l-2.7/sippynetworktablesDefaultThreadManager.cpp:68:69: error: within this context
/home/linaro/robotpy/Packages/wpilib/WPILib/networktables2/thread/DefaultThreadManager.h: In function ‘PyObject* meth_DefaultThreadManager_newBlockingPeriodicThread(PyObject*, PyObject*)’:
/home/linaro/robotpy/Packages/wpilib/WPILib/networktables2/thread/DefaultThreadManager.h:23:20: error: ‘virtual NTThread* DefaultThreadManager::newBlockingPeriodicThread(PeriodicRunnable*, const char*)’ is private
build/temp.linux-armv7l-2.7/sippynetworktablesDefaultThreadManager.cpp:95:100: error: within this context
/home/linaro/robotpy/Packages/wpilib/WPILib/networktables2/thread/DefaultThreadManager.h:23:20: error: ‘virtual NTThread* DefaultThreadManager::newBlockingPeriodicThread(PeriodicRunnable*, const char*)’ is private
build/temp.linux-armv7l-2.7/sippynetworktablesDefaultThreadManager.cpp:95:143: error: within this context
error: command ‘gcc’ failed with exit status 1
linaro@linaro-ubuntu-desktop:~/pynetworktables$

Any Ideas?

Thanks,

Paul Davis
:frowning:

You need the current git head of RobotPy to compile pynetworktables. RobotPy uses git submodules now, and if you don’t check it out correctly then pynetworktables will not compile for you.


git clone https://github.com/robotpy/robotpy.git robotpy
cd robotpy
git submodule init
git submodule update

I’ve gotten it to work on Windows and Linux for Python 2 and 3.

That explains allot. Thanks

Thanks that worked.

Mandatory update March 4, 2013

This is a mandatory update for C++ teams and MUST be installed before competing. Install this build on your development system and rebuild your program. Then deploy the new resultant .OUT file to the robot. The fixed issues are:

  1. Adjusted the packet size of data transmitted with NetworkTables (and SmartDashboard) to avoid excessive number of TCP/IP packets.

  2. Updated minimum CAN Jaguar version to 101 as per rule 61-4.

  3. Added a fix to the Preference class to make it more robust.

  4. Subsystems now only report changes in Test mode (LiveWindow updates)

  5. Removed some unnecessary initialization of some variables.

  6. Added code to make the Scheduler class sendable so that it can be written to the SmartDashboard.

  7. Fixed an issue with numeric arrays in NetworkTables.

  8. Fixed an issue with invalid and/or null pointers in LiveWindow code causing crashes in threaded robot code.

The update can be found here: http://firstforge.wpi.edu/sf/frs/do/viewRelease/projects.wpilib/frs.2013_frc_update_for_c.mandatory_update_rev_3622

Are you going to update your forked Github to take this in to account?

The RobotPy WPILib repository (which is what pynetworktables uses) has already been updated with the latest updates.

We are using an Odroid running Ubuntu and we have a script to start up automatically. The Odroid is booting before the cRio and trying to connect with the Networktables. This is causing the cRio to not boot at all. Is there a way to check if the network tables are running? Or is there some other way to interface the Odriod to the cRio?

Thank you

What do you mean by this, and what language are you using on the cRio? Is it your program that’s crashing? What happens when you don’t have the odroid running? If your program is running on the cRio and then the odroid starts, does it crash immediately? More details needed.

FYI, if you were using pynetworktables, update to the latest version of it/RobotPy. There were a number of stupid bugs that would cause crashes and data inconsistencies. The issues should be fixed now.