ENPM702 Introductory Robot Programming L12 ROS (Part 4) Fall 2024 PDF
Document Details
Uploaded by WonderfulSuprematism
University of Maryland
2024
ENPM702
Z. Kootbally
Tags
Summary
This document is lecture notes for ENPM702, Introductory Robot Programming, L12: ROS (Part 4), Fall 2024 at the University of Maryland. It covers topics like ROS, Quality of Service (QoS), Rotations, Proportional Controllers, and Executors.
Full Transcript
ENPM702: Introductory Robot Programming L12: ROS (Part 4) version 1.0 Lecturer: Z. Kootbally School: University of Maryland Semester/Year: Fall/2024 Table of Contents Ɓ Reach a Goal Ɓ Prerequisites...
ENPM702: Introductory Robot Programming L12: ROS (Part 4) version 1.0 Lecturer: Z. Kootbally School: University of Maryland Semester/Year: Fall/2024 Table of Contents Ɓ Reach a Goal Ɓ Prerequisites Ɓ Demonstration Ɓ Learning Objectives Ɓ Executors Ɓ Threads Ɓ Quality of Service (QoS) Ɓ SingleThreadedExecutor Ɓ QoS Settings Ɓ Demonstration Ɓ Example Ɓ MultiThreadedExecutor Ɓ Demonstration Ɓ Callback Groups Ɓ Rotations Ɓ Demonstration Ɓ Euler Angles Ɓ Interfaces Ɓ Rounding Errors in Rotations Ɓ Custom Interfaces Ɓ Representation Ɓ Interface Packages Ɓ Examples Ɓ Message Interface for u BotStatus.msg Ɓ Demonstration Ɓ Demonstration Ɓ Proportional Controller Ɓ Next Class version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 1 47 Changelog v1.0: Original version. version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 2 47 Convention IJ Syntax. U General Important notes. u file Ì folder link Ŧ ı command Best practices. ƍ example δ terminology question Ͻ U ROS Warning. n node t topic : m message Summary. Ď Tips. version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 3 47 Prerequisites U Prerequisites Clone the specified GitHub repository into your ROS 2 workspace by following these steps: Compress the Ì src folder in your workspace into a ZIP file. Delete the Ì src folder. Recreate the Ì src folder. Clone the repository into the newly created Ì src folder. https://github.com/zeidk/enpm702_fall2024_ros Remove the Ì build, Ì log, and Ì install folders. version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 4 47 Learning Objectives U Learning Objectives By the end of this lecture, you will be able to: Quality of Service: Understand how QoS can be used to create different settings for publishers and subscribers. Rotations: Learn about quaternions and how to compute a quaternion through use cases. Proportional Controller: What a proportional controller is and how we can use it to move the robot to reach a goal. Executor: The different types of executors and the use of callback groups for multi threading. Interface: Create a custom interface. version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 5 47 Quality of Service (QoS) Part I ͽ Quality of Service (QoS) version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 6 47 Quality of Service (QoS) δ Quality of Service (QoS) Qualitty of Service (QoS) in ROS 2 is an adaptation of the DDS QoS policies that control the way data is exchanged between entities in a distributed system. QoS in ROS 2 ensures that the communication layer can be tuned to handle different types of data communication and guarantee that the data is transferred reliably and efficiently. ó Resources ROS 2 Quality of Service Policies Quality of Service Settings ROS QoS - Deadline, Liveliness, and Lifespan version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 7 47 Quality of Service (QoS) Ī QoS Settings U QoS Settings in ROS 2 Reliability controls whether the data should be delivered reliably (i.e., all data is guaranteed to arrive, potentially with retries) or best-effort (i.e., data may be lost). Durability determines whether data should be stored until it is delivered to all subscribers, even if they are not currently active (transient local) or not (volatile). History controls how the middleware manages the storage of old messages, which in turn influences how new subscribers can access them and what happens when messages are not processed quickly enough. keep last tells the middleware to only store up to a certain number of most recent messages. New messages that arrive will displace the oldest messages once this cache is full. keep all instructs the middleware to store all messages until they are delivered to all subscribers. This means that even if a subscriber is slow or temporarily offline, it can still receive old messages that were published before it caught up. Deadline is used to ensure that data is published or updated within a certain period of time. This QoS setting is particularly important for real-time systems where timely delivery of messages is crucial for system performance and correctness. Liveliness determines the mechanism and interval to assert the liveliness of a participant. version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 8 47 Quality of Service (QoS) Ī Example ƍ Example QoS settings in ROS 2 can be used with publishers, subscribers, services, and actions to define the behavior of data communication between nodes in various scenarios. // QoS for the publisher rclcpp::QoS pub_qos(10); // keep last 10 messages pub_qos.reliable(); // reliability pub_qos.transient_local(); // durability // initialize the publisher publisher_ = this->create_publisher("qos_demo", pub_qos); // QoS for the subscriber rclcpp::QoS sub_qos(10); // keep last 10 messages sub_qos.reliable(); // reliability sub_qos.transient_local(); // durability // initialize the subscriber subscriber_ = this->create_subscription( "qos_demo", sub_qos, std::bind(&QoSDemoSubscriberNode::receive_int, this, std::placeholders::_1)); version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 9 47 Quality of Service (QoS) Ī Demonstration Ð Demonstration ı colcon build --packages-select qos_publisher_demo qos_subscriber_demo ı ros2 run qos_publisher_demo qos_publisher_demo ı ros2 run qos_subscriber_demo qos_subscriber_demo version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 10 47 Rotations Part II ͽ Rotations version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 11 47 Rotations Ī Euler Angles δ Euler Angles Euler angles describe the rotation of an object by specifying three angles, typically represented as rotations about three distinct axes. Roll (Rotation about the X-axis) – Imagine a plane doing a barrel roll. Pitch (Rotation about the Y-axis) – A good example is an airplane ascending or descending. Yaw (Rotation about the Z-axis) – In an airplane, this would be a change in direction to the left or right. version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 12 47 Rotations δ Quaternions A quaternion is a mathematical constructs used to represent rotations in 3D space. 𝑞 = 𝑤 + 𝑥𝑖 + 𝑦𝑗 + 𝑧𝑘𝑞 = 𝑤 + 𝑥𝑖 + 𝑦𝑗 + 𝑧𝑘 where 𝑤, 𝑥, 𝑦, 𝑧 are real numbers. Why Quaternions in Robotics? Efficient for 3D rotations, avoids gimbal lock (unlike Euler angles). Used in pose estimation, orientation tracking, and control algorithms. U Key Messages using Quaternions m geometry_msgs::msg::Quaternion m geometry_msgs::msg::Pose (uses quaternion for orientation) m tf2::Quaternion version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 13 47 Rotations Ī Rounding Errors in Rotations U Rotation Matrices A rotation matrix is a 3𝑥3 orthogonal matrix with determinant 1, representing a rotation in 3D space. U Quaternions When repeatedly applying rotation matrices Quaternions represent rotations using four (e.g., multiplying them together in a components and do not suffer from sequence), numerical precision issues can orthogonality or determinant constraints. lead to: When normalized, quaternions inherently Loss of orthogonality: The matrix maintain their “unit” property, preserving might no longer remain strictly the rotation without introducing distortions. orthogonal. Rounding errors can still occur in Drift: Over time, the matrix may no quaternion arithmetic, but the errors are longer have a determinant of 1, leading typically smaller and easier to correct (e.g., to skewing or scaling effects. by renormalizing the quaternion). Accumulated error: Each multiplication introduces small numerical inaccuracies due to floating-point arithmetic. version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 14 47 Rotations Ī Representation U Representation There are 2 representations of quaternion: Hamilton: q = [𝑞𝑤 , 𝑞𝑥 , 𝑞𝑦 , 𝑞𝑧 ] JPL (Jet Propulsion Laboratory): q = [𝑞𝑥 , 𝑞𝑦 , 𝑞𝑧 , 𝑞𝑤 ] While ROS itself does not enforce the use of a specific quaternion representation, both Hamilton and JPL representations are commonly used within the ROS community, with Hamilton being more prevalent in general robotics applications and JPL being more common in aerospace-related projects. version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 15 47 Rotations Ī Examples ƍ Example 𝜋 Compute the quaternion of a rotation of 𝛼 = 2 about the 𝑋 axis. The unit vector for the axis of rotation 𝑋 is (1, 0, 0). Formula for converting an axis-angle representation of a rotation to a quaternion: q = cos( 𝛼2 ) + sin( 𝛼2 )(𝑥𝑖 + 𝑦𝑗 + 𝑧𝑘) Normalization of the Axis Vector – The magnitude of the axis vector (1, 0, 0) is √12 + 02 + 02 = √1. Therefore, the normalized vector is ( 1 , 0 , 0 ) √1 √1 √1 Computing Quaternion Components 𝑞𝑤 is given by cos( 𝛼2 ) = cos( 𝜋4 ) = 0.707 The 𝑞𝑥 , 𝑞𝑦 , and 𝑞𝑧 components are calculated by multiplying the sine of half the rotation angle (sin( 𝜋4 )) by each of the normalized axis components. 𝑞𝑥 = sin( 𝜋4 ) × 1 = 0.707 √1 𝑞𝑦 = sin( 𝜋4 ) × 0 = 0.0 √1 𝑞𝑧 = sin( 𝜋4 ) × = 0.0 0 √1 q = [𝑞𝑤 , 𝑞𝑥 , 𝑞𝑦 , 𝑞𝑧 ]=[0.707, 0.707, 0.0, 0.0] version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 16 47 Rotations Ī Examples ƍ Example 𝜋 Compute the quaternion of a rotation of 2 about the axis with the unit vector (1, 0, 1). Formula for converting an axis-angle representation of a rotation to a quaternion: q = cos( 𝛼2 ) + sin( 𝛼2 )(𝑥𝑖 + 𝑦𝑗 + 𝑧𝑘) Normalization of the Axis Vector – The magnitude of the axis vector (1, 0, 1) is √12 + 02 + 12 = √2. Therefore, the normalized vector is ( 1 , 0 , 1 ) √2 √2 √2 Computing Quaternion Components 𝑞𝑤 is given by cos( 𝛼2 ) = cos( 𝜋4 ) = 0.707 The 𝑞𝑥 , 𝑞𝑦 , and 𝑞𝑧 components are calculated by multiplying the sine of half the rotation angle (sin( 𝜋4 )) by each of the normalized axis components. 𝑞𝑥 = sin( 𝜋4 ) × 1 = √2 2 × 1 =0.5 √2 √2 𝑞𝑦 = sin( 𝜋4 ) × 0 = 0.0 √2 𝑞𝑧 = sin( 𝜋4 ) × = √2 1 2 × 1 =0.5 √2 √2 q = [𝑞𝑤 , 𝑞𝑥 , 𝑞𝑦 , 𝑞𝑧 ]=[0.707, 0.5, 0.0, 0.5] version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 17 47 Rotations Ī Demonstration Ð Demonstration ı colcon build --packages-select quaternion_demo quaternion_demo ı ros2 run quaternion_demo quaternion_demo version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 18 47 Proportional Controller Part III ͽ Proportional Controller version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 19 47 Proportional Controller δ Proportional Controller A proportional controller (P-controller) is a feedback control mechanism used to reduce the error between a desired setpoint and a system’s current state. The controller applies a correction proportional to the magnitude of the error, which is the difference between the desired state (e.g., position, velocity) and the actual state of the system. Mathematically: 𝑢(𝑡) = 𝐾𝑝 × 𝑒(𝑡), where: 𝑢(𝑡): Control signal or actuation command. 𝐾𝑝 : Proportional gain, a constant that determines the response intensity. A higher 𝐾𝑝 results in faster system response but can cause overshoot or instability. A lower 𝐾𝑝 results in slower response and less oscillation but may lead to steady-state error (residual error that the controller cannot eliminate). 𝑒(𝑡): Error at time 𝑡, defined as 𝑒(𝑡) = setpoint − current state version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 20 47 Proportional Controller U Proportional Controller setpoint error signal current state controller plant/process version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 21 47 Proportional Controller Ī Reach a Goal ƍ Example Task an automated vehicle to stay in the middle of the lane. setpoint error signal current state controller setpoint: Desired lateral offset (typically 0). current state: Actual lateral offset from the setpoint error controller signal current state middle of the lane (measured using sensors like cameras). error: Lateral offset error. setpoint error signal current state signal: Compute an angular velocity controller correction proportional to the error. 𝜔 = 𝐾𝑝 × (desired offset - current offset) setpoint error signal current state controller version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 22 47 Proportional Controller Ī Reach a Goal é ToDo Use a proportional control to reach a goal (𝑥𝑔 ,𝑦𝑔 ,𝜃𝑔 ) Define Positional and Angular Goals Specify the target position (𝑥𝑔 ,𝑦𝑔 ) and target orientation (𝜃𝑔 ) in the 2D plane. Define tolerances for both position and orientation to determine when the goal is achieved. Calculate Errors Distance error: 𝑒𝑑 = √(𝑥𝑔 − 𝑥)2 + (𝑦𝑔 − 𝑦)2 Angular error to goal position: 𝑒𝜃 = 𝜃𝑑 − 𝜃, where 𝜃𝑑 = atan2(𝑦𝑔 − 𝑦, 𝑥𝑔 − 𝑥) Final orientation error: 𝑒𝑓 𝑖𝑛𝑎𝑙 = 𝜃𝑔 − 𝜃 Two-phase control strategy Phase 1: Navigate to goal position: Use a proportional controller to minimize both distance error (𝑒𝑑 ) and angular error (𝑒𝜃 ) The robot moves toward the goal while maintaining its orientation towards the target. Phase 2: Align to goal orientation Once the robot is within the positional tolerance (𝑒𝑑 < 𝜖), stop linear motion. Use a proportional controller to minimize the final orientation error (𝑒𝑓 𝑖𝑛𝑎𝑙 ). Stop the robot: The robot stops moving when: 𝑒𝑑 < 𝜖: Positional error is within tolerance. |𝑒𝑓 𝑖𝑛𝑎𝑙 | < 𝜖𝜃 : Orientation error is within tolerance. version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 23 47 Proportional Controller Ī Reach a Goal Ī Angle Normalization U Angle Normalization Normalization ensures that all angles and angular errors are within the range [−𝜋, 𝜋]. This is critical for two main reasons: Handling wraparound properly: Without normalization, the difference between angles close to 𝜋 and −𝜋 can result in large and incorrect values. Example: Desired angle: −𝜋 + 0.1 Current angle: 𝜋 − 0.1 Error without normalization: 𝑒𝜃 = (−𝜋 + 0.1) − (𝜋 − 0.1) = −2𝜋 + 0.2 ≈ −6.08 rad (incorrect) Error with normalization: 𝑒𝜃 = 0.2 rad (correct) Avoiding unstable control: Large errors caused by improper handling of wraparound can lead to overcorrection and instability in the control loop. Wrap to [−2𝜋, 2𝜋]: Add or subtract multiples of 2𝜋 until the angle is within this range. Wrap to [−𝜋, 𝜋]: ⎧ angle − 2𝜋 if angle > 𝜋 normalized_angle = angle + 2𝜋 if angle < −𝜋 ⎨ ⎩ angle otherwise version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 24 47 Proportional Controller Ī Reach a Goal Ī Demonstration Ð Demonstration ı colcon build --packages-select p_controller_demo ı ros2 run p_controller_demo p_controller_demo version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 25 47 Executors Part IV ͽ Executors version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 26 47 Executors δ Executors An executor is a core component responsible for managing the execution of callbacks associated with nodes. Executors abstract away the complexity of managing threads and can operate with a single thread (SingleThreadedExecutor) or multiple threads (MultiThreadedExecutor). Executors can manage the callbacks of one or more nodes at the same time. version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 27 47 Executors Ī Threads δ Threads A thread is one of the smallest units of processing that can be scheduled and executed, often within a larger program or process. version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 28 47 Executors Ī SingleThreadedExecutor U SingleThreadedExecutor Processes callbacks one at a time in a single thread. Suitable for applications with low computational demands or when deterministic execution is required. rclcpp::executors::SingleThreadedExecutor executor; executor.add_node(node); executor.spin(); rclcpp::spin(node) uses a SingleThreadedExecutor internally by default. When you call rclcpp::spin(node), the following happens: A SingleThreadedExecutor is created implicitly. The specified node is added to this executor. The executor begins spinning to process the callbacks associated with the node. version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 29 47 Executors Ī SingleThreadedExecutor ƍ Example auto node1 = std::make_shared("node1"); auto node2 = std::make_shared("node2"); // Create a SingleThreadedExecutor rclcpp::executors::SingleThreadedExecutor executor; // Add both nodes to the executor executor.add_node(node1); executor.add_node(node2); // Spin the executor executor.spin(); Ͻ Disadvantages Blocking: If one node has a long-running or blocking callback, it can delay callbacks from other nodes. Performance: Single-threaded execution can become a bottleneck if there are many nodes or high callback rates. version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 30 47 Executors Ī SingleThreadedExecutor Ī Demonstration Ð Demonstration ı colcon build --packages-select singlethreadedexecutor_demo ı ros2 run singlethreadedexecutor_demo singlethreadedexecutor_demo é ToDo Include delays to see how the code is affected. version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 31 47 Executors Ī MultiThreadedExecutor δ MultiThreadedExecutor A MultiThreadedExecutor is an executor that processes callbacks using a thread pool. This allows multiple callbacks to run simultaneously, enabling greater throughput and better utilization of multi-core processors. Features: Enables parallel execution of callbacks. Ideal for high-performance applications where callback rates are high. Works with multiple nodes and multiple callback types (subscriptions, timers, services, etc.). version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 32 47 Executors Ī MultiThreadedExecutor ƍ Example auto node1 = std::make_shared("node1"); auto node2 = std::make_shared("node2"); // Create a MultiThreadedExecutor rclcpp::executors::MultiThreadedExecutor executor; // Add nodes to the executor executor.add_node(node1); executor.add_node(node2); // Spin the executor executor.spin(); version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 33 47 Executors Ī MultiThreadedExecutor Ī Callback Groups δ Callback Groups A callback group is a mechanism to control which callbacks can execute concurrently. It allows developers to group callbacks into categories and specify whether they should execute concurrently or sequentially. U Mutually Exclusive Only one callback from the group can execute at a time. Used for callbacks that share resources or need to avoid concurrency issues. U Reentrant Allows multiple callbacks in the group to execute simultaneously. Used for independent callbacks that do not share resources. version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 34 47 Executors Ī MultiThreadedExecutor Ī Callback Groups version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 35 47 Executors Ī MultiThreadedExecutor Ī Callback Groups ƍ Example Create callback groups: // Callback groups have to be class attributes mutually_exclusive_group_ = ↪ this->create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive); reentrant_group_ = this->create_callback_group(rclcpp::CallbackGroupType::Reentrant); Adding a subscriber to a callback group: // Create a subscription in the mutually exclusive group auto options = rclcpp::SubscriptionOptions(); options.callback_group = mutually_exclusive_group_; subscription_ = this->create_subscription("topic", 10, ↪ std::bind(&MyNode::callback1, this, std::placeholders::_1), options); Adding a timer to a callback group: // Create a timer in the reentrant group timer_ = this->create_wall_timer( std::chrono::seconds(1), std::bind(&MyNode::callback2, this), reentrant_group_); version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 36 47 Executors Ī MultiThreadedExecutor Ī Demonstration Ð Demonstration ı colcon build --packages-select multithreadedexecutor_demo ı ros2 run demo_nodes_cpp talker ı ros2 run multithreadedexecutor_demo multithreadedexecutor_demo é ToDo Include delays and set different callback groups to timers and to the subscriber. version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 37 47 Interfaces Part V ͽ Interfaces version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 38 47 Interfaces U Interfaces ROS applications typically communicate through interfaces, which fall into one of three categories: Message for topic publishers and subscribers. Service for service client/server communication. Action for action client/server communication. Interfaces are described with the interface definition language (IDL), which is a descriptive language used to define data types and interfaces in a way that is independent of the programming language or operating system/processor platform. version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 39 47 Interfaces Ī Custom Interfaces U Custom Interfaces Although ROS provides many interfaces from various packages, there are instances where the required interfaces are unavailable, necessitating the creation of custom interfaces. Scenario: Publish the status of the TurtleBot, including its pose (𝑥, 𝑦, 𝜃), velocities (𝑣, 𝛾 ), and model (burger, waffle, or waffle_pi). This scenario requires a custom message interface because none of the available ROS messages include all of these fields. Write the custom message interface in u BotStatus.msg version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 40 47 Interfaces Ī Custom Interfaces Ī Interface Packages U Interface Packages Custom interfaces are created in C++ packages with the suffix _msgs or _interfaces. These packages do not include any programming code. é ToDo Create ˜ enpm702_msgs with dependencies on ˜ example_interfaces and ˜ geometry_msgs Delete Ì src and Ì include Create the folder Ì msg and within it, create the file u BotStatus.msg version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 41 47 Interfaces Ī Custom Interfaces Ī Message Interface for u BotStatus.msg é ToDo Write the structure for u BotStatus.msg # CONSTANTS # The field model will take only one of the three following values uint8 BURGER=1 uint8 WAFFLE=2 uint8 WAFFLE_PI=3 uint8 model # BURGER, WAFFLE, or WAFFLE_PI geometry_msgs/Pose2D pose # x, y, theta float64 velocities # [linear.x, angular.z] version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 42 47 Interfaces Ī Custom Interfaces Ī Message Interface for u BotStatus.msg é ToDo Set up the package files for interfaces. Build a msg file: Edit u package.xml rosidl_default_generators rosidl_default_runtime rosidl_interface_packages Build a msg file: Edit u CMakeLists.txt find_package(example_msgs REQUIRED) find_package(geometry_msgs REQUIRED) find_package(rosidl_default_generators REQUIRED) set(msg_files "msg/BotStatus.msg" # Add other msg files here ) rosidl_generate_interfaces(${PROJECT_NAME} ${msg_files} DEPENDENCIES example_interfaces geometry_msgs) ament_export_dependencies(rosidl_default_runtime) ament_package() version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 43 47 Interfaces Ī Custom Interfaces Ī Message Interface for u BotStatus.msg é ToDo Generate message interface in target languages (C++ and Python). ı colcon build --packages-select enpm702_msgs ı source install∕setup. ı ros2 interface show enpm702_msgs∕msg∕BotStatus Eventually, check that u robot_status.hpp is created in the Ì install directory. version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 44 47 Interfaces Ī Custom Interfaces Ī Message Interface for u BotStatus.msg é ToDo Use the custom message interface. Any package that uses interfaces from ˜ enpm702_msgs must declare a dependency on ˜ enpm702_msgs. Check u package.xml and u CMakeLists.txt Include the proper header to use the custom message interface. #include Initialize a publisher with the custom message type: bot_status_publisher_ = this->create_publisher ("interface_demo", 10); Build and publish the message: bot_status_msg_.model = bot_model_; bot_status_msg_.velocities.at(0) = linear_x_; bot_status_msg_.velocities.at(1) = angular_z_; bot_status_msg_.pose.x = position_x_; bot_status_msg_.pose.y = position_y_; bot_status_msg_.pose.theta = theta_; bot_status_publisher_->publish(bot_status_msg_); version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 45 47 Interfaces Ī Custom Interfaces Ī Demonstration Ð Demonstration colcon build --packages-select interface_demo ı os2 launch turtlebot3_gazebo empty_world.launch.py ı ı ros2 run turtlebot3_teleop teleop_keyboard Move the robot. ı ros2 run interface_demo interface_demo é ToDo Check published data with ı ros2 topic echo interface_demo version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 46 47 Next Class U Next Lecture Lecture 13: ROS (Part 5) Last quiz. version 1.0 ENPM702 | L12: Robot Operating System (Part 4) 47 47