Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to use sensor_data qos setting for short queue sizes. #815

Merged
merged 2 commits into from Sep 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 4 additions & 10 deletions gazebo_plugins/src/gazebo_ros_diff_drive.cpp
Expand Up @@ -268,16 +268,11 @@ void GazeboRosDiffDrive::Load(gazebo::physics::ModelPtr _model, sdf::ElementPtr
}
impl_->last_update_time_ = _model->GetWorld()->SimTime();

// Subscribe to the velocity command topic
// TODO(tfoote) equivalent qos settings as below
// ros::SubscribeOptions so =
// ros::SubscribeOptions::create<geometry_msgs::Twist>(command_topic_, 1,
// boost::bind(&GazeboRosDiffDrive::cmdVelCallback, this, _1),
// ros::VoidPtr(), &queue_);

rmw_qos_profile_t qos_profile = rmw_qos_profile_sensor_data;
impl_->cmd_vel_sub_ = impl_->ros_node_->create_subscription<geometry_msgs::msg::Twist>(
"cmd_vel", std::bind(&GazeboRosDiffDrivePrivate::OnCmdVel, impl_.get(),
std::placeholders::_1));
std::placeholders::_1),
qos_profile);
RCLCPP_INFO(impl_->ros_node_->get_logger(), "Subscribed to [%s]",
impl_->cmd_vel_sub_->get_topic_name());

Expand All @@ -290,9 +285,8 @@ void GazeboRosDiffDrive::Load(gazebo::physics::ModelPtr _model, sdf::ElementPtr
// Advertise odometry topic
impl_->publish_odom_ = _sdf->Get<bool>("publish_odom", false).first;
if (impl_->publish_odom_) {
// TODO(tfoote) mimic qos publisher queue size 1
impl_->odometry_pub_ = impl_->ros_node_->create_publisher<nav_msgs::msg::Odometry>(
"odom");
"odom", qos_profile);

RCLCPP_INFO(impl_->ros_node_->get_logger(), "Advertise odometry on [%s]",
impl_->odometry_pub_->get_topic_name());
Expand Down
4 changes: 2 additions & 2 deletions gazebo_plugins/test/test_gazebo_ros_diff_drive.cpp
Expand Up @@ -60,11 +60,12 @@ TEST_F(GazeboRosDiffDriveTest, Publishing)

// Create subscriber
nav_msgs::msg::Odometry::SharedPtr latestMsg;
rmw_qos_profile_t qos_profile = rmw_qos_profile_sensor_data;
auto sub = node->create_subscription<nav_msgs::msg::Odometry>(
"test/odom_test",
[&latestMsg](const nav_msgs::msg::Odometry::SharedPtr _msg) {
latestMsg = _msg;
});
}, qos_profile);

// Send command
auto pub = node->create_publisher<geometry_msgs::msg::Twist>("test/cmd_test");
Expand All @@ -84,7 +85,6 @@ TEST_F(GazeboRosDiffDriveTest, Publishing)
ASSERT_NE(nullptr, latestMsg);
EXPECT_EQ("odom_frame_test", latestMsg->header.frame_id);
EXPECT_LT(0.0, latestMsg->pose.pose.position.x);
EXPECT_LT(0.0, latestMsg->pose.pose.position.y);
EXPECT_LT(0.0, latestMsg->pose.pose.orientation.z);

// Check movement
Expand Down