Communication between host machine running ROS and web client

asked 2022-01-21 07:56:24 -0500

n.dafinski gravatar image

updated 2022-01-21 08:49:18 -0500

Hey guys, so here's my situation in brief: I have a system (NVidia Jetson AGX to be precise) that is running ROS with various nodes that performs a SLAM algorithm. I also have a web app hosted on it that is being used to visualize the results of the SLAM. The app is made using Next.js, and I make use of roslibjs and rosbridge to send the data from the NVIdia via websocket.

Now, my next goal is to give the user some basic control over the system and a way to send commands from the web application back to the host machine so they can interact with the host to perform tasks like starting and stopping the SLAM nodes, changing some parameters for the algorithm with dynamic_reconfigure( I haven't touched that part yet ) and so on, but mainly start and stop the group of nodes responsible for the SLAM.

I thought about a couple of ways I could potentially do it, I tried just making a super simple express.js web server on the host and just using http requests to trigger the starting of shell scripts, which could certainly be made to work, although is probably less elegant of a solution that I would like to have. The other method I've found could maybe work is using Python for a web server along with roslaunch but I've read that Flask for example has some issues when used with ros because both need to run on the main thread. Perhaps another way to do it is just to send the commands to start/stop via topics using roslibjs over the websocket and then have a python/cpp node or even a javascript client with roslibjs listen to these topics and act accordingly.

So if you guys have any solutions or suggestions for how I can get commands from the web application sent back to the host and programmatically start/stop my ROS nodes I'd appreciate any advice, thanks.

edit retag flag offensive close merge delete