Controlling a RoboRIO through a Raspberry Pi & a wifi Router

Hello there!

Alrighty so, I’m working on a college-level project for a mining robot. We are using the FRC RoboRIO to work as the hub for almost all of the information on the Robot itself, save the obstacle and distancing sensing cameras that are connected to a Raspberry Pi 4B.

What I want to do is be able to control the robot from a computer connected to a Router whose wifi signal is connected to the Raspberry Pi 4B, which in turn is connected to the RoboRIO via ethernet cable. Please see the below image if there is any confusion.

My dream would be able to write an executable front panel of a LabVIEW VI that can send signals over Wi-Fi to the RoboRIO, which can, in turn, send signals back to be viewed, as one does in FRC with the dashboard.

My Team and I have several ideas that we have begun testing (see side note below), however, we have limited time to test and I’d love to hear if anyone has any ideas or things I should look into. We are using LabVIEW on the RoboRIO and Python on the Raspberry Pi. I am personally fluent in LabVIEW, and we have someone on the team fluent in python + several other languages.

Please let me know if you have any questions for me.

Sidenote:

Using TCP, we have been able to send a signal in labVIEW code running on the RoboRIO to a python server running on the RPi who then sends a signal back. (The signal in question was to subtract three from whatever number we sent. from the LabVIEW end, Send 1000, recieved 997, then 994 etc.) That was fun but due to our inexperience took longer than it should and does not appear to be exactly what we wish to use from my perspective.

I wonder if ROS makes sense here - I don’t know all that much about it but maybe someone else can chime in. @marshall maybe?

For the TCP stuff, what performance characteristics where you expecting, and what did you end up seeing? Did you try disabling Nagle’s algorithm?

1 Like

Check out this guide from FRC2220

It helped us a lot.

1 Like

Not sure this helps, but Linux networking is really flexible. For example, you could set up the Pi to route packets so that the laptop and RIO could communicate as if the Pi were not there. You’ve basically drawn a network, and there are a lot of ways to establish communications.

Here’s an overview article I just found – there are probably better ones, as this one covers a lot of stuff that isn’t specific to setting up the router function, but it seems fine to start: Using Raspberry Pi as a Wired Router – Linux Hint. I wouldn’t treat this as a series of steps to follow, but as an outline of what you do to set up routing. If you assign IP addresses carefully, you can set things up as a bridge, which may be simpler. Maybe the thing to do is to search until you find an article that’s pretty close. Putting IP addresses in your diagram might help to narrow things down, but if you are flexible here, it may help to simplify things if you choose the IP addresses carefully.

You’ll have to excuse me as I am unfamiliar with TCP and Nagle’s Algorithm. We were following This Guide specifically python server LabVIEW Client. We modified it to get what I detailed at the bottom of my Original Post. We felt like while we could make this work, it would just take too long for the time we have.

Plus we’d prefer not to jump from the computer to the raspberry pi then to the roboRIO, we’d prefer a method that allows us to send signals directly from the computer to the RoboRIO, using the RPi simply as more of a conveyor than an interpreter.

1 Like

If your IP addresses are set up such that bridging will work, the accepted answer to this question is pretty close to what you’ll need. This article is a more concise way to set up routing. Find someone who has basic familiarity with networking and you’re there. Or, fill in the diagram with IP addresses for everything that has them set and note which might be changed and we can go from there.

The Wikipedia article on bridging provides a little background:

A network bridge is a computer networking device that creates a single, aggregate network from multiple communication networks or network segments. This function is called network bridging. Bridging is distinct from routing. Routing allows multiple networks to communicate independently and yet remain separate, whereas bridging connects two separate networks as if they were a single network. In the OSI model, bridging is performed in the data link layer (layer 2). If one or more segments of the bridged network are wireless, the device is known as a wireless bridge.

If you have someone who wants to learn networking, this seems to be a pretty good introduction.

Hey there, thanks so much for your responses and apologies for the large delays between my messages, I’m communicating with a few people in my group and it sometimes takes time for them to respond. I’ve set some of them on reading through some of the articles you’ve linked and they have some ideas they’d like to work through.

I’ve been in the lab and have worked with the raspberry pi a little. Typing hostname -I on it gave me the IP Address of 192.168.1.131, and second one that I assume was the roboRIO since whenever I disconnected the roboRIO, it disappeared from the list.

Anywho, lets assume I’ve given the RoboRIO a static IP address of 10.64.63.2 (using the FRC IP configs because why not). The Laptop IP Address controlling this whole process might change, as different teams may wish to connect. Is this a good place to “go from” as you said?

Yeah – it sounds as though you might want to use routing, rather than bridging, given the IP addresses you mentioned. The big thing there was that the laptop IP address might be something you don’t control. But, you might actually have control over this through a protocol known as DHCP, which is often used to hand out IP addresses to things like laptops (especially if you plan to use a router as in the initial diagram).

What is really needed is a detailed diagram of everything involved in the networks, the hardware, the connections, what operating system is running on things like laptops, what kind of router you will use, etc. Using the router will help to isolate things, so that you may not need to do anything on the laptops – but you will need to get the router configuration right, as well as the Pi.

