43 #include <gtest/gtest.h>
54 psm = std::make_unique<planning_scene_monitor::PlanningSceneMonitor>(
"robot_description");
55 psm->monitorDiffs(
true);
65 planning_scene_monitor::PlanningSceneMonitorPtr
psm;
66 planning_scene::PlanningScenePtr
scene;
72 auto scene{ psm->getPlanningScene() };
73 moveit_msgs::PlanningScene msg;
74 msg.is_diff = msg.robot_state.is_diff =
true;
75 psm->newPlanningSceneMessage(msg);
76 EXPECT_EQ(scene, psm->getPlanningScene());
78 msg.is_diff = msg.robot_state.is_diff =
false;
79 psm->newPlanningSceneMessage(msg);
80 EXPECT_EQ(scene, psm->getPlanningScene());
85 #define TRIGGERS_UPDATE(msg, expected_update_type) \
87 psm->clearUpdateCallbacks(); \
88 auto received_update_type{ UpdateType::UPDATE_NONE }; \
89 psm->addUpdateCallback([&](auto type) { received_update_type = type; }); \
90 psm->newPlanningSceneMessage(msg); \
91 EXPECT_EQ(received_update_type, expected_update_type); \
96 moveit_msgs::PlanningScene msg;
97 msg.is_diff = msg.robot_state.is_diff =
true;
100 msg.fixed_frame_transforms.emplace_back();
101 msg.fixed_frame_transforms.back().header.frame_id =
"base_link";
102 msg.fixed_frame_transforms.back().child_frame_id =
"object";
103 msg.fixed_frame_transforms.back().transform.rotation.w = 1.0;
105 msg.fixed_frame_transforms.clear();
108 msg.robot_state.is_diff =
true;
111 msg.robot_state.is_diff =
false;
112 TRIGGERS_UPDATE(msg, UpdateType::UPDATE_STATE | UpdateType::UPDATE_GEOMETRY);
114 msg.robot_state = moveit_msgs::RobotState{};
115 msg.robot_state.is_diff =
true;
116 moveit_msgs::CollisionObject co;
117 co.header.frame_id =
"base_link";
119 co.operation = moveit_msgs::CollisionObject::ADD;
120 co.pose.orientation.w = 1.0;
121 co.primitives.emplace_back();
122 co.primitives.back().type = shape_msgs::SolidPrimitive::SPHERE;
123 co.primitives.back().dimensions = { 1.0 };
124 msg.world.collision_objects.emplace_back(co);
127 msg.world.collision_objects.clear();
133 int main(
int argc,
char** argv)
135 testing::InitGoogleTest(&argc, argv);
136 ros::init(argc, argv,
"planning_scene_monitor_test");
141 return RUN_ALL_TESTS();