Btw the solution includes rclpy.spin_once(self) in callback that results in action server not being able to receive a second request. It was discussed in one of other threads here, that this is a bad solution.
I suggest amending course with some basics about multi threading and callback groups, otherwise a newbie like me will be really struggling to pass quiz.
The ROS2 Basics in 5 Days Galactic (Python) course does not introduce Multi threading and callback groups. You can find those topics on Advanced ROS2 course. But, as a person who has completed that course (myself), I am 100% sure that you can complete that course without using Multi Threading and Callback Groups. I have solved all the quizzes (topics, services, and actions) without using multi threading and callback group concepts.
Even I used rclpy.spin_once(self) in my program and it worked well. So I am sure that you can make it work.
The problem with this method is that it works only once - looks like if you call spin_once inside of callback, then the main spin stops working. If you call action again, it wont work without restarting action server - when I faced that behavior I decided it’s a wrong solution. In this thread for same issue you recommended to use callback groups yourself - too bad i found your post only after I found that myself in official documentation. https://get-help.robotigniteacademy.com/t/cant-retrieve-data-from-odom-topic/20315/5
So, I do not think there is a correct way of solving this quiz without callback groups.
I’d like to hear from admins, because my distance calculations are correct (checked manually) and i use same formula as provided solution. Still gradebot says it is wrong - I want to understand why.
Yes, you are correct and I agree with you. Also, I do remember that post (the link you referenced).
Your observation that the server works only once and needs to be restarted is also correct.
But I was just telling this as a way to finish the quiz, from the scope of the chapters. This course has not introduced the Callback group concepts, so with that in mind I told you that this will work.
But yes, again, I agree with you (and from my own actual words from the post) that using callback groups will be a better way to do this. And yes, it is also the “correct” way!
I am glad you have found out my post !
Summary: If you want to finish the quiz, you can do it using the spin_once function and still be fine. But the correct way is to use callback groups.
Also, I totally agree with your comments w.r.t adding multithreading and callback groups to the course. This is something that we will do for sure in the close future. We already had several discussions about this, but it needs to be planned thoroughly before being implemented.
I am also stuck at the end of lection 5. I can publisch the cmd_vel and do the goal_handles’s in the execution loop and but I can not read with a second callback the odometry values. I also tried with lambda call but that is only executed after the callback for the ros2 action.
Any additional hint how to actually implement the execution callback with proper readings of a topic without wired multi thread or callback groups ?
I don’t think you need to complicate your program by using lambda functions.
Just define odometry callback the usual way.
Inside the execute callback use rclpy.spin_once(self). Here self keyword is very important as you will/should define your action server as a Nodelet (inherited from Node class).
Yes, you can. With the spin_once function mentioned above.