18 #ifndef COB_COLLISION_MONITOR_VALID_STATE_PUBLISHER_H 19 #define COB_COLLISION_MONITOR_VALID_STATE_PUBLISHER_H 24 #include <std_msgs/Bool.h> 26 #include <moveit/collision_detection/collision_common.h> 39 : planning_scene_monitor_(psm),
41 max_age_(nh.
param(
"max_age", 1.0)),
42 pub_(nh.advertise<
std_msgs::Bool>(
"state_is_valid", 1)),
44 verbose_(nh.
param(
"verbose", false))
46 double ground_size = nh.
param(
"ground_size", 10.0);
48 if(ground_size != 0.0){
50 moveit_msgs::CollisionObject co;
51 co.header.frame_id = nh.
param(
"ground_link",std::string(
"base_link"));
52 co.id =
"_ground_plane_";
55 co.primitives.resize(1);
56 co.primitives.front().type = shape_msgs::SolidPrimitive::BOX;
57 co.primitives.front().dimensions.resize(3);
58 co.primitives.front().dimensions[0] = ground_size;
59 co.primitives.front().dimensions[1] = ground_size;
60 co.primitives.front().dimensions[2] = 0.01;
61 co.primitive_poses.resize(1);
62 co.primitive_poses.front().position.z = -0.005 + nh.
param(
"ground_height",-0.001);
63 co.primitive_poses.front().orientation.w = 1.0;
66 co.planes.front().coef[2] = 1;
67 co.plane_poses.resize(1);
68 co.plane_poses.front().position.z = nh.
param(
"ground_height",-0.001);
69 co.plane_poses.front().orientation.w = 1.0;
71 diff_msg_.world.collision_objects.push_back(co);
72 diff_msg_.is_diff =
true;
84 planning_scene_monitor::CurrentStateMonitorPtr csm = planning_scene_monitor_->getStateMonitor();
85 bool complete = max_age_.
isZero() ? csm->haveCompleteState() : csm->haveCompleteState(max_age_);
89 planning_scene::PlanningScenePtr diff_ps = ps->diff(diff_msg_);
90 data_.data = !diff_ps->isStateColliding(
"", verbose_);
97 diff_ps->getCollidingPairs(contacts);
98 ROS_DEBUG(
"#Collisions: %zu", contacts.size());
99 for (collision_detection::CollisionResult::ContactMap::iterator map_it=contacts.begin(); map_it!=contacts.end(); ++map_it)
101 ROS_ERROR(
"Collision between %s and %s", map_it->first.first.c_str(), map_it->first.second.c_str());
102 ROS_DEBUG(
"#Contacts: %zu", map_it->second.size());
103 for (std::vector<collision_detection::Contact>::iterator vec_it=map_it->second.begin(); vec_it!=map_it->second.end(); ++vec_it)
109 }
else if(was_complete_){
115 catch(std::exception &ex)
117 ROS_DEBUG(
"std::exception: %s", ex.what());
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val)
void publish(const boost::shared_ptr< M > &message) const
planning_scene_monitor::PlanningSceneMonitorPtr planning_scene_monitor_
ValidStatePublisher(ros::NodeHandle nh, planning_scene_monitor::PlanningSceneMonitorPtr psm)
std::map< std::pair< std::string, std::string >, std::vector< Contact > > ContactMap
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
moveit_msgs::PlanningScene diff_msg_
void updatedScene(planning_scene_monitor::PlanningSceneMonitor::SceneUpdateType type)