I took the boomer example project and changed it to a ros_automobile controller by copying the source of ros_automobile into my project. It works and I can put it into gear and set the throttle and steering angle and the vehicle moves as expected.

rosservice call /automobile/set_gear "value: 1"
rosservice call /automobile/set_throttle 0.2
rosservice call /automobile/set_steering_angle 0.3
rostopic echo /automobile/current_speed

I'd like to add in a camera next, perhaps duplicate the overlay that the boomer example was setting up but publishing the image to ros would be the main feature.

I don't see examples of RosCamera in use anywhere else but it looks to be what I want- do I add it into my version of the source of ros_automobile.cpp, or is there a way to associate it with the sensorSlot/Camera through the webots gui, or something else?

Update it looks like RosCamera and all other sensors in the sensorSlot are automatically created (not sure how- because of ros_automobile?), all I needed to do was

$ rosservice call /camera/enable "value: 100"

and then it publishes on /camera/image at 10Hz.

It would be convenient if it started publishing on startup, I tried calling enable within RosAutomobile setup:

  // this gets a handle on the Camera that already exists
  camera = new webots::Camera("camera");
RosAutomobile::launchRos(...) {

The in-webots gui overlay appears when I do that, but no images get published, I still have to do the rosservice call.


1 Answer 1


I set up a new world from scratch (located here: https://github.com/lucasw/webots_ros_example) which is cleaner than using the boomer example, and added a vehicle and then selected ros_automobile from the controller drop-down (I didn't need to copy the source of ros_automobile into my project- unless I need to edit it just for my project?), then if a roscore is running it all comes up (only after a world reload I think). It looks at all the sensors in the sensor slots which includes a camera, and it generates a rosservice enable call for each in the namespace defined by the sanitized sensor name- https://github.com/lucasw/webots_ros_example/blob/main/ros_example/scripts/sensor_setup.py brings up what I want but would have to be hand-edited to match any sensor changes in the webots gui.

(I didn't use the snap installed webots, and had to make changes to build it from source on Ubuntu 22.04 and made additional changes to ros_automobile so steering angle and throttle could be set via topic instead of the default service call, it's all in this fork: https://github.com/lucasw/webots/tree/ros_auto_topic_control)

(Not sure why the wheels wobble so much as seen in the picture, something for another question)

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.