Actions Quiz Gradebot: Action /distance_as is not publishing feedback

Hello, I ran quiz code 2 times just to be sure but both times I failed on this step:

Action /distance_as is not publishing feedback. Didn’t you know that feedback is a gift? Kindly look into this matter:

  • Are you publishing feedback in your action server node?
  • Call your action with ros2 action send_goal -f and check that you get feedback from the server.

When I run it from the command line all is well.

Client Output

$ ros2 launch actions_quiz actions_quiz_client.launch.py

[INFO] [launch]: All log files can be found below /home/user/.ros/log/2024-12-26-02-22-08-273351-2_xterm-6910
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [action_client_node-1]: process started with pid [6911]
[action_client_node-1] [INFO] [1735179730.372461166] [my_action_client]: Sending goal, seconds: 20
[action_client_node-1] [INFO] [1735179730.373047815] [my_action_client]: Goal accepted by server, waiting for result
[action_client_node-1] [INFO] [1735179730.373311804] [my_action_client]: Feedback, current_dist: 0.100000
[action_client_node-1] [INFO] [1735179731.373421830] [my_action_client]: Feedback, current_dist: 0.200000
[action_client_node-1] [INFO] [1735179732.373703683] [my_action_client]: Feedback, current_dist: 0.300000

[action_client_node-1] [INFO] [1735179744.373384052] [my_action_client]: Feedback, current_dist: 1.500000
[action_client_node-1] [INFO] [1735179745.373387633] [my_action_client]: Feedback, current_dist: 1.600000
[action_client_node-1] [INFO] [1735179746.373430207] [my_action_client]: Feedback, current_dist: 1.700000
[action_client_node-1] [INFO] [1735179747.373382900] [my_action_client]: Feedback, current_dist: 1.800000
[action_client_node-1] [INFO] [1735179748.373387615] [my_action_client]: Feedback, current_dist: 1.900000
[action_client_node-1] [INFO] [1735179749.373768370] [my_action_client]: Feedback, current_dist: 2.000000
[action_client_node-1] [ERROR] [1735179750.373436076] [my_action_client]: Result, status: true, total_dist: 2.000000
[action_client_node-1] [INFO] [1735179750.373490773] [my_action_client]: Goal finished with status: SUCCEEDED
[INFO] [action_client_node-1]: process has finished cleanly [pid 6911]

Server Output

$ ros2 launch actions_quiz actions_quiz_server.launch.py

[INFO] [launch]: All log files can be found below /home/user/.ros/log/2024-12-26-02-21-57-695175-2_xterm-6874
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [action_server_node-1]: process started with pid [6875]
[action_server_node-1] [INFO] [1735179730.372793511] [my_action_server]: Received goal request with seconds 20
[action_server_node-1] [INFO] [1735179730.373052432] [my_action_server]: Executing goal
[action_server_node-1] [INFO] [1735179730.373252521] [my_action_server]: Publish feedback
[action_server_node-1] [INFO] [1735179731.373350198] [my_action_server]: Publish feedback
[action_server_node-1] [INFO] [1735179732.373651075] [my_action_server]: Publish feedback
[action_server_node-1] [INFO] [1735179733.373361532] [my_action_server]: Publish feedback

[action_server_node-1] [INFO] [1735179744.373330728] [my_action_server]: Publish feedback
[action_server_node-1] [INFO] [1735179745.373326171] [my_action_server]: Publish feedback
[action_server_node-1] [INFO] [1735179746.373359821] [my_action_server]: Publish feedback
[action_server_node-1] [INFO] [1735179747.373326694] [my_action_server]: Publish feedback
[action_server_node-1] [INFO] [1735179748.373326101] [my_action_server]: Publish feedback
[action_server_node-1] [INFO] [1735179749.373333882] [my_action_server]: Publish feedback
[action_server_node-1] [INFO] [1735179750.373415607] [my_action_server]: Goal succeeded

Published data to topic /total_distance

$ ros2 topic echo /total_distance

data: 0.10000000149011612
data: 0.20000000298023224
data: 0.30000001192092896
data: 0.4000000059604645
data: 0.5
data: 0.6000000238418579
data: 0.7000000476837158

data: 1.700000286102295
data: 1.8000003099441528
data: 1.9000003337860107
data: 2.000000238418579

Thank you for your help.
Ivan

from actions_quiz_msg.action import Distance

