Ask Your Question

Rosbridge in C++

asked 2021-08-25 21:17:49 -0500

zuy gravatar image

Hi everyone, I'm having a project to build a user interface with ROS in C++. I found that rosbridge is a useful tool but the rosbridge client only support java script, java and python. Is there any way we can embbed the api of one of those (roslibjs, jrosbridge, roslibpy) into C++? Thank you for reading my questions.

edit retag flag offensive close merge delete


At a high level, please explain what you want to accomplish. Why do you not create a "real" ros node, in c++ if that's your preferred language?

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-08-26 14:15:56 -0500 )edit

Because I want to build a user interface which can monitor and control the robot remotely. But I want to have a native application instead of web-based. Is it possible to do this?

zuy gravatar image zuy  ( 2021-08-26 20:23:31 -0500 )edit

Yes, it's very possible. However, you have not explained enough of your idea for me to comment on whether using rosbridge makes sense. Will you configure a ros network between the laptop (for UI) and the robot, or will the robot run a custom server that your UI app makes a network connection to? On which machine did you want to run rosbridge?

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-08-27 06:17:04 -0500 )edit

Simply I just want to create an application which can communicate to ROS (on my robot) and this application should be run on a non-ROS machine. I found that rosbridge is almost the only way to do this without a great effort. So I'm looking for a solution to use rosbridge in a native application. C++ is a prefered language, however we can be flexible. Could you give me some advice? Thank you for paying attention in my topic.

zuy gravatar image zuy  ( 2021-08-27 06:29:48 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2021-08-27 13:24:16 -0500

Mike Scheutzow gravatar image

Have you looked at the technical details of talking to rosbridge_server? From what I see, your app connects to a websocket on the robot, then you send a json message, and get one or more json responses. There are already libraries for c++ to help code both for websockets and for json. This approach should work if rosbridge does the things you need, but you will have to be careful not to subscribe to any high-bandwidth topics.

If it were me, I'd likely create a ros node in python that uses the tornado library to implement a very simple one-page http server. This approach keeps all ros message traffic on the robot, allowing the node to publish and subscribe to whatever it needs to, and not worry about consuming wireless bandwidth. How nice the displayed web page looks would depend entirely on how much effort you want to put into coding it.

edit flag offensive delete link more


That is a great idea, I'll think about how to turn that into a real thing. Thank you!

zuy gravatar image zuy  ( 2021-08-28 01:44:50 -0500 )edit

answered 2021-08-26 01:41:33 -0500

gvdhoorn gravatar image

From Google (rosbridge c++): Sanic/rosbridge2cpp and ppianpak/rosbridgecpp.

I've not used either of those, so you'll have to test them out and see whether they satisfy your requirements.

edit flag offensive delete link more


Thank you for helping. But seems like there's nothing about other libraries like nav2djs or ros2djs, I wonder if I can build a complete application with this.

zuy gravatar image zuy  ( 2021-08-26 05:13:19 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2021-08-25 21:17:49 -0500

Seen: 300 times

Last updated: Aug 27 '21