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  moveit::core::RobotStatePtr robot_state_;
71  const planning_scene_monitor::PlanningSceneMonitorPtr planning_scene_monitor_;
72 
73  // The collision monitor thread.
74  std::thread monitor_thread_;
75  // The flag used for stopping the collision monitor thread.
76  std::atomic<bool> stop_requested_;
77 
78  // The scaling factor when approaching a collision.
79  std::atomic<double>& collision_velocity_scale_;
80 
81  // The data structures used to get information about robot self collisions.
82  collision_detection::CollisionRequest self_collision_request_;
83  collision_detection::CollisionResult self_collision_result_;
84  // The data structures used to get information about robot collision with other objects in the collision scene.
85  collision_detection::CollisionRequest scene_collision_request_;
86  collision_detection::CollisionResult scene_collision_result_;
87 };
88 
89 } // namespace moveit_servo
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.