Skip to content

Commit d0471a2

Browse files
authored
Merge pull request #74 from JustusBraun/pr/free-space-layer
Feature: Add layer which checks if a robot can fit through a space
2 parents ea54926 + 0c7999f commit d0471a2

File tree

7 files changed

+404
-3
lines changed

7 files changed

+404
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ The package structure is as follows:
139139
- RoughnessLayer - `mesh_layers/RoughnessLayer`
140140
- SteepnessLayer - `mesh_layers/SteepnessLayer`
141141
- RidgeLayer - `mesh_layer/RidgeLayer`
142+
- ClearanceLayer - `mesh_layers/ClearanceLayer`
142143
- InflationLayer - `mesh_layers/InflationLayer`
143144

144145
- `dijkstra_mesh_planner` contains a mesh planner plugin providing a path planning method based on Dijkstra's algorithm.
@@ -170,6 +171,7 @@ below.
170171
| **RoughnessLayer** | `mesh_layers/RoughnessLayer` | local radius based normal fluctuation | ![RoughnessLayer](docs/images/costlayers/roughness.jpg?raw=true "Roughness Layer") |
171172
| **SteepnessLayer** | `mesh_layers/SteepnessLayer` | arccos of the normal's z coordinate | ![SteepnessLayer](docs/images/costlayers/steepness.jpg?raw=true "Steepness Layer") |
172173
| **RidgeLayer** | `mesh_layer/RidgeLayer` | local radius based distance along normal | ![RidgeLayer](docs/images/costlayers/ridge.jpg?raw=true "RidgeLayer") |
174+
| **ClearanceLayer** | `mesh_layers/ClearanceLayer` | comparison of robot height and clearance along each vertex normal | ![ClearanceLayer](docs/images/costlayers/clearance.jpg?raw=true "Clearance Layer") |
173175
| **InflationLayer** | `mesh_layers/InflationLayer` | by distance to a lethal vertex | ![InflationLayer](docs/images/costlayers/inflation.jpg?raw=true "Inflation Layer") |
174176

175177
# Planners

docs/images/costlayers/clearance.jpg

368 KB
Loading

mesh_layers/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ add_library(${PROJECT_NAME}
2222
src/inflation_layer.cpp
2323
src/steepness_layer.cpp
2424
src/ridge_layer.cpp
25+
src/clearance_layer.cpp
2526
)
2627
include_directories(
2728
include
@@ -53,4 +54,4 @@ install(TARGETS
5354
ament_export_include_directories(include)
5455
ament_export_libraries(${PROJECT_NAME})
5556
ament_export_dependencies(mesh_map)
56-
ament_package()
57+
ament_package()
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
/*
2+
* Copyright 2024, Justus Braun
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
*
8+
* 1. Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
*
11+
* 2. Redistributions in binary form must reproduce the above
12+
* copyright notice, this list of conditions and the following
13+
* disclaimer in the documentation and/or other materials provided
14+
* with the distribution.
15+
*
16+
* 3. Neither the name of the copyright holder nor the names of its
17+
* contributors may be used to endorse or promote products derived
18+
* from this software without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24+
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30+
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31+
* POSSIBILITY OF SUCH DAMAGE.
32+
*
33+
* authors:
34+
* Justus Braun <[email protected]>
35+
*
36+
*/
37+
38+
#ifndef MESH_MAP__FREESPACE_LAYER_H
39+
#define MESH_MAP__FREESPACE_LAYER_H
40+
41+
#include <mesh_map/abstract_layer.h>
42+
#include <rclcpp/rclcpp.hpp>
43+
44+
namespace mesh_layers
45+
{
46+
/**
47+
* @brief Costmap layer which calculates the free space in the direction of the vertex normals
48+
*/
49+
class ClearanceLayer : public mesh_map::AbstractLayer
50+
{
51+
/**
52+
* @brief try read layer from map file
53+
*
54+
* @return true if successul; else false
55+
*/
56+
virtual bool readLayer() override;
57+
58+
/**
59+
* @brief try to write layer to map file
60+
*
61+
* @return true if successfull; else false
62+
*/
63+
virtual bool writeLayer() override;
64+
65+
/**
66+
* @brief delivers the default layer value
67+
*
68+
* @return default value used for this layer
69+
*/
70+
virtual float defaultValue() override
71+
{
72+
return std::numeric_limits<float>::infinity();
73+
}
74+
75+
/**
76+
* @brief delivers the threshold above which vertices are marked lethal
77+
*
78+
* @return lethal threshold
79+
*/
80+
virtual float threshold() override;
81+
82+
/**
83+
* @brief calculate the values of this layer
84+
*
85+
* @return true if successfull; else false
86+
*/
87+
virtual bool computeLayer() override;
88+
89+
/**
90+
* @brief deliver the current costmap
91+
*
92+
* @return calculated costmap
93+
*/
94+
virtual lvr2::VertexMap<float>& costs() override;
95+
96+
/**
97+
* @brief deliver set containing all vertices marked as lethal
98+
*
99+
* @return lethal vertices
100+
*/
101+
virtual std::set<lvr2::VertexHandle>& lethals() override
102+
{
103+
return lethal_vertices_;
104+
}
105+
106+
/**
107+
* @brief update set of lethal vertices by adding and removing vertices
108+
*
109+
* @param added_lethal vertices to be marked as lethal
110+
* @param removed_lethal vertices to be removed from the set of lethal vertices
111+
*/
112+
virtual void updateLethal(std::set<lvr2::VertexHandle>& added_lethal, std::set<lvr2::VertexHandle>& removed_lethal) override {};
113+
114+
/**
115+
* @brief initializes this layer plugin
116+
*
117+
* @return true if initialization was successfull; else false
118+
*/
119+
virtual bool initialize() override;
120+
121+
/**
122+
* @brief callback for incoming param changes
123+
*/
124+
rcl_interfaces::msg::SetParametersResult reconfigureCallback(std::vector<rclcpp::Parameter> parameters);
125+
126+
private:
127+
/**
128+
* @brief mark vertices without enough clearance as lethal and compute the costs
129+
*
130+
* @return true if successfull; else false
131+
*/
132+
bool computeLethalsAndCosts();
133+
134+
// distance along vertex normal until the next face
135+
lvr2::DenseVertexMap<float> clearance_;
136+
// Actual costs values
137+
lvr2::DenseVertexMap<float> costs_;
138+
// set of all current lethal vertices
139+
std::set<lvr2::VertexHandle> lethal_vertices_;
140+
141+
rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr dyn_params_handler_;
142+
struct {
143+
double robot_height = 0.5;
144+
double height_inflation = 0.3;
145+
double factor = 1.0;
146+
} config_;
147+
};
148+
149+
} /* namespace mesh_layers */
150+
151+
#endif // MESH_MAP__FREESPACE_LAYER_H

mesh_layers/mesh_layers.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,11 @@
4141
Calculates an indicator whether or not a vertex is part of a ridge.
4242
</description>
4343
</class>
44-
</library>
44+
<class name="mesh_layers/ClearanceLayer"
45+
type="mesh_layers::ClearanceLayer"
46+
base_class_type="mesh_map::AbstractLayer">
47+
<description>
48+
Calculates the free space along the vertex normals and uses it to check if the robot fits through a space. Useful for doors, holes etc.
49+
</description>
50+
</class>
51+
</library>

0 commit comments

Comments
 (0)