Skip to content

Commit

Permalink
Replaced numbers with SystemDefaultsQos() (#2271)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shobuj-Paul authored Jul 31, 2023
1 parent 830ceda commit 5506dd5
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ bool LocalPlannerComponent::initialize()

// Initialize global trajectory listener
global_solution_subscriber_ = node_->create_subscription<moveit_msgs::msg::MotionPlanResponse>(
config_.global_solution_topic, 1, [this](const moveit_msgs::msg::MotionPlanResponse::ConstSharedPtr& msg) {
config_.global_solution_topic, rclcpp::SystemDefaultsQoS(),
[this](const moveit_msgs::msg::MotionPlanResponse::ConstSharedPtr& msg) {
// Add received trajectory to internal reference trajectory
robot_trajectory::RobotTrajectory new_trajectory(planning_scene_monitor_->getRobotModel(), msg->group_name);
moveit::core::RobotState start_state(planning_scene_monitor_->getRobotModel());
Expand Down
2 changes: 1 addition & 1 deletion moveit_ros/moveit_servo/test/pose_tracking_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ TEST_F(PoseTrackingFixture, OutgoingMsgTest)
return;
};
auto traj_sub = node_->create_subscription<trajectory_msgs::msg::JointTrajectory>(
"/panda_arm_controller/joint_trajectory", 1, traj_callback);
"/panda_arm_controller/joint_trajectory", rclcpp::SystemDefaultsQoS(), traj_callback);

geometry_msgs::msg::PoseStamped target_pose;
target_pose.header.frame_id = "panda_link4";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ SemanticWorld::SemanticWorld(const rclcpp::Node::SharedPtr& node,

{
table_subscriber_ = node_handle_->create_subscription<object_recognition_msgs::msg::TableArray>(
"table_array", 1,
"table_array", rclcpp::SystemDefaultsQoS(),
[this](const object_recognition_msgs::msg::TableArray::ConstSharedPtr& msg) { return tableCallback(msg); });
visualization_publisher_ =
node_handle_->create_publisher<visualization_msgs::msg::MarkerArray>("visualize_place", 20);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@

namespace planning_scene_monitor
{
namespace
{
static const auto SUBSCRIPTION_QOS = rclcpp::QoS(25);
}

CurrentStateMonitorMiddlewareHandle::CurrentStateMonitorMiddlewareHandle(const rclcpp::Node::SharedPtr& node)
: node_(node)
Expand All @@ -75,7 +71,7 @@ void CurrentStateMonitorMiddlewareHandle::createJointStateSubscription(const std
JointStateUpdateCallback callback)
{
joint_state_subscription_ =
node_->create_subscription<sensor_msgs::msg::JointState>(topic, SUBSCRIPTION_QOS, callback);
node_->create_subscription<sensor_msgs::msg::JointState>(topic, rclcpp::SystemDefaultsQoS(), callback);
}

void CurrentStateMonitorMiddlewareHandle::resetJointStateSubscription()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ void PlanningSceneMonitor::startSceneMonitor(const std::string& scene_topic)
if (!scene_topic.empty())
{
planning_scene_subscriber_ = pnode_->create_subscription<moveit_msgs::msg::PlanningScene>(
scene_topic, 100, [this](const moveit_msgs::msg::PlanningScene::ConstSharedPtr& scene) {
scene_topic, rclcpp::SystemDefaultsQoS(), [this](const moveit_msgs::msg::PlanningScene::ConstSharedPtr& scene) {
return newPlanningSceneCallback(scene);
});
RCLCPP_INFO(LOGGER, "Listening to '%s'", planning_scene_subscriber_->get_topic_name());
Expand Down Expand Up @@ -1225,15 +1225,16 @@ void PlanningSceneMonitor::startWorldGeometryMonitor(const std::string& collisio
if (!collision_objects_topic.empty())
{
collision_object_subscriber_ = pnode_->create_subscription<moveit_msgs::msg::CollisionObject>(
collision_objects_topic, 1024,
collision_objects_topic, rclcpp::SystemDefaultsQoS(),
[this](const moveit_msgs::msg::CollisionObject::ConstSharedPtr& obj) { return collisionObjectCallback(obj); });
RCLCPP_INFO(LOGGER, "Listening to '%s'", collision_objects_topic.c_str());
}

if (!planning_scene_world_topic.empty())
{
planning_scene_world_subscriber_ = pnode_->create_subscription<moveit_msgs::msg::PlanningSceneWorld>(
planning_scene_world_topic, 1, [this](const moveit_msgs::msg::PlanningSceneWorld::ConstSharedPtr& world) {
planning_scene_world_topic, rclcpp::SystemDefaultsQoS(),
[this](const moveit_msgs::msg::PlanningSceneWorld::ConstSharedPtr& world) {
return newPlanningSceneWorldCallback(world);
});
RCLCPP_INFO(LOGGER, "Listening to '%s' for planning scene world geometry", planning_scene_world_topic.c_str());
Expand Down Expand Up @@ -1306,7 +1307,8 @@ void PlanningSceneMonitor::startStateMonitor(const std::string& joint_states_top
{
// using regular message filter as there's no header
attached_collision_object_subscriber_ = pnode_->create_subscription<moveit_msgs::msg::AttachedCollisionObject>(
attached_objects_topic, 1024, [this](const moveit_msgs::msg::AttachedCollisionObject::ConstSharedPtr& obj) {
attached_objects_topic, rclcpp::SystemDefaultsQoS(),
[this](const moveit_msgs::msg::AttachedCollisionObject::ConstSharedPtr& obj) {
return attachObjectCallback(obj);
});
RCLCPP_INFO(LOGGER, "Listening to '%s' for attached collision objects",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ bool SynchronizedStringParameter::waitForMessage(const rclcpp::Duration& timeout
auto const nd_name = std::string(node_->get_name()).append("_ssp_").append(name_);
auto const temp_node = std::make_shared<rclcpp::Node>(nd_name);
string_subscriber_ = temp_node->create_subscription<std_msgs::msg::String>(
name_, rclcpp::QoS(1).transient_local().reliable(),
name_,
rclcpp::QoS(1).transient_local().reliable(), // "transient_local()" is required for supporting late subscriptions
[this](const std_msgs::msg::String::ConstSharedPtr& msg) { return stringCallback(msg); });

rclcpp::WaitSet wait_set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void TrajectoryExecutionManager::initialize()
auto options = rclcpp::SubscriptionOptions();
options.callback_group = callback_group;
event_topic_subscriber_ = node_->create_subscription<std_msgs::msg::String>(
EXECUTION_EVENT_TOPIC, 100,
EXECUTION_EVENT_TOPIC, rclcpp::SystemDefaultsQoS(),
[this](const std_msgs::msg::String::ConstSharedPtr& event) { return receiveEvent(event); }, options);

controller_mgr_node_->get_parameter("trajectory_execution.execution_duration_monitoring",
Expand Down
4 changes: 2 additions & 2 deletions moveit_ros/robot_interaction/src/robot_interaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,8 @@ void RobotInteraction::toggleMoveInteractiveMarkerTopic(bool enable)
[this, marker_name](const geometry_msgs::msg::PoseStamped::SharedPtr& msg) {
moveInteractiveMarker(marker_name, *msg);
};
auto subscription =
node_->create_subscription<geometry_msgs::msg::PoseStamped>(topic_name, 1, subscription_callback);
auto subscription = node_->create_subscription<geometry_msgs::msg::PoseStamped>(
topic_name, rclcpp::SystemDefaultsQoS(), subscription_callback);
int_marker_move_subscribers_.push_back(subscription);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ void MotionPlanningDisplay::toggleSelectPlanningGroupSubscription(bool enable)
if (enable)
{
planning_group_sub_ = node_->create_subscription<std_msgs::msg::String>(
"/rviz/moveit/select_planning_group", 1,
"/rviz/moveit/select_planning_group", rclcpp::SystemDefaultsQoS(),
[this](const std_msgs::msg::String::ConstSharedPtr& msg) { return selectPlanningGroupCallback(msg); });
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,26 +267,28 @@ void MotionPlanningFrame::allowExternalProgramCommunication(bool enable)
{
using std::placeholders::_1;
plan_subscriber_ = node_->create_subscription<std_msgs::msg::Empty>(
"/rviz/moveit/plan", 1,
"/rviz/moveit/plan", rclcpp::SystemDefaultsQoS(),
[this](const std_msgs::msg::Empty::ConstSharedPtr& msg) { return remotePlanCallback(msg); });
execute_subscriber_ = node_->create_subscription<std_msgs::msg::Empty>(
"/rviz/moveit/execute", 1,
"/rviz/moveit/execute", rclcpp::SystemDefaultsQoS(),
[this](const std_msgs::msg::Empty::ConstSharedPtr& msg) { return remoteExecuteCallback(msg); });
stop_subscriber_ = node_->create_subscription<std_msgs::msg::Empty>(
"/rviz/moveit/stop", 1,
"/rviz/moveit/stop", rclcpp::SystemDefaultsQoS(),
[this](const std_msgs::msg::Empty::ConstSharedPtr& msg) { return remoteStopCallback(msg); });
update_start_state_subscriber_ = node_->create_subscription<std_msgs::msg::Empty>(
"/rviz/moveit/update_start_state", 1,
"/rviz/moveit/update_start_state", rclcpp::SystemDefaultsQoS(),
[this](const std_msgs::msg::Empty::ConstSharedPtr& msg) { return remoteUpdateStartStateCallback(msg); });
update_goal_state_subscriber_ = node_->create_subscription<std_msgs::msg::Empty>(
"/rviz/moveit/update_goal_state", 1,
"/rviz/moveit/update_goal_state", rclcpp::SystemDefaultsQoS(),
[this](const std_msgs::msg::Empty::ConstSharedPtr& msg) { return remoteUpdateGoalStateCallback(msg); });
update_custom_start_state_subscriber_ = node_->create_subscription<moveit_msgs::msg::RobotState>(
"/rviz/moveit/update_custom_start_state", 1, [this](const moveit_msgs::msg::RobotState::ConstSharedPtr& msg) {
"/rviz/moveit/update_custom_start_state", rclcpp::SystemDefaultsQoS(),
[this](const moveit_msgs::msg::RobotState::ConstSharedPtr& msg) {
return remoteUpdateCustomStartStateCallback(msg);
});
update_custom_goal_state_subscriber_ = node_->create_subscription<moveit_msgs::msg::RobotState>(
"/rviz/moveit/update_custom_goal_state", 1, [this](const moveit_msgs::msg::RobotState::ConstSharedPtr& msg) {
"/rviz/moveit/update_custom_goal_state", rclcpp::SystemDefaultsQoS(),
[this](const moveit_msgs::msg::RobotState::ConstSharedPtr& msg) {
return remoteUpdateCustomGoalStateCallback(msg);
});
}
Expand Down Expand Up @@ -614,7 +616,7 @@ void MotionPlanningFrame::initFromMoveGroupNS()
clear_octomap_service_client_ = node_->create_client<std_srvs::srv::Empty>(move_group::CLEAR_OCTOMAP_SERVICE_NAME);

object_recognition_subscriber_ = node_->create_subscription<object_recognition_msgs::msg::RecognizedObjectArray>(
"recognized_object_array", 1,
"recognized_object_array", rclcpp::SystemDefaultsQoS(),
[this](const object_recognition_msgs::msg::RecognizedObjectArray::ConstSharedPtr& msg) {
return listenDetectedObjects(msg);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ void RobotStateDisplay::changedRobotStateTopic()
setStatus(rviz_common::properties::StatusProperty::Warn, "RobotState", "No msg received");

robot_state_subscriber_ = node_->create_subscription<moveit_msgs::msg::DisplayRobotState>(
robot_state_topic_property_->getStdString(), 10,
robot_state_topic_property_->getStdString(), rclcpp::SystemDefaultsQoS(),
[this](const moveit_msgs::msg::DisplayRobotState::ConstSharedPtr& state) { return newRobotStateCallback(state); });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void TrajectoryVisualization::onInitialize(const rclcpp::Node::SharedPtr& node,
}

trajectory_topic_sub_ = node_->create_subscription<moveit_msgs::msg::DisplayTrajectory>(
trajectory_topic_property_->getStdString(), 2,
trajectory_topic_property_->getStdString(), rclcpp::SystemDefaultsQoS(),
[this](const moveit_msgs::msg::DisplayTrajectory::ConstSharedPtr& msg) { return incomingDisplayTrajectory(msg); });
}

Expand Down Expand Up @@ -294,7 +294,7 @@ void TrajectoryVisualization::changedTrajectoryTopic()
if (!trajectory_topic_property_->getStdString().empty() && robot_state_)
{
trajectory_topic_sub_ = node_->create_subscription<moveit_msgs::msg::DisplayTrajectory>(
trajectory_topic_property_->getStdString(), 2,
trajectory_topic_property_->getStdString(), rclcpp::SystemDefaultsQoS(),
[this](const moveit_msgs::msg::DisplayTrajectory::ConstSharedPtr& msg) {
return incomingDisplayTrajectory(msg);
});
Expand Down
8 changes: 5 additions & 3 deletions moveit_ros/warehouse/src/save_to_warehouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,14 @@ int main(int argc, char** argv)
psm.addUpdateCallback([&](auto&&) { return onSceneUpdate(psm, pss); });

auto mplan_req_sub = node->create_subscription<moveit_msgs::msg::MotionPlanRequest>(
"motion_plan_request", 100,
"motion_plan_request", rclcpp::SystemDefaultsQoS(),
[&](const moveit_msgs::msg::MotionPlanRequest& msg) { onMotionPlanRequest(msg, psm, pss); });
auto constr_sub = node->create_subscription<moveit_msgs::msg::Constraints>(
"constraints", 100, [&](const moveit_msgs::msg::Constraints& msg) { onConstraints(msg, cs); });
"constraints", rclcpp::SystemDefaultsQoS(),
[&](const moveit_msgs::msg::Constraints& msg) { onConstraints(msg, cs); });
auto state_sub = node->create_subscription<moveit_msgs::msg::RobotState>(
"robot_state", 100, [&](const moveit_msgs::msg::RobotState& msg) { onRobotState(msg, rs); });
"robot_state", rclcpp::SystemDefaultsQoS(),
[&](const moveit_msgs::msg::RobotState& msg) { onRobotState(msg, rs); });

std::vector<std::string> topics;
psm.getMonitoredTopics(topics);
Expand Down

0 comments on commit 5506dd5

Please sign in to comment.