Go to the documentation of this file.
43 #include <gtest/gtest.h>
46 using geometry_msgs::Point;
67 nh.setParam(
"/inflation_tests/inflation/inflation_radius", inflation_radius);
79 m[0].push_back(initial);
82 for (
int i = 0; i < bin->second.size(); ++i)
84 const CellData& cell = bin->second[i];
90 double dist = hypot(dx, dy);
92 unsigned char expected_cost = ilayer->
computeCost(dist);
93 ASSERT_TRUE(costmap->
getCost(cell.
x_, cell.
y_) >= expected_cost);
95 if (dist > inflation_radius)
100 if (dist == bin->first)
111 m[dist].push_back(data);
117 m[dist].push_back(data);
123 m[dist].push_back(data);
129 m[dist].push_back(data);
137 TEST(costmap, testAdjacentToObstacleCanStillMove){
163 TEST(costmap, testInflationShouldNotCreateUnknowns){
188 TEST(costmap, testCostFunctionCorrectness){
210 for(
unsigned int i = 0; i <= (
unsigned int)ceil(5.0); i++){
226 for(
unsigned int i = (
unsigned int)(ceil(5.0) + 1); i <= (
unsigned int)ceil(10.5); i++){
227 unsigned char expectedValue = ilayer->
computeCost(i/1.0);
228 ASSERT_EQ(map->
getCost(50 + i, 50), expectedValue);
256 TEST(costmap, testInflationOrderCorrectness){
263 const double inflation_radius = 4.1;
413 int main(
int argc,
char** argv){
414 ros::init(argc, argv,
"inflation_tests");
415 testing::InitGoogleTest(&argc, argv);
416 return RUN_ALL_TESTS();
void addObservation(costmap_2d::ObstacleLayer *olayer, double x, double y, double z=0.0, double ox=0.0, double oy=0.0, double oz=MAX_Z)
void addStaticLayer(costmap_2d::LayeredCostmap &layers, tf2_ros::Buffer &tf)
static const unsigned char INSCRIBED_INFLATED_OBSTACLE
void setFootprint(const std::vector< geometry_msgs::Point > &footprint_spec)
Updates the stored footprint, updates the circumscribed and inscribed radii, and calls onFootprintCha...
static const unsigned char NO_INFORMATION
void resizeMap(unsigned int size_x, unsigned int size_y, double resolution, double origin_x, double origin_y, bool size_locked=false)
Storage for cell information used during obstacle inflation.
virtual unsigned char computeCost(double distance) const
Given a distance, compute a cost.
A 2D costmap provides a mapping between points in the world and their associated "costs".
costmap_2d::ObstacleLayer * addObstacleLayer(costmap_2d::LayeredCostmap &layers, tf2_ros::Buffer &tf)
std::vector< Point > setRadii(LayeredCostmap &layers, double length, double width, double inflation_radius)
unsigned int getSizeInCellsY() const
Accessor for the y size of the costmap in cells.
static const unsigned char LETHAL_OBSTACLE
int main(int argc, char **argv)
void updateMap(double robot_x, double robot_y, double robot_yaw)
Update the underlying costmap with new data. If you want to update the map outside of the update loop...
Instantiates different layer plugins and aggregates them into one score.
unsigned int getIndex(unsigned int mx, unsigned int my) const
Given two map coordinates... compute the associated index.
static const unsigned char FREE_SPACE
costmap_2d::InflationLayer * addInflationLayer(costmap_2d::LayeredCostmap &layers, tf2_ros::Buffer &tf)
TEST(costmap, testAdjacentToObstacleCanStillMove)
unsigned int getSizeInCellsX() const
Accessor for the x size of the costmap in cells.
void printMap(costmap_2d::Costmap2D &costmap)
unsigned char getCost(unsigned int mx, unsigned int my) const
Get the cost of a cell in the costmap.
unsigned int countValues(costmap_2d::Costmap2D &costmap, unsigned char value, bool equal=true)
void validatePointInflation(unsigned int mx, unsigned int my, Costmap2D *costmap, InflationLayer *ilayer, double inflation_radius)