Mobile Router For Robotics - Standard and AdHoc?

I have a slightly odd use case in that I'm building a mobile router for use with my robots and associated kit. I have built a router based around a Waveshare Compute Module 4, 4G/5G base, along with a pair of Alfa USB adapters and it works an absolute treat as a standard access point setup.

I'm currently able to use the on-board wifi to connect to an existing wifi network to act as the WAN, and I've configured one of the USB adapters to work as an AP. This all works great, I've even got one of the ethernet ports to act as a wired WAN if available and the other as a LAN port. The next bit is tricky, for me at least...

At some events I will have a base of operations set up and when I'm nearby, all is well. The issue is with moving out of the range of the AP. If I was able to configure AdHoc wifi on the robot and controller, would I be able to connect to the router when in range but still have the robot and controller talking directly otherwise?

None of my laptops are able to connect to an AdHoc network, so I'm really hoping I can have it set up so that when I'm back at base everything will connect via various adapters on the router and will all be able to talk to each other.

Pi Wifi: connect to event/home wifi connection as WWAN
USB Adapter 1: Configured as AP
USB Adapter 2: Configured in AdHoc mode

Does anyone know if what I'm trying is even possible please? I've not used AdHoc wifi before and not sure if my understanding is just way off the mark or not.

It will do what you want just normally - the built-in radio connected to the WAN wifi network doesn't have to be in range or communicating for a second radio to provide a LAN access point SSID to the robot and controller. Adhoc isn't required for this.

Aye, but if the router is plugged in to the mains for power it'll be stuck in one location. If the robot goes out of range or if interferance from other stations kicks in the connection is dropped. That's where I hope adhoc would be useful.

I also can't use/rely on event WiFi for this, all too often they either have wireless isolation enabled or a device limit

Your description is confusing...

If one router is fixed in place (because of the mains power connection) and the other one is on the robot and might go out of range, of course the connection will drop. But if that happens, they're out of range and adhoc isn't going to solve that... so is there another device in the equation here that would be closer to the robot that you want to be able to connect?

There's only one router, sorry for the confusing description as I wrote it late at night after a long few days trying to get something working.

The other device is the controller for the robot, it's also running on a Raspberry Pi.

Perhaps a mesh network is what you need?

I have one at home, but at events I won't be able to install one and I don't believe a Rasbperry Pi running raspbian can act as a mesh node either. Happy to be corrected there though.

Hmm, I may be happily corrected:

1 Like

So what device is on the robot and which is stationary? Which operating system/firmware is on each device? And which device are you hoping to turn into adhoc or mesh mode upon loss of signal/out of range?

1 Like

The router is running OpenWRT, 22.03.5, and it'll be stationary. Both the robot and the controller are running Raspian on a Raspberry Pi each and are mobile. I also have a laptop that I use for dev and debugging while on site, that doesn't support IBSS or 802.11s though.

The router is has the following radios:

  • Compute Module 4, onboard: connects to site/event wifi as WAN
  • USB WiFi 1, Alfa (1200AC) : <not configured, hopefully as Mesh/AdHoc mode>
  • USB WiFi 2, Alfa (1200AC) : Acting as Access Point

The robot is also running on a Compute Module 4 and has it's onboard radio, the controller is running on a Raspberry Pi 4 with the same radio I believe, just without the external antenna connection.

I'm not sure what the best technique would be so I'm not going to use terms I don't quite understand, but the ideal solution would be one whereby when the robot or controller are in range they connect to the router. They'd then be accessible by any other clients connected to that router and have an internet connection (if available)

If the robot and controller are out of range of the router, they can connect to each other directly, ideally without the connection dropping as this could screw up the processes running the robot.

The non-dropping of the connection is why I thought an adhoc network would be the way forward, as I thought that they'd just connect to the router if it's present and otherwise just connect to each other. I'm not sure if I'm barking up the wrong tree with trying to get this working this way or not, or if AdHoc or Batman-ADV would be the way forward.

If anyone could set me on the right track, even if it's "this wont work", then I'd appreciate it.

So the Pi4 is onboard the robot and that is what you want to go into ad-hoc mode if/when it goes out of range?

The Robot is running on a Compute Module 4, which is the same chipset as a Pi 4, and the controller is running on a standard Pi 4 board. Ideally they'd both be in adhoc mode all the time along with the second radio on the router which would allow access to the rest of the network and the internet.

And the robot is running raspberry pi os, right?

Yes, both the robot and the controller. They are both running the x64 bit Buster OS specifically, there's a lot of reasons why I had to use this one rather than Bullseye or Ubuntu so this is the one I'm stuck with for better or worse.

Thanks for your patience with this by the way, I know it's an odd use case so any help really is appreciated.

I’m still really confused - if the stationary router and the robot are out of range of each other, what purpose would ad-hoc mode have? The devices would still be out of range and unable to connect to each other. I still don’t understand what, if anything, will connect to the robot in adhoc mode that would still be in range.

The controller would connect to the robot, it's a separate device pictured a few posts above and below alongside the robot. It allows for manual control over the robot and display of data on it's screen.

The robot is running on the Compute Module, the controller has the Raspberry Pi 4 on board. From a chipset perspective they are near enough identical however.

Ok. I think I understand now. The controller would be in proximity of the robot, even if both were out of range of the stationary ap.

What if you made the controller an ap instead, and have the robot connect to it that way. You could detect a loss of signal on the robot (ie ping tests through WiFi ok the stationary ap, detect when the robot (and/or controller) drops). When that happens, change the controller to an ap, and the robot would be able to connect to the controller directly.

That said, since those devices are not running openwrt, this is probably not the place to get detailed help on this topic. You might want to ask on forums related to raspberry pi os.

I would make either the robot or the controller an AP, and the other two devices clients of that AP. The Router being a client can still be the path to the Internet-- when available. This is a reversal of convention but it does work.

Then it's no big deal if you move the AP out of range of the Router, the robot and controller are still linked the same just no path to the Internet. In this scheme the robot and controller would have to stay in direct WiFi range of each other but I think that you said that is acceptable in the use scenario.

Setting everything with static IPs would be best. The wan side of the router can use DHCP to adapt to different uplinks to the Internet.

1 Like

As I've said, ideally the connection wouldn't be interrupted hence wanting to avoid switching modes which takes time. I've put steps in place to prevent the robot moving when LOS occurs but it's never going to be perfect and finding edge cases has proven tricky.

I have had the robot acting as an AP in the past but it was a bit of a pain to set up and added an overhead I'd prefer to avoid. It's a solid idea though and with the router being able to connect as a client it certainly makes things a bit easier. I guess it'd also mean I can connect my laptop to it when away from the router too.

I may just add a second wifi adapter to each at this rate and call it done. I'll see if I can get the mesh idea working further down the line, it feels like the better option but I just need something that works at this point.

Thanks for the sounding board folks, I'll report back if I ever get my initial idea working.