How does ray sensor work?

asked 2019-03-01 03:43:52 -0500

kumpakri gravatar image

I am trying to understand the ray sensor.

When I look into the RaySensor.cc file, I can see the RaySensor::UpdateImpl function with this piece of code

    // range readings of 4 corners
    r1 = this->LaserShape()->GetRange(j1);
    r2 = this->LaserShape()->GetRange(j2);
    r3 = this->LaserShape()->GetRange(j3);
    r4 = this->LaserShape()->GetRange(j4);
    range = (1-vb)*((1 - hb) * r1 + hb * r2)
        + vb *((1 - hb) * r3 + hb * r4);

I don't know what the '4 corners' are or why it needs to know the ranges of the corner or what it means. But it seems that this LaserShape()->GetRange() returns a range.

LaserShape() is a variable of RaySensorPrivate object of a type physics::MultiRayShapePtr.

The MultiRayShape::GetRange(unsigned int _index) function returns

this->GetMinRange() + this->rays[_index]->GetLength();

rays is a vector defined in MultiRayShape.hh

protected: std::vector<RayShapePtr> rays;

in the RayShape.cc file

double RayShape::GetLength() const
{
  return this->contactLen;
}

And this much is said about contactLen in the RayShape.hh

  // Contact information; this is filled out during collision
  // detection.
  /// \brief Length of the ray.
  protected: double contactLen;

Now how and when is the contactLen being filled? How can I find out?

edit retag flag offensive close merge delete