In a rolling (local) costmap the StaticLayer extent is in map_frame_, so the bounds it reported did not cover the moving master window and zone layers (forbidden, preferred, unpreferred, critical) were not redrawn as the robot moved. - StaticLayer::updateBounds: when the costmap is rolling, expand the bounds to the whole master window every cycle. - StaticLayer::updateCosts: skip when disabled; the transformed path uses the master grid passed in and the same merge policy as the aligned path. - CostmapLayer::mergeCost: one merge rule for aligned and transformed grids. NO_INFORMATION in the layer keeps the master cell; CRITICAL_SPACE always wins; PREFERRED/UNPREFERRED only below INSCRIBED_INFLATED_OBSTACLE; otherwise max. updateWithMax and updateWithOverwrite keep their previous results. - CriticalLayer::updateCosts delegates to StaticLayer::updateCosts, so it is rolling-aware too. - Test: rolling_static_layer_test, 7 cases. Tests on dev: rolling_static_layer_test 7/7, test_costmap 9/9, costmap_common_root_test 4/4 (rooted and flat). directional_layer_test InvalidMaxDeviationThrows still fails: it checks directional_layer.cpp initialization, which this change does not touch.
155 lines
5.9 KiB
C++
Executable File
155 lines
5.9 KiB
C++
Executable File
/*********************************************************************
|
|
*
|
|
* Software License Agreement (BSD License)
|
|
*
|
|
* Copyright (c) 2008, 2013, Willow Garage, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
*
|
|
* * Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* * Redistributions in binary form must reproduce the above
|
|
* copyright notice, this list of conditions and the following
|
|
* disclaimer in the documentation and/or other materials provided
|
|
* with the distribution.
|
|
* * Neither the name of Willow Garage, Inc. nor the names of its
|
|
* contributors may be used to endorse or promote products derived
|
|
* from this software without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
*
|
|
* Author: Eitan Marder-Eppstein
|
|
* David V. Lu!!
|
|
*********************************************************************/
|
|
#ifndef ROBOT_COSTMAP_2D_COSTMAP_LAYER_H_
|
|
#define ROBOT_COSTMAP_2D_COSTMAP_LAYER_H_
|
|
|
|
#include <robot_costmap_2d/layer.h>
|
|
#include <robot_costmap_2d/layered_costmap.h>
|
|
|
|
namespace robot_costmap_2d
|
|
{
|
|
|
|
class CostmapLayer : public Layer, public Costmap2D
|
|
{
|
|
public:
|
|
CostmapLayer() : has_extra_bounds_(false),
|
|
extra_min_x_(1e6), extra_max_x_(-1e6),
|
|
extra_min_y_(1e6), extra_max_y_(-1e6) {}
|
|
|
|
bool isDiscretized()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
virtual void matchSize();
|
|
|
|
virtual void clearArea(int start_x, int start_y, int end_x, int end_y, bool invert_area=false);
|
|
|
|
/**
|
|
* If an external source changes values in the costmap,
|
|
* it should call this method with the area that it changed
|
|
* to ensure that the costmap includes this region as well.
|
|
* @param mx0 Minimum x value of the bounding box
|
|
* @param my0 Minimum y value of the bounding box
|
|
* @param mx1 Maximum x value of the bounding box
|
|
* @param my1 Maximum y value of the bounding box
|
|
*/
|
|
void addExtraBounds(double mx0, double my0, double mx1, double my1);
|
|
|
|
protected:
|
|
/// Merge one known layer cell with the same policy in aligned and transformed grids.
|
|
static unsigned char mergeCost(unsigned char master_cost, unsigned char layer_cost, bool use_maximum);
|
|
|
|
/*
|
|
* Updates the master_grid within the specified
|
|
* bounding box using this layer's values.
|
|
*
|
|
* TrueOverwrite means every value from this layer
|
|
* is written into the master grid.
|
|
*/
|
|
void updateWithTrueOverwrite(robot_costmap_2d::Costmap2D& master_grid, int min_i, int min_j, int max_i, int max_j);
|
|
|
|
/*
|
|
* Updates the master_grid within the specified
|
|
* bounding box using this layer's values.
|
|
*
|
|
* Overwrite means every valid value from this layer
|
|
* is written into the master grid (does not copy NO_INFORMATION)
|
|
*/
|
|
void updateWithOverwrite(robot_costmap_2d::Costmap2D& master_grid, int min_i, int min_j, int max_i, int max_j);
|
|
|
|
/*
|
|
* Updates the master_grid within the specified
|
|
* bounding box using this layer's values.
|
|
*
|
|
* Sets the new value to the maximum of the master_grid's value
|
|
* and this layer's value. If the master value is NO_INFORMATION,
|
|
* it is overwritten. If the layer's value is NO_INFORMATION,
|
|
* the master value does not change.
|
|
*/
|
|
void updateWithMax(robot_costmap_2d::Costmap2D& master_grid, int min_i, int min_j, int max_i, int max_j);
|
|
|
|
/*
|
|
* Updates the master_grid within the specified
|
|
* bounding box using this layer's values.
|
|
*
|
|
* Sets the new value to the sum of the master grid's value
|
|
* and this layer's value. If the master value is NO_INFORMATION,
|
|
* it is overwritten with the layer's value. If the layer's value
|
|
* is NO_INFORMATION, then the master value does not change.
|
|
*
|
|
* If the sum value is larger than INSCRIBED_INFLATED_OBSTACLE,
|
|
* the master value is set to (INSCRIBED_INFLATED_OBSTACLE - 1).
|
|
*/
|
|
void updateWithAddition(robot_costmap_2d::Costmap2D& master_grid, int min_i, int min_j, int max_i, int max_j);
|
|
|
|
/**
|
|
* Updates the bounding box specified in the parameters to include
|
|
* the location (x,y)
|
|
*
|
|
* @param x x-coordinate to include
|
|
* @param y y-coordinate to include
|
|
* @param min_x bounding box
|
|
* @param min_y bounding box
|
|
* @param max_x bounding box
|
|
* @param max_y bounding box
|
|
*/
|
|
void touch(double x, double y, double* min_x, double* min_y, double* max_x, double* max_y);
|
|
|
|
/*
|
|
* Updates the bounding box specified in the parameters
|
|
* to include the bounding box from the addExtraBounds
|
|
* call. If addExtraBounds was not called, the method will do nothing.
|
|
*
|
|
* Should be called at the beginning of the updateBounds method
|
|
*
|
|
* @param min_x bounding box (input and output)
|
|
* @param min_y bounding box (input and output)
|
|
* @param max_x bounding box (input and output)
|
|
* @param max_y bounding box (input and output)
|
|
*/
|
|
void useExtraBounds(double* min_x, double* min_y, double* max_x, double* max_y);
|
|
bool has_extra_bounds_;
|
|
|
|
private:
|
|
double extra_min_x_, extra_max_x_, extra_min_y_, extra_max_y_;
|
|
};
|
|
|
|
} // namespace robot_costmap_2d
|
|
#endif // ROBOT_COSTMAP_2D_COSTMAP_LAYER_H_
|