It’s clearly using it when I run it, so maybe it’s a naming error?
Here’s the part in the init section
self.subscriber2 = self.create_subscription(
Odometry,
'/odom',
self.odom_callback,
QoSProfile(depth=10, reliability=ReliabilityPolicy.BEST_EFFORT))
Then here’s the callback section:
# scrubbed
and here’s where I use it:
# scrubbed
This is probably because you did not name the node as specified. Did you check out the things Gradebot asked you to? Here is what it said:
To check the name of the node subscribed to /odom
,
# launch your quiz in one terminal
ros2 launch topics_quiz topics_quiz.launch.py
And
# Check the subscriptions to `/odom` in another terminal
ros2 topic info /odom -v
If needed, you can share the output here.
You can refer to a similar case here:
This was the output - but I’m not sure what it’s supposed to look like? Help?
Subscription count: 1
Node name: topics_quiz_node
Node namespace: /
Topic type: nav_msgs/msg/Odometry
Endpoint type: SUBSCRIPTION
GID: 01.0f.54.de.51.05.e0.05.01.00.00.00.00.00.13.04.00.00.00.00.00.00.00.00
QoS profile:
Reliability: BEST_EFFORT
History (Depth): UNKNOWN
Durability: VOLATILE
Lifespan: Infinite
Deadline: Infinite
Liveliness: AUTOMATIC
Liveliness lease duration: Infinite
One thing I noticed is that the reliabilities didn’t match. I’ve fixed this now.
Also, I’m assuming that the program is supposed to shut itself down (rather than me typing Ctrl-C). My code matches the examples:
rclpy.spin(topics_quiz)
# Explicity destroy the node
topics_quiz.destroy_node()
# shutdown the ROS communication
rclpy.shutdown()
Any idea why my code might not be stopping?
This output looks good enough for this test. The reliability bit would be another improvement.
Let me check the Gradebot logs and get back.
The error was
Unknown topic '/odom'
That’s strange, because that means it did not find the topic. It could be a temporary error in the simulation, so please just try again. I have restored your “lost” trial due to this.
system
Closed
September 4, 2024, 10:49am
8
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.