feat(directional_layer): make the allowed deviation configurable
Add max_deviation_deg (default 90, valid 0 < x < 180). The field carries the value so checkSegment and every planner use the same rule. 90 keeps the previous masks bit for bit; out-of-range values stop the layer from initialising.
This commit is contained in:
@@ -118,9 +118,10 @@ bool traverseGridSegment(double x0, double y0, double x1, double y1, Visitor&& v
|
||||
/** @brief Return allowed direction indices for a displacement.
|
||||
* @param dx Displacement along +X [m or cells] in the global/grid frame.
|
||||
* @param dy Displacement along +Y [same units as dx] in the global/grid frame.
|
||||
* @return Bit k is set when dot(v_k, displacement) is nonnegative within sign tolerance.
|
||||
* @param max_deviation_rad Maximum inclusive angular deviation [rad], in (0, pi).
|
||||
* @return Bit k is set when direction k accepts the displacement within relative tolerance.
|
||||
*/
|
||||
uint8_t allowedDirectionMask(double dx, double dy);
|
||||
uint8_t allowedDirectionMask(double dx, double dy, double max_deviation_rad);
|
||||
|
||||
/** @brief Outcome of a world-space segment query. */
|
||||
enum class SegmentResult
|
||||
@@ -148,10 +149,12 @@ public:
|
||||
/** @brief Validate and construct a field; invalid input returns null.
|
||||
* @param grid Complete direction message in the global frame.
|
||||
* @param expected Master grid geometry in the global frame.
|
||||
* @param max_deviation_rad Maximum inclusive deviation [rad], in (0, pi).
|
||||
* @param result Optional output explaining validation success or failure.
|
||||
*/
|
||||
static std::shared_ptr<const DirectionField> create(const robot_nav_msgs::OccupancyGrid& grid,
|
||||
const DirectionGeometry& expected,
|
||||
double max_deviation_rad,
|
||||
DirectionValidationResult* result = nullptr);
|
||||
|
||||
/** @brief Return cell code: 0 unconstrained, 1..8 direction_index + 1.
|
||||
@@ -171,6 +174,8 @@ public:
|
||||
|
||||
/** @brief Return the immutable master geometry and global frame. */
|
||||
const DirectionGeometry& geometry() const { return geometry_; }
|
||||
/** @brief Return the immutable maximum angular deviation [rad]. */
|
||||
double maxDeviationRad() const { return max_deviation_rad_; }
|
||||
/** @brief True if at least one cell has a nonzero direction code. */
|
||||
bool hasConstraints() const { return has_constraints_; }
|
||||
|
||||
@@ -186,9 +191,11 @@ public:
|
||||
SegmentViolation* first = nullptr) const;
|
||||
|
||||
private:
|
||||
DirectionField(const robot_nav_msgs::OccupancyGrid& grid, const DirectionGeometry& geometry);
|
||||
DirectionField(const robot_nav_msgs::OccupancyGrid& grid, const DirectionGeometry& geometry,
|
||||
double max_deviation_rad);
|
||||
DirectionGeometry geometry_;
|
||||
std::vector<uint8_t> codes_;
|
||||
double max_deviation_rad_;
|
||||
bool has_constraints_;
|
||||
};
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ private:
|
||||
bool seen_map_;
|
||||
bool debug_state_;
|
||||
bool rolling_;
|
||||
double max_deviation_rad_; ///< Maximum angular deviation [rad].
|
||||
std::string map_topic_, direction_topic_;
|
||||
std::chrono::steady_clock::time_point pending_since_, last_pending_log_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user