ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
In the meantime I've found the solution on the net in different pieces: It publishes the sensor data immediately as it arrived to the host.
Please find the relevant code chunks below:
// Initializing ROS.
rmw_qos_profile_t custom_qos_profile = rmw_qos_profile_default;
custom_qos_profile.depth = 7;
rclcpp::WallRate loop_rate(100);
rclcpp::init(argc, argv);
// Creating a node
auto node = rclcpp::Node::make_shared("IMU_node");
// Creating a publisher
auto imu_publisher = node->create_publisher<sensor_msgs::msg::Imu>("Imu_topic", custom_qos_profile.depth);
// Creating hte message
auto imu_msg = std::make_shared<sensor_msgs::msg::Imu>();
while( rclcpp::ok() )
{
// Listen to the sensor
std::string buf = imu.SerialReadLine();
// Interpret buf and derive relevant values and store in 'value';
.
.
.
// Fill the IMU msg
imu_msg->orientation.x = value;
imu_publisher->publish(*imu_msg);
rclcpp::spin_some(node);
}
2 | No.2 Revision |
In the meantime I've found the solution on the net in different pieces: It publishes the sensor data immediately as it arrived to the host.
Please find the relevant code chunks below:
// Initializing ROS.
rmw_qos_profile_t custom_qos_profile = rmw_qos_profile_default;
custom_qos_profile.depth = 7;
rclcpp::WallRate loop_rate(100);
rclcpp::init(argc, argv);
// Creating a node
auto node = rclcpp::Node::make_shared("IMU_node");
// Creating a publisher
auto imu_publisher = node->create_publisher<sensor_msgs::msg::Imu>("Imu_topic", custom_qos_profile.depth);
// Creating hte message
auto imu_msg = std::make_shared<sensor_msgs::msg::Imu>();
while( rclcpp::ok() )
{
// Listen to the sensor
std::string buf = imu.SerialReadLine();
// Interpret buf and derive relevant values and store in 'value';
.
.
.
// Fill the IMU msg
imu_msg->orientation.x = value;
imu_publisher->publish(*imu_msg);
rclcpp::spin_some(node);
}
3 | No.3 Revision |
In the meantime I've found the solution on the net in different pieces: It publishes the sensor data immediately as it arrived to the host.
Please find the relevant code chunks below:
// Initializing ROS.
rmw_qos_profile_t custom_qos_profile = rmw_qos_profile_default;
custom_qos_profile.depth = 7;
rclcpp::WallRate loop_rate(100);
rclcpp::init(argc, argv);
// Creating a node
auto node = rclcpp::Node::make_shared("IMU_node");
// Creating a publisher
auto imu_publisher = node->create_publisher<sensor_msgs::msg::Imu>("Imu_topic", custom_qos_profile.depth);
// Creating hte the message
auto imu_msg = std::make_shared<sensor_msgs::msg::Imu>();
while( rclcpp::ok() )
{
// Listen to the sensor
std::string buf = imu.SerialReadLine();
// Interpret buf and derive relevant values and store in 'value';
.
.
.
// Fill the IMU msg
imu_msg->orientation.x = value;
imu_publisher->publish(*imu_msg);
rclcpp::spin_some(node);
}