ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

How to "paint" spots robot visited in Gazebo?

asked 2023-01-19 07:56:37 -0500

Fizpok gravatar image

Hi, I have a robot (let's say it is a simple 2-wheeled+caster wheel diff drive robot). It works as a vacuum cleaner of a sort: moves over the "world", leaving behind a band of "clean carpet". My question is, how can I paint this path that robot covered, in a different color, so it can be easily seen? I would provide my ideas, but I have none: no idea how to do it right. I use ROS2, Python and Gazebo. Thank you.

edit retag flag offensive close merge delete

Comments

Are you using move_base & costmaps?

Mike Scheutzow gravatar image Mike Scheutzow  ( 2023-01-20 10:47:38 -0500 )edit

costmaps, yes. Not sure about move_base - I am just a beginner. I follow the https://navigation.ros.org/getting_st...

Fizpok gravatar image Fizpok  ( 2023-01-20 14:38:12 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
2

answered 2023-01-19 17:03:43 -0500

ljaniec gravatar image

updated 2023-01-20 15:09:29 -0500

You can try to implement your own Gazebo plugins (C++):

I can see two plugins or a plugin + a timer node there:

  • 1) (plugin/node) It should modify a PNG file, basing on the robot localization every N seconds, "painting" a path on the surface,

  • 2) (plugin) Update visuals of the floor by loading aforementioned PNG file as its texture every few seconds.

A "hackish" way in Python would be spawning a static objects (a tile?) without collision boxes right under the robot, below the surface, with a bright color, every N seconds. It has some problems thought (many objects in the world after a while etc.). You could work it out thought, e.g. delete the overlapped boxes and swap them with one bigger tile etc.

edit flag offensive delete link more

Comments

1

Thank you very much. Now I know what I am doing this weekend :)

Fizpok gravatar image Fizpok  ( 2023-01-20 14:34:59 -0500 )edit
1

Please share here your results later, it is a quite interesting question!

ljaniec gravatar image ljaniec  ( 2023-01-20 15:10:28 -0500 )edit
2

answered 2023-01-21 08:28:55 -0500

Mike Scheutzow gravatar image

updated 2023-01-21 08:39:35 -0500

I have seen no pre-packaged way to do what you ask for.

I would think twice before implementing this in a gazebo-specific way. The problem is that it will work only in simulation (and will not work when running a real robot.) I'd look for a solution that works for both cases.

Probably the simplest programming approach for someone new to ros would be to create a python ros node which opens a graphical image window using the opencv API. The idea is to treat this window as a 2D grid. Load your map into the window, scaling it if necessary. Subscribe to your robot's pose topic. For each pose message you receive, color the corresponding grid x,y in the window.

There is a conceptually similar approach that would use rviz for the display by creating a custom layer for the global costmap, but this requires using c++, and the API's have a steeper learning curve than opencv has. This approach is not for beginners.

edit flag offensive delete link more

Comments

I am new to ROS (actually, ROS2), but not to C++: I can program OpenCV. So, could you please explain, what should I do with the image after it is created in OpenCV? I need to put it on top of a map somehow, right?

Also, I am not sure the approach is optimal. Let me suggest two use cases. It needs to work both for simulated robot and for a real robot that is reflected in a simulation (this is part I haven't touched yet).

  1. A robotic vacuum cleaner cleans the floor, and I want clean floor to be marked with a color. It is similar to occupancy grid, so i thought about mimicking what is done in RViz... except, it would be nice to have it in Gazebo.
  2. A car drives in a simulated city. As it approaches a cyclist, arrows of possible directions of this object ...
(more)
Fizpok gravatar image Fizpok  ( 2023-01-23 06:58:47 -0500 )edit

The simple thing to do is create 1 image, then draw ON that image. The opencv API provides functions for drawing rectangles.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2023-01-23 07:25:51 -0500 )edit

I understand. My question is, how can I use the image after I painted on it? Like, should I open it in RViz as, say, a layer on top of a map? If yes, how do I do it? Thanks.

Fizpok gravatar image Fizpok  ( 2023-01-23 14:20:26 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2023-01-19 07:56:37 -0500

Seen: 152 times

Last updated: Jan 21 '23