We have got this instruction in the subject:
- obstacle closer than 1 meter in front of the robot), the robot will move forward.
- If the laser reading in front of the robot is lower than 1 meter (there is an obstacle closer than 1 meter in front of the robot), the robot will turn left.
- If the laser reading at the right side of the robot is lower than 1 meter (there is an obstacle closer than 1 meter at the right side of the robot), the robot will turn left.
- If the laser reading at the left side of the robot is lower than 1 meter (there is an obstacle closer than 1 meter at the left side of the robot), the robot will turn right.
But in the solution we have:
//If the distance to an obstacle at the left side of the robot is smaller than 0.3 meters, the robot will turn right
if (msg->ranges[719] < 0.3)
{
linX = 0.0;
angZ = -0.2;
}
//If the distance to an obstacle at the right side of the robot is smaller than 0.3 meters, the robot will turn left
if (msg->ranges[0] < 0.3)
{
linX = 0.0;
angZ = 0.2;
}
1 meter and 0.3 meters. Please fix it. The behavior in the gif is different than in the subject.