Skip to content

AttributeError in dqn_gazebo: 'Goal_Response' missing pose_x + Robot not moving during DQN Agent #85

@rahul-r-joshua

Description

@rahul-r-joshua

I am using Ubuntu 22.04 with ROS 2 Humble and TurtleBot3 DQN simulation.

I executed the following commands in separate terminals:
ros2 launch turtlebot3_gazebo turtlebot3_dqn_stage1.launch.py
ros2 run turtlebot3_dqn dqn_gazebo 1
ros2 run turtlebot3_dqn dqn_environment
ros2 run turtlebot3_dqn dqn_test 1 600

But as soon as I run dqn_gazebo, I get this error:
ros2 run turtlebot3_dqn dqn_gazebo 1
[INFO] [1761665617.691816928] [gazebo_interface]: Loaded entity from: /home/ajay/turtlebot3_ws/install/turtlebot3_gazebo/share/turtlebot3_gazebo/models/turtlebot3_dqn_world/goal_box/model.sdf
Delete Goal
Spawn Goal at (-0.5, -1.0, 0.0)
Traceback (most recent call last):
File "/home/ajay/turtlebot3_ws/install/turtlebot3_dqn/lib/turtlebot3_dqn/dqn_gazebo", line 33, in
sys.exit(load_entry_point('turtlebot3-dqn', 'console_scripts', 'dqn_gazebo')())
File "/home/ajay/turtlebot3_ws/build/turtlebot3_dqn/turtlebot3_dqn/dqn_gazebo.py", line 271, in main
rclpy.spin_once(gazebo_interface, timeout_sec=0.1)
File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/init.py", line 208, in spin_once
executor.spin_once(timeout_sec=timeout_sec)
File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 751, in spin_once
self._spin_once_impl(timeout_sec)
File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 748, in _spin_once_impl
raise handler.exception()
File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/task.py", line 254, in call
self._handler.send(None)
File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 447, in handler
await call_coroutine(entity, arg)
File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 401, in _execute_service
response = await await_or_execute(srv.callback, request, srv.srv_type.Response())
File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 107, in await_or_execute
return callback(*args)
File "/home/ajay/turtlebot3_ws/build/turtlebot3_dqn/turtlebot3_dqn/dqn_gazebo.py", line 216, in task_succeed_callback
response.pose_x = self.entity_pose_x
AttributeError: 'Goal_Response' object has no attribute 'pose_x'
[ros2run]: Process exited with failure 1
It seems the service response message no longer contains pose_x, pose_y, and pose_z, which causes the node to crash.

To continue testing, I used the following command instead:
ros2 run turtlebot3_dqn dqn_agent 1 600

This time, there is no node crash, but:

  1. The robot does not move
  2. No velocity commands on topic /cmd_vel
  3. Episode/reset does not start correctly
    So the DQN Agent does not begin training or exploring.

Gazebo launches correctly
Task success service crashes
Robot stays still during DQN Agent execution

Please update the DQN example for ROS2 Humble to fix:
Incorrect service response fields in dqn_gazebo.py
Movement issue in DQN Agent (likely due to failed goal reset callback)
Any patch or updated branch would be very helpful.
Thank you!!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions