Podcast
Questions and Answers
What is the primary purpose of a publisher in ROS?
What is the primary purpose of a publisher in ROS?
Which message type is specifically mentioned for controlling robot actions in ROS 2?
Which message type is specifically mentioned for controlling robot actions in ROS 2?
What do subscribers implement in ROS 2 according to the learning objectives?
What do subscribers implement in ROS 2 according to the learning objectives?
What are the two main components related to data transmission in ROS discussed in the learning objectives?
What are the two main components related to data transmission in ROS discussed in the learning objectives?
Signup and view all the answers
Which of the following best describes messages in the context of ROS?
Which of the following best describes messages in the context of ROS?
Signup and view all the answers
What is essential to publish at regular intervals in a publisher implementation?
What is essential to publish at regular intervals in a publisher implementation?
Signup and view all the answers
What should be the focus when writing a subscriber in ROS 2?
What should be the focus when writing a subscriber in ROS 2?
Signup and view all the answers
What knowledge is expected to be gained regarding topics in this lecture?
What knowledge is expected to be gained regarding topics in this lecture?
Signup and view all the answers
What characterizes a message in the context of publishers?
What characterizes a message in the context of publishers?
Signup and view all the answers
Which of the following statements about publisher-subscriber communication is true?
Which of the following statements about publisher-subscriber communication is true?
Signup and view all the answers
What does Quality of Service (QoS) refer to in this messaging context?
What does Quality of Service (QoS) refer to in this messaging context?
Signup and view all the answers
Which command would you use to see all interfaces installed on your system?
Which command would you use to see all interfaces installed on your system?
Signup and view all the answers
What is the first step in using a message in your program?
What is the first step in using a message in your program?
Signup and view all the answers
Which of the following is NOT a valid command for interfacing with message structures?
Which of the following is NOT a valid command for interfacing with message structures?
Signup and view all the answers
What is the appropriate way to publish a message using the example_interfaces package?
What is the appropriate way to publish a message using the example_interfaces package?
Signup and view all the answers
Which of the following best describes the role of a publisher in this messaging system?
Which of the following best describes the role of a publisher in this messaging system?
Signup and view all the answers
What does the command ros2 topic list
accomplish?
What does the command ros2 topic list
accomplish?
Signup and view all the answers
Which message type is used for publishing velocity commands on the /cmd_vel
topic?
Which message type is used for publishing velocity commands on the /cmd_vel
topic?
Signup and view all the answers
What is the purpose of the ros2 topic echo
command?
What is the purpose of the ros2 topic echo
command?
Signup and view all the answers
What should be included in the bot_publisher.hpp
file?
What should be included in the bot_publisher.hpp
file?
Signup and view all the answers
What is the significance of the parameter 10
when initializing the velocity publisher in ROS2?
What is the significance of the parameter 10
when initializing the velocity publisher in ROS2?
Signup and view all the answers
Which command would you use to find out the type of messages published on a specific topic?
Which command would you use to find out the type of messages published on a specific topic?
Signup and view all the answers
What does the command ros2 topic hz
measure?
What does the command ros2 topic hz
measure?
Signup and view all the answers
In the context of ROS2, what is a topic primarily used for?
In the context of ROS2, what is a topic primarily used for?
Signup and view all the answers
What types of messages are being subscribed to by the BotSubscriber class?
What types of messages are being subscribed to by the BotSubscriber class?
Signup and view all the answers
In which file is the BotSubscriber class defined?
In which file is the BotSubscriber class defined?
Signup and view all the answers
What is the purpose of the 'std::bind' function in the subscriber initialization?
What is the purpose of the 'std::bind' function in the subscriber initialization?
Signup and view all the answers
How is the main node created in the main.cpp file?
How is the main node created in the main.cpp file?
Signup and view all the answers
What is the purpose of the callback methods odom_callback and scan_callback?
What is the purpose of the callback methods odom_callback and scan_callback?
Signup and view all the answers
What is specified in the CMakeLists.txt for building the executable?
What is specified in the CMakeLists.txt for building the executable?
Signup and view all the answers
What function is called to start the ROS node after initializing?
What function is called to start the ROS node after initializing?
Signup and view all the answers
What are the two main types of messages being processed in BotSubscriber's callbacks?
What are the two main types of messages being processed in BotSubscriber's callbacks?
Signup and view all the answers
What is the main objective when modifying the BotPublisher class?
What is the main objective when modifying the BotPublisher class?
Signup and view all the answers
What does a subscriber require to function correctly?
What does a subscriber require to function correctly?
Signup and view all the answers
Which messages should the created subscribers handle?
Which messages should the created subscribers handle?
Signup and view all the answers
What function must be used to publish at regular intervals?
What function must be used to publish at regular intervals?
Signup and view all the answers
Which statement about Quality of Service (QoS) for subscribers is accurate?
Which statement about Quality of Service (QoS) for subscribers is accurate?
Signup and view all the answers
What files are part of the bot_subscriber package?
What files are part of the bot_subscriber package?
Signup and view all the answers
What is the purpose of the callback function in the subscriber?
What is the purpose of the callback function in the subscriber?
Signup and view all the answers
Which command is used to run the bot_pub executable?
Which command is used to run the bot_pub executable?
Signup and view all the answers
What is the purpose of the line 'velocity_publisher_ = this->create_publisher("cmd_vel", 10);'?
What is the purpose of the line 'velocity_publisher_ = this->create_publisher("cmd_vel", 10);'?
Signup and view all the answers
What does the angular.z parameter in the Twist message control?
What does the angular.z parameter in the Twist message control?
Signup and view all the answers
In which file should the include directories be specified for the publisher node?
In which file should the include directories be specified for the publisher node?
Signup and view all the answers
What happens if the message queue exceeds a size of 10 in the publisher?
What happens if the message queue exceeds a size of 10 in the publisher?
Signup and view all the answers
Which part of the bot node is responsible for initializing the ROS 2 environment?
Which part of the bot node is responsible for initializing the ROS 2 environment?
Signup and view all the answers
What is the role of the line 'ament_target_dependencies(bot_pub rclcpp geometry_msgs)' in CMakeLists.txt?
What is the role of the line 'ament_target_dependencies(bot_pub rclcpp geometry_msgs)' in CMakeLists.txt?
Signup and view all the answers
Which method would be used to publish the velocity message to the 'cmd_vel' topic?
Which method would be used to publish the velocity message to the 'cmd_vel' topic?
Signup and view all the answers
What does the statement 'auto message = geometry_msgs::msg::Twist();' do?
What does the statement 'auto message = geometry_msgs::msg::Twist();' do?
Signup and view all the answers
Study Notes
Course Information
- Course: ENPM702: Introductory Robot Programming
- Lecture: L11: ROS (Part 3)
- Version: 1.1
- Lecturer: Z. Kootbally
- School: University of Maryland
- Semester/Year: Fall 2024
- Date: 2024/11/13
Table of Contents
-
Learning Objectives
- Messages and Topics: Gain knowledge about message structures and how data is transmitted through topics
- Publishers: Learn to write and implement a publisher in ROS 2 to control robot actions, including publishing specific data types like
geometry_msgs/msg/Twist
- Subscribers: Learn to write and implement a subscriber in ROS 2 to retrieve LIDAR scans and the robot position
-
Publishers
- Topics: Publishers send messages on topics
- Messages: Data sent by publishers are structured as messages
- Asynchronous: Publishers can keep generating and sending messages without waiting for subscribers
- Quality of Service (QoS): QoS settings determine how communication is handled (reliability, durability, etc.)
-
Messages
- Interface Definition Language (IDL)
- Messages are structured data types for communication between nodes over topics, services, or actions.
- Interface Definition Language (IDL)
-
Commands
- Listing all interfaces:
ros2 interface list
- Showing interface structure:
ros2 interface show <message type>
(e.g.,geometry_msgs/msg/Twist
) - Showing interfaces from a package:
ros2 interface package <package name>
(e.g.,geometry_msgs
)
- Listing all interfaces:
-
Usage
- Understanding message structure:
ros2 interface show example_interfaces/msg/String
- Including the message:
#include <example_interfaces/msg/String.hpp>
- Instantiate a message object:
auto message = example_interfaces::msg::String();
- Fill out message fields:
message.data = "Hello";
- Publish the message:
publisher_->publish(message);
- Understanding message structure:
-
Topics
- Structure:
- Name: Unique identifier (e.g.,
/camera/image_raw
) - Message Type: Specific message type (e.g.,
sensor_msgs/msg/Image
) defines the structure of data
- Name: Unique identifier (e.g.,
- Structure:
-
Commands
- Listing active topics:
ros2 topic list
- Showing data from a topic:
ros2 topic echo <topic name>
- Getting topic information:
ros2 topic info <topic name>
- Getting a topic's type:
ros2 topic type <topic name>
- Getting average publishing rate:
ros2 topic hz <topic name>
- Listing active topics:
-
Write a Simple Publisher
- Objective: Publish a single
Twist
message (linear.x = 1.0 and angular.z = 0.5) tocmd_vel
- Package:
bot_publisher
- Files:
bot_publisher.cpp
andbot_publisher.hpp
- Class:
BotPublisher
- Executable:
bot_pub
- Topic:
/cmd_vel
- Message:
geometry_msgs/msg/Twist
- Package:
- Objective: Publish a single
-
Writing the code (simple publisher):
bot_publisher.hpp
- Creating a publisher attribute:
rclcpp::Publisher<geometry_msgs::msg::Twist>::SharedPtr velocity_publisher_;
- Initializing the publisher:
velocity_publisher_ = this->create_publisher<geometry_msgs::msg::Twist>("cmd_vel", 10);
- Building the message and publishing it:
auto message = geometry_msgs::msg::Twist(); message.linear.x = 1.0; message.angular.z = 0.5; velocity_publisher_->publish(message);
- Creating a publisher attribute:
-
Initializing velocity publisher
-
Other instructions and details on the topic
-
Write the
main
function inmain.cpp
-
Edit
CMakeLists.txt
-
Compile and execute
-
colcon build --packages-select bot_publisher
-
ros2 run bot_publisher bot_pub
-
Introspect
-
ros2 topic echo cmd_vel
-
rqt_graph
-
Publish at Regular Intervals
- Objective: Publish a
Twist
message to/cmd_vel
every 300 ms
- Objective: Publish a
-
Write Subscribers
- Objective: Create two subscribers
- Retrieve turtlebot's position from
/odom
(nav_msgs/msg/Odometry
) and receive LiDAR data from/scan
(sensor_msgs/msg/LaserScan
). - Package:
bot_subscriber
- Files:
bot_subscriber.cpp
andbot_subscriber.hpp
- Class:
BotSubscriber
- Executable:
bot_sub
- Topics:
/odom
&/scan
- Message:
nav_msgs/msg/Odometry
&sensor_msgs/msg/LaserScan
- Retrieve turtlebot's position from
- Objective: Create two subscribers
-
Code for creating and initializing the subscribers
-
Code for main function in
main.cpp
andCMakeLists.txt
-
Exercise
- Objective: Integrate publisher and subscribers into
bot_controller
package to move robot forward at 0.1 m/s and stop if obstacle detected within 0.2 m.
- Objective: Integrate publisher and subscribers into
Next Lecture
- Lecture 12: ROS (Part 4)
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
This quiz covers the concepts of message structures, publishers, and subscribers within the Robot Operating System (ROS) for robot programming. You will learn how to implement these elements in ROS 2 and understand the role of Quality of Service settings in communication. Test your understanding of how data is transmitted through topics and how robot actions are controlled.