moveit2
The MoveIt Motion Planning Framework for ROS 2.
collision_monitor.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * BSD 3-Clause License
3  *
4  * Copyright (c) 2019, Los Alamos National Security, LLC
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * * Redistributions of source code must retain the above copyright notice, this
11  * list of conditions and the following disclaimer.
12  *
13  * * Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * * Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *******************************************************************************/
33 /*
34  * Title : collision_monitor.hpp
35  * Project : moveit_servo
36  * Created : 06/08/2023
37  * Author : Brian O'Neil, Andy Zelenak, Blake Anderson, V Mohammed Ibrahim
38  *
39  * Description: Monitors the planning scene for collision and publishes the velocity scaling.
40  */
41 
42 #pragma once
43 
44 #include <moveit_servo_lib_parameters.hpp>
47 
48 namespace moveit_servo
49 {
50 
52 {
53 public:
54  CollisionMonitor(const planning_scene_monitor::PlanningSceneMonitorPtr& planning_scene_monitor,
55  const servo::Params& servo_params, std::atomic<double>& collision_velocity_scale);
56 
57  void start();
58 
59  void stop();
60 
61 private:
65  void checkCollisions();
66 
67  // Variables
68 
69  const servo::Params& servo_params_;
70 
71  const planning_scene_monitor::PlanningSceneMonitorPtr planning_scene_monitor_;
72  moveit::core::RobotState robot_state_;
73 
74  // The collision monitor thread.
75  std::thread monitor_thread_;
76  // The flag used for stopping the collision monitor thread.
77  std::atomic<bool> stop_requested_;
78 
79  // The scaling factor when approaching a collision.
80  std::atomic<double>& collision_velocity_scale_;
81 
82  // The data structures used to get information about robot self collisions.
83  collision_detection::CollisionRequest self_collision_request_;
84  collision_detection::CollisionResult self_collision_result_;
85  // The data structures used to get information about robot collision with other objects in the collision scene.
86  collision_detection::CollisionRequest scene_collision_request_;
87  collision_detection::CollisionResult scene_collision_result_;
88 };
89 
90 } // namespace moveit_servo
Representation of a robot's state. This includes position, velocity, acceleration and effort.
Definition: robot_state.hpp:90
CollisionMonitor(const planning_scene_monitor::PlanningSceneMonitorPtr &planning_scene_monitor, const servo::Params &servo_params, std::atomic< double > &collision_velocity_scale)
Representation of a collision checking request.
Representation of a collision checking result.