The initial diagram is close, it’s mainly missing information on the router. The other thing that comes into play here is the level of detail required in any instructions. If you have someone who’s somewhat familiar with networking, I can just outline things and they can work out the details. In this case, I probably wouldn’t need any more details on things like the router.

Here are the main steps in such an outline:

  1. Set up the router to hand out an IP address to laptops, via DHCP;
  2. Set up the router to (also via DHCP) inform the laptop that it is providing connectivity (routes) to 192.168.1.x and 10.64.63.x;
  3. Set up routing on the Pi so traffic for the RIO is sent on.

Step 3) is going to be very similar to what’s covered in this note.

If the laptop is going to be running things such as a driver station, you most likely want to check out this page. You will most likely be closest to what’s described in the “On the Field” section.

If you change the IP address on the Pi, you can probably make things even simpler. In other words, giving it an address that starts with “10.64.63.” will make the routing set up easier. Basically, the Pi can replace the radio, and also do it’s Pi thing (whatever you have it doing).

I’ll be in our lab for several hours straight this weekend working on the robot to get it ready for our proof of life, and in the downtimes, I’ll be working on our wireless connection. Once I am able I’ll post an update, most likely with more questions.

Thanks so much for the links you’ve been posting and the guidance, I am very new to this. It has been a big learning experience.

1 Like

So, I wrote some labVIEW code and was able to communicate how I want to over localhost using UDP, but now the main thing we’re having difficulties with is bridging on the Raspberrypi. We looked up how to set up bridging, and we found and followed a guide, but it does not appear to work. It may be simply due to our unfamiliarity with linux/networking, but we’re not sure.

Can you provide a link to the tutorial you followed?

Additionally, any steps deviated from the tutorial would be useful too.

The two tutorials we followed can be found at the following link:

We followed each separately to the T, reformatting the SD card in between each tutorial. I’m sure that with UDP we can do what we want to do, just we need to figure out how to get this linux stuff down.

2 Likes

Thanks for these. Helps me understand what you are probably running into.

Are you still trying to use a router as in the original diagram or are you just using the raspberry pi and connecting the laptops WiFi to the raspberry pi?

I get the sense that the trouble here isn’t Linux but just networking. It looks to me based on what these tutorials are having you do that you are possibly running into a double NAT issue or a problem with subnets and routing.

Can you amend your logical diagram into a physical diagram to include IP addresses (possibly a range if you are relying on DHCP) and subnets/gateways for each device? That would be helpful for helping you troubleshoot.

Other information that is useful are pings and traceroutes from each device to the next device in the sequence so we can see where issues are coming from.

Are you hoping to rely on host names with this and mDNS? If so then that’s going to add its own fun with broadcast messages and forwarding.

The answer to your first question is yes we are still using a router.

I’ve amended my diagram as best as I can with as much information as possible, you can find that below.

As to your final question, I believe the answer is no.

Thanks so much for your chiming in on this. Today was a really stressful day in the lab with nothing working.

1 Like

Thanks for this! So I can see one problem right off and that’s the 169.x.x.x address on the RoboRIO. That’s a self assigned (“automatic private IP” is the correct term IIRC) address and it makes me think that it’s not one that has been assigned intentionally and it’s just the RoboRIO failing back to something it knows instead of picking up a DHCP address.

Given the tutorials you linked and trying to set this up as a bridge, you might want to try setting a static IP on the roboRIO to be something on the 192.168.1.0/24 network you are using. That will keep everything on the same subnet at least and let us bypass DHCP for the moment and keep trying the networking config settings.

I’m fairly certain that the Pi has the capacity to handle the direct connection without a crossover cable but that might also be something to verify here and try.

Hang in there, you are doing systems integration with networking. I can’t do much tonight but if you want to PM me some times you are free tomorrow and will have access to the setup then I can try to setup a zoom and help directly with the troubleshooting.

I attempted to set a static IP for the roboRIO but every time I did I could only see it through USB. I never did this while I was a student in FRC, so I suspect I am doing it wrong.

Thanks so much for the quick reply. I’ll shoot you a message tonight as soon as I know what times I could have access to the lab.

1 Like

Had a great zoom session.

The first issue we resolved was that the main laptop was plugged into router “Internet/WAN” port. We swapped that to one of the LAN ports on the router. We then set about following this tutorial for a raspberry pi bridge:

https://willhaley.com/blog/raspberry-pi-wifi-ethernet-bridge/

Last steps were configuring some DHCP reservations so they could keep DHCP functionality but maintain known IP addresses.

Took about an hour or so of troubleshooting but a lot of that was me just trying to understand the network and then resolving getting the packages installed on the pi. It was mostly networking configurations that needed to be worked out. Good stuff overall and hopefully their project is a huge success now that they’ve got the networking sorted out.

3 Likes

Thanks, this is great. Sorry, was away for the weekend and offline. If there’s anything else, let me know. Very glad things worked out!

1 Like