Distance calculation in actions_quiz

Hello,

When autocorrecting my actions_quiz exercise I received the following feedback:

image

From the first attempt, I am subscribed to the odometry topic and I obtain position.x and position.y values. I used these values to calculate distance (in 2D) as usual by:
sqrt((x1 - x0)^2 + (y1 - y0)^2), where x1 and x0 are final and initial x coordinates respectively, and y1 and y0 the same but for y coordinate.

I calculate the “travelled distance” in every topic callback, and I add it up to the total distance previously calculated (distance += sqrt(…) in every callback).

I have checked it with the teleop command, and the value I obtained as feedback and total distance outputs makes sense, having in mind that each square travelled is 1 meter long.

I am making some assumptions though, which are:

  • Distance is reset to 0.0 every time the action server is called by the client.
  • If the robot is moving with action server on, but no action client is doing a request, this distance remains to 0.0. So travelled distance will only increase when a client is “listening”.

Am I missing something? I have been trying several things for a while and I am a bit out of ideas now. Thank you in advance for any help. I can share more details if necessary.

Best!

One of possible bugs can be related to the first iteration, when x0/y0 should be set for the first time (distance += … shouldn’t be called).
(You can log distance delta on each step. It should be ± the same for same speed and 0 for not moving robot)

Hello vipera!

Thank you for your quick response. For that first iteration, I have establish a flag to initialize x0 and y0 to the initial position when the client is executed. I have checked the distance with different speeds (including 0) and the results are coherent every time. Actually, my calculation is done independently of the speed, since I am using pose.pose.position.x and y values, from Odometry. I calculate iteratively the delta distance and I add it up as well. All this is done for every topic_callback, so the delta is added to the overall distance every topic_callback. Sorry if I repeat myself too much… I do not know how to explain it better.

In any case, using a 0.55 m/s speed with the teleop_twist_keyboard I can see how the distance increases about 0.55 meters per each feedback output, which is every second, which is also coherent.

Maybe I have to include Z coordinate in the distance formula? I do not think so, but who knows…

I tried something else, a minor change in the distance reset to 0.0 for every new call of the action service, to double ensure that the value is reset. I changed nothing but a minor calculation of the distance, and now the autocorrector outputs an error indicating that it is not receiving feedback from the server when runnig the command:
ros2 action send_goal -f /distance_as actions_quiz_msg/action/Distance seconds:\ 30
which is not what it is happening:

And also the topic:
image

I do not know if anyone from support can check my code or my enviroment to see if everything is fine from my side. If possible, it would be great. Sorry for any inconvenience. I have only 2 attempts left :sweat_smile:.
Thank you!

Hello @navarrognp ,

This requires some further investigation as it seems there’s some kind of error in the grading code. We will be checking this in the following days and let you know as soon as we solve the issue. In the meantime, I suggest you keep advancing with other units/courses.

Best,

1 Like

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

Hello @navarrognp ,

It seems the issue has been resolved. Could you try to submit your Quiz again? And let me know what score you get this time.

Best,

1 Like

Doing some more testing, it seems there are still some problems. Very strange issue… I’ll keep investigating.

1 Like