Using the robot WIFI network to transmit data to an application?

I’m probably going to get a lot of hate for this one - please keep it to yourself as it starts arguments (and is soul-crushing to an incredible degree). We’re writing a robot in c++ and want to play around a bit with the bottom layer of FRC coding by setting up a REST api server on the robot that would allow us to visit a “website” in our browser and see streamed information from the robot. However, we can’t find any information on doing this. Is there an Ethernet class or something that we can use? We’ll just use Python Tkinter/console if we have to implement more than the HTTP protocol.
Thanks in advance, and PLEASE don’t tell us this is difficult and pointless.

This has been done by some teams before. For C++, crow is a good place to start. One idiomatic design could be to only implement a REST API using crow, and build the entire frontend as a single-page app with webpack. If you want to go lower level than crow, you always have the Linux API at your disposal

Thank you! I’m glad this is actually possible

But do they have support for an FRC robot? I don’t think its possible to install boost on one…

The RoboRIO is just a standard linux system. You absolutely could get boost or pretty much anything else you can get on linux on it. You’d probably just have to compile it yourself following their docs.

Caveat: implementing this will probably be difficult, but maybe not pointless. You will learn a lot about web development, using third party libraries, and synchronization (if you make the dashboard capable of writes). None of these problems are unique to robotics, FRC, or the roboRIO. They will not make your robot score more points. It all depends on what you are aiming to learn.

Some additional sample points I know of:

In general, the robot and DS communicate over a normal computer ethernet/wifi/tcp-ip/etc. network, which teams can use as they please, as long as usage falls within Game Manual restrictions. R60-R64 would be the main relevant rules for 2021. They have been pretty stable over the years.

FRC Web Components is one existing solution, many teams have had success with this one.

The NetworkTables V4 spec is expanding to allow browser-based visualization and logging solutions to connect directly to the roboRIO.

We copied a solution used by Team 254 back in 2015. Ours wasn’t working till 2017 or so, with a lot of different assumptions than what other teams were working with.

If you want to start really low level, wpiutil (built as part of wpilibc) has a webserver example program that runs a webserver on a separate thread. allwpilib/webserver.cpp at main · wpilibsuite/allwpilib · GitHub

1 Like

Just use the linux socket.h. It actually runs really well, and you don’t have to bother reading WPI’s massive code. Geeksforgeeks, bogotobogo, numerous people on github have good socket tutorials

So I am curious, why did you ask for help if you’ve already decided on a solution?

You mentioned using boost previously, which is an enormous library. The code I linked to is using a fairly lightweight C++ wrapper around two off-the-shelf C libraries: libuv and http_parser. You can also use straight C calls to libuv and http_parser, or even raw Linux sockets and a hand-written HTTP parser, of course. In general, all of these approaches are quite low level compared to eg JavaScript or Java’s libraries for doing HTTP. It can be a good learning experience to write from scratch, but it’s a trade-off on where you want to spend your time and energy.

2 Likes

While I appreciate your advice, it does not apply to our team’s situation. To accomplish our team’s goals, it was more effect to implement at a higher level of abstraction.

I see the variety of solutions presented already as key evidence of this: The selected solution must align with all desired outcomes.

As a general statement: To discuss solutions in a vacuum from desired outcomes is to talk past each other, actively inviting unproductive bickering.

1 Like

Because I didn’t know I had access to the linux API

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