Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions rmf_robot_sim_common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ find_package(eigen3_cmake_module REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(rmf_fleet_msgs REQUIRED)
Expand Down Expand Up @@ -74,6 +75,7 @@ target_link_libraries(slotcar_common
Eigen3::Eigen
rclcpp::rclcpp
${geometry_msgs_TARGETS}
${std_msgs_TARGETS}
${rmf_fleet_msgs_TARGETS}
${rmf_building_map_msgs_TARGETS}
tf2_ros::tf2_ros
Expand All @@ -91,6 +93,7 @@ target_include_directories(slotcar_common
ament_export_dependencies(
Eigen3
rclcpp
std_msgs
geometry_msgs
tf2_ros
rmf_fleet_msgs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <tf2_ros/transform_broadcaster.h>

#include <geometry_msgs/msg/transform_stamped.hpp>
#include <std_msgs/msg/string.hpp>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR! Do you think that we should use string or some other custom message?

#include <rmf_fleet_msgs/msg/robot_mode.hpp>
#include <rmf_fleet_msgs/msg/robot_state.hpp>
#include <rmf_fleet_msgs/msg/path_request.hpp>
Expand Down Expand Up @@ -174,6 +175,7 @@ class SlotcarCommon

std::shared_ptr<tf2_ros::TransformBroadcaster> _tf2_broadcaster;
rclcpp::Publisher<rmf_fleet_msgs::msg::RobotState>::SharedPtr _robot_state_pub;
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr _collision_pub;

rclcpp::Subscription<rmf_fleet_msgs::msg::PathRequest>::SharedPtr _traj_sub;
rclcpp::Subscription<rmf_fleet_msgs::msg::PauseRequest>::SharedPtr _pause_sub;
Expand Down
1 change: 1 addition & 0 deletions rmf_robot_sim_common/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<depend>eigen</depend>
<depend>rclcpp</depend>
<depend>geometry_msgs</depend>
<depend>std_msgs</depend>
<depend>tf2_ros</depend>
<depend>rmf_fleet_msgs</depend>
<depend>rmf_building_map_msgs</depend>
Expand Down
10 changes: 10 additions & 0 deletions rmf_robot_sim_common/src/slotcar_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ void SlotcarCommon::init_ros_node(const rclcpp::Node::SharedPtr node)
_ros_node->create_publisher<rmf_fleet_msgs::msg::RobotState>(
"/robot_state", 10);

_collision_pub =
_ros_node->create_publisher<std_msgs::msg::String>(
"/robot_collisions", 10);

auto qos_profile = rclcpp::QoS(10);
qos_profile.transient_local();
_building_map_sub =
Expand Down Expand Up @@ -842,8 +846,14 @@ bool SlotcarCommon::emergency_stop(
// TODO flush logger here
// TODO get collision object name
if (need_to_stop)
{
RCLCPP_INFO_STREAM(logger(), "Stopping [" << _model_name <<
"] to avoid a collision");

std_msgs::msg::String msg;
msg.data = _model_name;
_collision_pub->publish(msg);
}
else
RCLCPP_INFO_STREAM(logger(), "No more obstacles; resuming course for [" <<
_model_name << "]");
Expand Down