41 #include <gtest/gtest.h>
55 for (
unsigned int i = 0; i < trials; ++i)
58 scene.checkCollision(req, res, state);
89 collision_detection::CollisionEnvPtr
cenv_;
91 collision_detection::AllowedCollisionMatrixPtr
acm_;
101 const std::string plugin_name = GetParam();
102 SCOPED_TRACE(plugin_name);
104 std::vector<moveit::core::RobotState> states;
105 std::vector<std::thread> threads;
106 std::vector<bool> collisions;
109 if (!loader.
activate(plugin_name, planning_scene_))
111 #if defined(GTEST_SKIP_)
112 GTEST_SKIP_(
"Failed to load collision plugin");
118 for (
unsigned int i = 0; i <
THREADS; ++i)
122 state.setToRandomPositions();
125 states.push_back(std::move(state));
128 for (
unsigned int i = 0; i <
THREADS; ++i)
129 threads.emplace_back(std::thread([i, &
scene = *planning_scene_, &state = states[i], expected = collisions[i]] {
130 return runCollisionDetectionAssert(i, TRIALS, scene, state, expected);
133 for (
unsigned int i = 0; i < states.size(); ++i)
139 planning_scene_.reset();
142 #ifndef INSTANTIATE_TEST_SUITE_P
143 #define INSTANTIATE_TEST_SUITE_P(...) INSTANTIATE_TEST_CASE_P(__VA_ARGS__)
149 int main(
int argc,
char** argv)
151 ::testing::InitGoogleTest(&argc, argv);
152 return RUN_ALL_TESTS();
collision_detection::CollisionEnvPtr cenv_
moveit::core::RobotModelPtr robot_model_
planning_scene::PlanningScenePtr planning_scene_
moveit::core::RobotStatePtr robot_state_
collision_detection::AllowedCollisionMatrixPtr acm_
bool activate(const std::string &name, const planning_scene::PlanningScenePtr &scene)
Activate a specific collision plugin for the given planning scene instance.
Representation of a robot's state. This includes position, velocity, acceleration and effort.
const RobotModelConstPtr & getRobotModel() const
Get the robot model this state is constructed for.
This class maintains the representation of the environment as seen by a planning instance....
moveit::core::RobotModelPtr loadTestingRobotModel(const std::string &robot_name)
Loads a robot from moveit_resources.
Representation of a collision checking request.
Representation of a collision checking result.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW void clear()
Clear a previously stored result.
bool collision
True if collision was found, false otherwise.
int main(int argc, char **argv)
#define INSTANTIATE_TEST_SUITE_P(...)
bool runCollisionDetection(unsigned int, unsigned int trials, const planning_scene::PlanningScene &scene, const moveit::core::RobotState &state)
void runCollisionDetectionAssert(unsigned int id, unsigned int trials, const planning_scene::PlanningScene &scene, const moveit::core::RobotState &state, bool expected_result)
TEST_P(CollisionDetectorTests, Threaded)
Tests the collision detector in multiple threads.