Better solution of the micro project?

The solution is a bit strange.

The following code just gets distance 0 …Why do you add them?

  // Get initial position
  float x_0 = rosbot.get_position(1);
  float y_0 = rosbot.get_position(2);
  float x_1 = x_0;
  float y_1 = y_0;
  float dist = calc_distance(x_0, y_0, x_1, y_1);

To get out of the coffee shop, the final step slightly adjust the direction otherwise the robot will hit something on the way towards the exit because the turning is not 90 degrees and therefore the final trajectory is not straight. However, it is not practical (because all the parameters and the final turn and moving forward are added according to many experiments).

Is there any other way to achieve that?

  while (dist < 8.00) {
    // Update current position
    x_1 = rosbot.get_position(1);
    y_1 = rosbot.get_position(2);
    dist = calc_distance(x_0, y_0, x_1, y_1);
    ROS_INFO_STREAM("Distance travelled: " << dist);
    // Keep moving
    rosbot.move_forward(1);
  }
  rosbot.turn("clockwise", 3);
  rosbot.move_forward(5);
  ROS_INFO_STREAM("Success!!!");

Let me capture this for review by the person in charge. We’ll let you know once we can review it.

In the meantime, you can continue with the course.

1 Like

Thanks a lot! :blush:
I have already finished that course.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.