Quiz Dispute - Unit 3 Understanding ROS2 Topics

Where do I file a dispute for the Quiz Result?

at the end it reported:
[22:17:28][assess] Not publishing to /cmd_vel. Stop and take a moment to check these points:

  • Did you create a publisher correctly in your source code?
  • Is the logic correct, such that the publisher gets to publish?
  • Did you name your node correctly? It should be topics_quiz_node
  • Your robot should start moving within 5 seconds of launching your package.
  • Run ros2 topic echo /cmd_vel and confirm that you have some data there.

Running ros2 topic echo /cmd_vel I confirmed that I was publishing data there.

I am also publishing from my node named topics_quiz_node

user:~$ ros2 topic info /cmd_vel -v
Type: geometry_msgs/msg/Twist

Publisher count: 1

Node name: topics_quiz_node
Node namespace: /
Topic type: geometry_msgs/msg/Twist
Endpoint type: PUBLISHER
GID: 01.0f.54.33.10.77.c5.3c.01.00.00.00.00.00.11.03.00.00.00.00.00.00.00.00
QoS profile:
Reliability: RELIABLE
History (Depth): UNKNOWN
Durability: VOLATILE
Lifespan: Infinite
Deadline: Infinite
Liveliness: AUTOMATIC
Liveliness lease duration: Infinite

Subscription count: 1

Node name: turtlebot3_diff_drive
Node namespace: /
Topic type: geometry_msgs/msg/Twist
Endpoint type: SUBSCRIPTION
GID: 01.0f.6a.68.2c.01.8a.66.01.00.00.00.00.00.66.04.00.00.00.00.00.00.00.00
QoS profile:
Reliability: RELIABLE
History (Depth): UNKNOWN
Durability: VOLATILE
Lifespan: Infinite
Deadline: Infinite
Liveliness: AUTOMATIC
Liveliness lease duration: Infinite

Can anybody help me?

Thank you very much,

Miguel.

Looking into it. Be right back.

The problem is that your code crashes at some point (within 20 seconds), when the gradebot launches it.

Please fix the part causing that problem and try again. Here is the log:

ros2 launch topics_quiz topics_quiz.launch.py
[INFO] [launch]: All log files can be found below /home/user/.ros/log/2024-08-05-03-17-07-851273-effe8d5746b8-499
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [topics_quiz_node-1]: process started with pid [501]
[topics_quiz_node-1] [INFO] [1722827829.030904853] [topics_quiz_node]: timer: "0"
[topics_quiz_node-1] Traceback (most recent call last):
[topics_quiz_node-1]   File "/home/user/ros2_ws/install/topics_quiz/lib/topics_quiz/topics_quiz_node", line 33, in <module>
[topics_quiz_node-1]     sys.exit(load_entry_point('topics-quiz==0.0.0', 'console_scripts', 'topics_quiz_node')())
[topics_quiz_node-1]   File "/home/user/ros2_ws/install/topics_quiz/lib/python3.10/site-packages/topics_quiz/topics_quiz_node.py", line 128, in main
[topics_quiz_node-1]     rclpy.spin(quiz)
[topics_quiz_node-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/__init__.py", line 222, in spin
[topics_quiz_node-1]     executor.spin_once()
[topics_quiz_node-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 712, in spin_once
[topics_quiz_node-1]     raise handler.exception()
[topics_quiz_node-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/task.py", line 239, in __call__
[topics_quiz_node-1]     self._handler.send(None)
[topics_quiz_node-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 418, in handler
[topics_quiz_node-1]     await call_coroutine(entity, arg)
[topics_quiz_node-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 332, in _execute_timer
[topics_quiz_node-1]     await await_or_execute(tmr.callback)
[topics_quiz_node-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 107, in await_or_execute
[topics_quiz_node-1]     return callback(*args)
[topics_quiz_node-1]   File "/home/user/ros2_ws/install/topics_quiz/lib/python3.10/site-packages/topics_quiz/topics_quiz_node.py", line 52, in timer_callback
[topics_quiz_node-1]     postion_x = self.odom_msg.pose.pose.position.x
[topics_quiz_node-1] AttributeError: 'int' object has no attribute 'pose'

By the way, thanks for reporting the problem early (at the very first trial)!

I don’t see any errors in the code. It runs smooth in the simulator as shown in the attached screen recorded (sorry when I tried to upload the file to the discussion I received “Sorry, new users can not upload attachments.”) Let me know other ways to share the program running and publishing topics. Thanks, Miguel.

You may not “see” any errors in the code, even if it’s there!

Your code might not be initializing variables properly or not considering edge cases for certain variables. This will sometimes lead to random errors like this.

For instance, this part of the error reveals something brittle about your code:

[topics_quiz_node-1]     postion_x = self.odom_msg.pose.pose.position.x
[topics_quiz_node-1] AttributeError: 'int' object has no attribute 'pose'
  • It is likely that self.odom_msg was initialized as integer, or an integer was assigned to it at some point.
    • It should be initialized as an empty Odom message instead, and also assigned an Odom message.

Please take a look at this, adjust your code, and submit again.

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