Visualize sensor trace

Typically: "How do I... ", "How can I... " questions
Post Reply
neostek
Posts: 21
Joined: 15 Feb 2013, 10:26

Visualize sensor trace

Post by neostek » 17 Jul 2019, 10:50

Dear all,

I have a (maybe) strange question that I would like to ask.

Consider that a mobile robot (e.g., a simple unicycle) has a sensor (e.g., a 360deg laser) that is mounted on the top of the robot. This sensor has a limited range (e.g., a circle around the sensor). I would like that, when the robot moves, the "trace" of the sensor is highlighted in V-REP.
In other words, I would like that the sensors show to me which part of the space it has seen.

Imagine, for example, a coverage task, where the robot has to explore all the space in a room. I would like to visualize, in real-time, which parts it had already explored and covered.

A simple strategy is that I write a script that, each X seconds, draws the shape of the sensor view (e.g., a simple circle) but I'm afraid that the simulation will be slow as the number of these shapes increase. I would like to know if there is another way (I tried with the proximity sensor with no success) for doing it.

Thank you in advance. For any question, do not hesitate to contact me. Best,
Neostek

fferri
Posts: 395
Joined: 09 Sep 2013, 19:28

Re: Visualize sensor trace

Post by fferri » 18 Jul 2019, 14:21

You can use sim.addDrawingObject to create a drawing object, which can then moved like any other object.

Use sim.addDrawingObjectItem to add items to the created drawing object.

neostek
Posts: 21
Joined: 15 Feb 2013, 10:26

Re: Visualize sensor trace

Post by neostek » 18 Jul 2019, 15:10

Thank you for your reply.

Yes, I can definitely do that. But, I have to perform a simulation that lasts minutes. Then, drawing objects, lets say every 2 seconds, forces V-REP to create a relevant number of objects that will slow down the simulation.

For this reason, I was asking if there is a way to graphically design the trace that the sensor does (note: the trace as the union of the sensor scans, not the path because I have to represent what the sensor has seen during the simulation).

If you have any idea, it is really welcome. Best,
Neostek

fferri
Posts: 395
Joined: 09 Sep 2013, 19:28

Re: Visualize sensor trace

Post by fferri » 18 Jul 2019, 15:23

Why do you say it will slow down the simulation? Did you try it?

Drawing object it is only graphical, has no impact on the simulation speed. And since a single object can draw as many items as you want, probably you can solve your problem with just one object.

coppelia
Site Admin
Posts: 7324
Joined: 14 Dec 2012, 00:25

Re: Visualize sensor trace

Post by coppelia » 18 Jul 2019, 15:32

You can also use a ocTree object to represent the seen areas. You will have to create a shape that represents the vision sensor boundaries. Then, each time you want to add a trace, add that shape to the ocTree via sim.insertObjectIntoOctree.

Or even simpler: each time you want to add a trace, copy and paste that shape into the scene. After having added about 100 of those shapes, you can group them with sim.groupShapes, so that display speed does not suffer too much.

But using drawing objects is probably the simplest of all solutions.

Cheers

neostek
Posts: 21
Joined: 15 Feb 2013, 10:26

Re: Visualize sensor trace

Post by neostek » 18 Jul 2019, 18:25

Thank you for your reply

@fferri: once it arrives at 200 created objects, it seems that the simulation starts to slow down a bit. Moreover, the since the created shapes has a level of trasparency (otherwise they cover the robot from a top-view), two overlapping shapes gave to me different variation of the same color and I would like to avoid it. If you suggestions for it, they are really welcome. Thanks!

@coppelia: I will take a look for the ocTree. Thanks!

coppelia
Site Admin
Posts: 7324
Joined: 14 Dec 2012, 00:25

Re: Visualize sensor trace

Post by coppelia » 19 Jul 2019, 07:48

If you need some kind of transparency, you might also use a point cloud instead of the ocTree, this way you will be able to see the points and through them too. The approach is almost identical as with the ocTree.

Cheers

Post Reply