Where is the laserShape in the ray sensor defined?
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
I want to achieve this with Gazebo sensor.
Asked by kumpakri on 2018-11-05 07:28:26 UTC
Answers
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.
Asked by nkoenig on 2018-11-05 15:52:35 UTC
Comments
@nkoenig Description added to the question.
Asked by kumpakri on 2018-11-06 03:43:57 UTC
@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!
Asked by adi3 on 2019-08-09 06:19:32 UTC
Comments
No progress was made.
Asked by kumpakri on 2019-08-13 07:57:13 UTC
Comments