Home | Tutorials | Wiki | Issues
Ask Your Question
0

Where is the laserShape in the ray sensor defined?

asked 2018-11-05 06:28:26 -0500

kumpakri gravatar image

updated 2018-11-06 02:43:25 -0500

I have been reading through source code of the ray sensor in order to understand how it works.

The RaySensor object has a physics::MultiRayShapePtr laserShape variable which it loads with a following instruction:

this->dataPtr->laserShape =
    boost::dynamic_pointer_cast<physics::MultiRayShape>(
        this->dataPtr->laserCollision->GetShape());

And it uses this variable to access information about it max angle, range, count of samples (which I don't understand what means) and loads distances to obstacles.

example of instruction to load a distance to obstacle:

 this->LaserShape()->GetRange(j1)

The physics::CollisionPtr laserCollision is obtained by following lines:

  this->dataPtr->laserCollision = physicsEngine->CreateCollision("multiray",
      this->ParentName());

So it seems the physicsEngine->CreateCollision() has some idea about what the ray looks like and provides the information to the sensor class. Is that correct? Where is the shape of the ray defined? And is there any way how to access it and change it?


EDIT

I would like to implement physically precise ultrasonic sensor. An ultrasonic sensor emits rays in 3D space, not just in one plane. The shape of the field is kind of cone, but the range differs for each angle.

here is an example of radiation specification of a ultrasonic sensor image description

I want to achieve this with Gazebo sensor.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2018-11-05 14:52:35 -0500

nkoenig gravatar image

updated 2018-11-06 10:30:46 -0500

Each physics engine implements a ray shape. For example, here is ODE's ray shape.

You really only need to worry about the main definition of ray shape .

If you are using a RaySensor, then most of the modifications you can do to the ray shape are exposed through SDF. Here is the SDF ray sensor spec.

Can you describe what you're trying to do?

Edit

Thanks for updating your question. Your project sounds like a great idea. Here is some background. A RayShape is a single line that with a start and end point. The primary purpose of a RayShape is to detect collisions. RayShapes are used primarily by CPU-based LiDAR sensors in Gazebo.

The "shape" of a RayShape can only be a straight line, see the RayShape API. A MultiRayShape is basically a collection of RayShapes, see the MultiRayShape API. You could construct a cone multiray shape using MultiRayShape::SetRay.

The MultiRayShape was intended to be used for LiDAR sensors. For exampl, its Init function creates the individual rays based on SDF data.

However, you should be able to use MultiRayShape in your own Sonar Sensor by using MultiRayShape's API.

edit flag offensive delete link more

Comments

@nkoenig Description added to the question.

kumpakri gravatar imagekumpakri ( 2018-11-06 02:43:57 -0500 )edit
0

answered 2019-08-09 06:28:23 -0500

adi3 gravatar image

@kumpakri Did you find a way to do this? I can confirm that the suggestion by @nkoenig works. I've been able to change the _physics_ part of the sensor ray via MultiRayShap::SetRay.

However, the _rendering_ of the beam in gzclient remains unchanged. If I place an object in front of this newly set (still invisible) ray, I can get readings from it. I haven't found a way to update the laser visual to match the altered ray position.

If you've made progress on this, do put in a note here. Otherwise, I'll open a new issue for this. Thanks!

edit flag offensive delete link more

Comments

No progress was made.

kumpakri gravatar imagekumpakri ( 2019-08-13 07:57:13 -0500 )edit
Login/Signup to Answer

Question Tools

2 followers

Stats

Asked: 2018-11-05 06:28:26 -0500

Seen: 671 times

Last updated: Aug 09