这些指南展示了如何将现有的ROS 1软件包转换为ROS 2。如果您是ROS 1和ROS 2之间移植的新手,建议您按顺序阅读指南。^1^
ROS | ROS2 |
---|---|
ros::Time::now() | rclcpp::Clock().now() |
ros::Duration() | rclcpp::Duration::from_seconds() |
ros::Duration(0.250).sleep() | rclcpp::sleep_for(std::chrono::seconds(1)) |
rclcpp::sleep_for(std::chrono::milliseconds(250)) | |
ros::spin() | |
ros::ok() | rclcpp::ok() |
ros::Publisher | rclcpp::Publisher<std_msgs::msg::String>::SharedPtr |
ros::Subscriber | rclcpp::Subscriber<std_msgs::msg::String>::SharedPtr |
ros::ServiceClient | rclcpp::Client<my_interfaces::srv::AddTwoInts>::SharedPtr |
ros::ServiceServer | rclcpp::Service<my_interfaces::srv::AddTwoInts>::SharedPtr |
ROS_INFO/WARN/ERROR("print some msg") | RCLCPP_INFO/WARN/ERROR(rclcpp::get_logger(LOGGER_NAME), "print some msg") |
#include "ros/ros.h" | #include "rclcpp/rclcpp.hpp" |