Web server utilization

This is a very simple topic. I was wondering if i could pull numbers off a web server and use them for our robot using the network tables by wpi. I want to know if anyone has successfully done this (not counting limelight numbers) and would like to help me.

What sort of server? Can you provide more details?

There are some available clients for interfacing with networktables in different languages. pynetworktables2js is one for javascript, and pynetworktables, accordingly, for python.

Am I correct in assuming that you want to have some application on your driver station, that updates values that your robot can read from networktables?

you are somewhat correct. I want to get values from a web server that gets values from an arduino and have the robot use those values to complete a task.

To clarify, is this a server elsewhere on the robot-DS network (i.e. a Pi or similar) or a server on the Internet? For the former, it’s very possible to use NetworkTables or just your language’s built-in networking code (all of that will function normally on the Rio). For the latter, that’s a bit more of an operation, but could probably happen with some skillful network setup.

I’m not totally familiar with how arduinos work with ethernet, or if you can use the networktables libraries in WPIlib for your purpose, etc. Sorry I’m not much help to you.

What I can recommend is instead getting the arduino to listen / speak to the rio over i2c. Here’s the code we used this year for our arduino. Admittedly, it doesn’t send anything back over i2c, but it does setup the interface, and there’s a lot of other documentation on CD on how to get i2c working for your team.

Alternatively, us the MXP serial lines. Serial is much more tolerant, and if you don’t need daisy chaining, much simpler. We saw a massive drop in errors once we switched our Arduino to serial. It’s super not worth it to use ethernet for an Arduino… i2c and serial are so much simpler, especially considering that you’d need a switch onboard to test it in the pits.

1 Like


Only if the server also supports network tables, as a communication protocol over TCP/IP. Per @jlmcmchl there are a number of existing libraries to do this, so it’s hopefully just a matter of finding one that works.

In case network tables doesn’t pan out, it’s not the only option for interacting with a webserver. In Casserole’s 2017 bot, python was used to create a UDP Server on a Beaglebone Black, which would broadcast vision target into to any device that connected to it. The built-in java Datagram libraries were used on the roboRIO client side to connect to the Beaglebone and receive the packets.

There are plenty of tools to “scrape” websites in Python. You can combine that with the Python NetworkTables library from RobotPy to make a tool.

However, if you control the code on the Arduino as well, then you may be making your life much harder than needed. You should “think outside the box” about the complete solution.

For instance, web servers do not need to server only HTML. I would have the server send JSON or even plain text with the numbers. Then a Python script could simply query the URL, load the resulting JSON, and write the values into NT. Other languages could be used too.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.