0
$\begingroup$

Rosanswers logo

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.


Originally posted by Fizpok on ROS Answers with karma: 11 on 2023-01-19

Post score: 1


Original comments

Comment by Mike Scheutzow on 2023-01-20:
Are you using move_base & costmaps?

Comment by Fizpok on 2023-01-20:
costmaps, yes. Not sure about move_base - I am just a beginner. I follow the https://navigation.ros.org/getting_started/index.html

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

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,
    1. (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.


Originally posted by ljaniec with karma: 3064 on 2023-01-19

This answer was NOT ACCEPTED on the original site

Post score: 2


Original comments

Comment by Fizpok on 2023-01-20:
Thank you very much. Now I know what I am doing this weekend :)

Comment by ljaniec on 2023-01-20:
Please share here your results later, it is a quite interesting question!

$\endgroup$
0
$\begingroup$

Rosanswers logo

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.


Originally posted by Mike Scheutzow with karma: 4903 on 2023-01-21

This answer was NOT ACCEPTED on the original site

Post score: 2


Original comments

Comment by Fizpok on 2023-01-23:
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 are displayed, and as new data arrives (and as we move), length and colors of arrows change... It all can be very dynamic.

In Gazebo (and probably, in RViz), the world might have 3rd dimension, so flat image might not be the best...

Comment by Mike Scheutzow on 2023-01-23:
The simple thing to do is create 1 image, then draw ON that image. The opencv API provides functions for drawing rectangles.

Comment by Fizpok on 2023-01-23:
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.

$\endgroup$

Your Answer

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