class ActionQuizServer(Node):
    def __init__(self):
        ...
        # Action server to accept goals
        self.action_server = ActionServer(
            self, Distance, '/distance_as', self.execute_callback)
        ...

    async def execute_callback(self, goal_handle):
         """Handle the incoming goal request."""
        ...
        self.feedback_msg1 = Distance.Feedback()
        self.gh = goal_handle
        ...
        # Send navigation goal
        result = await self.send_navigation_goal(x, y, yaw, goal_handle)
        ...

    async def send_navigation_goal(self, x, y, yaw, goal_handle):
        """Send a navigation goal using the NavigateToPose action."""
        ...
        # Send the goal
        send_goal_future = self.nav_to_pose_client.send_goal_async(goal_msg,
            feedback_callback=self.feedback_callback)
        nav_goal_handle = await send_goal_future
        ...
        get_result_future = nav_goal_handle.get_result_async()
        nav_result = await get_result_future
        ...

    def odom_callback(self, msg):
        ...
        self.distance_from_goal = math.sqrt((self.X - self.robot_x)**2 + (self.Y - 
            self.robot_y)**2)
        self.feedback_msg1.distance_left = self.distance_from_goal

    def feedback_callback(self, feedback_msg):
        self.feedback_msg1.distance_left = self.distance_from_goal
        self.gh.publish_feedback(self.feedback_msg1)


I don't think this is the correct way to do it but I got through the quiz using this method. In the execute_callback I added the 2 variables self.feedback_msg1 = Distance.Feedback() and self.gh = goal_handle so I could update them in the odom_callback and then publish the variables in feedback_callback. feedback_callback is suppose to be giving feedback for send_navigation_goal, the nav2_msgs.action, but I didn't publish the other actions feedback.

I didn’t mean to send a long 1 line text.

I don’t think this is the correct way to do it but I got through the quiz using this method. In the execute_callback I added the 2 variables self.feedback_msg1 = Distance.Feedback() and self.gh = goal_handle so I could update them in the odom_callback and then publish the variables in feedback_callback. feedback_callback is suppose to be giving feedback for send_navigation_goal, the nav2_msgs.action, but I didn’t publish the other actions feedback.

Your code crashes at the point of calling the action. It seems your action server is not responding on time (within 90 seconds), or you have some logic to stop it after a while (but it should run forever).

The expected setup is:

  1. Start the action server. Note that your action server must keep running.
  2. Send a goal to the action server. It should respond within 90 seconds.

Try the same commands below and see if you can reproduce the error the grader ran into.

# In one terminal
ros2 launch actions_quiz actions_quiz_server.launch.py

# In another terminal
timeout 90s ros2 action send_goal -f /distance_as actions_quiz_msg/action/Distance '{seconds: 10}'

This is the error gradebot ran into while calling the action server:

Traceback (most recent call last):
  File "/opt/ros/humble/bin/ros2", line 33, in <module>
    sys.exit(load_entry_point('ros2cli==0.18.3', 'console_scripts', 'ros2')())
  File "/opt/ros/humble/lib/python3.10/site-packages/ros2cli/cli.py", line 89, in main
    rc = extension.main(parser=parser, args=args)
  File "/opt/ros/humble/lib/python3.10/site-packages/ros2action/command/action.py", line 37, in main
    return extension.main(args=args)
  File "/opt/ros/humble/lib/python3.10/site-packages/ros2action/verb/send_goal.py", line 54, in main
    return send_goal(args.action_name, args.action_type, args.goal, feedback_callback)
  File "/opt/ros/humble/lib/python3.10/site-packages/ros2action/verb/send_goal.py", line 109, in send_goal
    rclpy.spin_until_future_complete(node, goal_future)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/__init__.py", line 248, in spin_until_future_complete
    executor.spin_until_future_complete(future, timeout_sec)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 288, in spin_until_future_complete
    self.spin_once_until_future_complete(future, timeout_sec)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 715, in spin_once_until_future_complete
    self.spin_once(timeout_sec)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 704, in spin_once
    handler, entity, node = self.wait_for_ready_callbacks(timeout_sec=timeout_sec)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 690, in wait_for_ready_callbacks
    return next(self._cb_iter)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 592, in _wait_for_ready_callbacks
    raise ExternalShutdownException()
rclpy.executors.ExternalShutdownException

Thank you for your response. I did run the code as you suggested and all went well. Here are the screenshots:

If everything went fine, I suggest you try again, making sure to kill any program running in any of the terminals before pressing the submit button.

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