The charger goal is the docked base_link pose, and the real charger face lies 0.40 m behind it (detector offset_x). mating_edge measured the pivot sweep from a face assumed at mating_extent (0.325 m) behind the goal, and still forced a terminal of at least rear_extent. So the robot rotated with its centre about 0.725 m from the charger face. Two optional keys, valid only with dock_anchor: mating_edge (rejected with center or face): - dock_face_offset [m]: distance from the goal back to the real dock face. Default mating_extent. - dock_pivot_safety_margin [m]: overrides maneuver/pivot_safety_margin for this marker. A YAML null reads as unset, so move_base2 can clear a previous marker's value. For mating_edge, the terminal floor becomes max(mating_extent - face_offset, 0) + padding (floored at path_point_spacing), and the pivot vertex becomes max(straight_distance, circumscribed - face_offset + margin). The costmap rotation radius uses the same margin. center and face are unchanged. KIT charger (face offset 0.40, margin 0.10, straight_length 0.2): vertex 0.2 m, robot centre 0.60 m from the charger face. Tests cover the three robot starts, the defaults, validation and null handling. The test target now links yaml-cpp itself.
1469 lines
63 KiB
C++
1469 lines
63 KiB
C++
#include <algorithm>
|
|
#include <cmath>
|
|
#include <iostream>
|
|
#include <limits>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <data_convert/data_convert.h>
|
|
#include <robot/node_handle.h>
|
|
|
|
#include "dock_planner/dock_calc.h"
|
|
#include "dock_planner/dock_planner_config.h"
|
|
|
|
namespace
|
|
{
|
|
|
|
constexpr double kPi = 3.14159265358979323846;
|
|
int failures = 0;
|
|
|
|
void check(bool condition, const char* expression, int line)
|
|
{
|
|
if (!condition)
|
|
{
|
|
std::cerr << "FAIL line " << line << ": " << expression << '\n';
|
|
++failures;
|
|
}
|
|
}
|
|
|
|
#define CHECK(expression) check((expression), #expression, __LINE__)
|
|
|
|
robot_geometry_msgs::Point point(double x, double y)
|
|
{
|
|
robot_geometry_msgs::Point result;
|
|
result.x = x;
|
|
result.y = y;
|
|
result.z = 0.0;
|
|
return result;
|
|
}
|
|
|
|
robot_geometry_msgs::PoseStamped pose(double x, double y, double yaw)
|
|
{
|
|
robot_geometry_msgs::PoseStamped result;
|
|
result.pose.position.x = x;
|
|
result.pose.position.y = y;
|
|
result.pose.orientation = data_convert::createQuaternionMsgFromYaw(yaw);
|
|
return result;
|
|
}
|
|
|
|
bool near(double first, double second, double tolerance = 1e-8)
|
|
{
|
|
return std::fabs(first - second) <= tolerance;
|
|
}
|
|
|
|
bool samePoseExactly(const robot_geometry_msgs::Pose& first,
|
|
const robot_geometry_msgs::Pose& second)
|
|
{
|
|
return first.position.x == second.position.x &&
|
|
first.position.y == second.position.y &&
|
|
first.position.z == second.position.z &&
|
|
first.orientation.x == second.orientation.x &&
|
|
first.orientation.y == second.orientation.y &&
|
|
first.orientation.z == second.orientation.z &&
|
|
first.orientation.w == second.orientation.w;
|
|
}
|
|
|
|
bool pathsEqualExactly(const std::vector<robot_geometry_msgs::Pose>& first,
|
|
const std::vector<robot_geometry_msgs::Pose>& second)
|
|
{
|
|
if (first.size() != second.size())
|
|
{
|
|
return false;
|
|
}
|
|
for (std::size_t index = 0; index < first.size(); ++index)
|
|
{
|
|
if (!samePoseExactly(first[index], second[index]))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
double normalizeAngle(double angle)
|
|
{
|
|
return std::remainder(angle, 2.0 * kPi);
|
|
}
|
|
|
|
double longitudinal(const robot_geometry_msgs::Pose& value,
|
|
const robot_geometry_msgs::Pose& goal)
|
|
{
|
|
const double yaw = data_convert::getYaw(goal.orientation);
|
|
const double dx = value.position.x - goal.position.x;
|
|
const double dy = value.position.y - goal.position.y;
|
|
return dx * std::cos(yaw) + dy * std::sin(yaw);
|
|
}
|
|
|
|
double lateral(const robot_geometry_msgs::Pose& value,
|
|
const robot_geometry_msgs::Pose& goal)
|
|
{
|
|
const double yaw = data_convert::getYaw(goal.orientation);
|
|
const double dx = value.position.x - goal.position.x;
|
|
const double dy = value.position.y - goal.position.y;
|
|
return -dx * std::sin(yaw) + dy * std::cos(yaw);
|
|
}
|
|
|
|
bool edgeIsForward(const robot_geometry_msgs::Pose& first,
|
|
const robot_geometry_msgs::Pose& second)
|
|
{
|
|
const double motion_yaw = std::atan2(second.position.y - first.position.y,
|
|
second.position.x - first.position.x);
|
|
const double body_yaw = data_convert::getYaw(first.orientation);
|
|
return std::cos(normalizeAngle(motion_yaw - body_yaw)) > 0.0;
|
|
}
|
|
|
|
double threePointCurvature(const robot_geometry_msgs::Pose& first,
|
|
const robot_geometry_msgs::Pose& middle,
|
|
const robot_geometry_msgs::Pose& last)
|
|
{
|
|
const double ab = std::hypot(middle.position.x - first.position.x,
|
|
middle.position.y - first.position.y);
|
|
const double bc = std::hypot(last.position.x - middle.position.x,
|
|
last.position.y - middle.position.y);
|
|
const double ac = std::hypot(last.position.x - first.position.x,
|
|
last.position.y - first.position.y);
|
|
if (ab <= 1e-12 || bc <= 1e-12 || ac <= 1e-12)
|
|
{
|
|
return 0.0;
|
|
}
|
|
const double twice_area = std::fabs(
|
|
(middle.position.x - first.position.x) * (last.position.y - first.position.y) -
|
|
(middle.position.y - first.position.y) * (last.position.x - first.position.x));
|
|
return 2.0 * twice_area / (ab * bc * ac);
|
|
}
|
|
|
|
/**
|
|
* @brief Assert the single-cusp contract: one curved lead-in, one direction
|
|
* change, then a straight terminal on the goal axis.
|
|
*
|
|
* @param terminal_forward true when the terminal leg is driven forward (front
|
|
* edge docks, e.g. a charging contact), false when it is driven in
|
|
* reverse (rear edge docks, e.g. forks into a pallet). The lead-in
|
|
* always runs in the opposite direction.
|
|
*/
|
|
std::size_t checkSingleCuspPath(
|
|
const std::vector<robot_geometry_msgs::Pose>& path,
|
|
const robot_geometry_msgs::Pose& goal,
|
|
double maximum_curvature,
|
|
bool terminal_forward)
|
|
{
|
|
CHECK(path.size() > 3);
|
|
std::size_t cusp_index = path.size();
|
|
int direction_changes = 0;
|
|
bool previous_forward = edgeIsForward(path[0], path[1]);
|
|
CHECK(previous_forward != terminal_forward);
|
|
|
|
for (std::size_t index = 1; index + 1 < path.size(); ++index)
|
|
{
|
|
const bool current_forward = edgeIsForward(path[index], path[index + 1]);
|
|
if (current_forward != previous_forward)
|
|
{
|
|
++direction_changes;
|
|
cusp_index = index;
|
|
}
|
|
previous_forward = current_forward;
|
|
}
|
|
|
|
CHECK(direction_changes == 1);
|
|
CHECK(cusp_index > 0);
|
|
CHECK(cusp_index + 1 < path.size());
|
|
|
|
for (std::size_t index = 0; index < cusp_index; ++index)
|
|
{
|
|
CHECK(edgeIsForward(path[index], path[index + 1]) != terminal_forward);
|
|
}
|
|
for (std::size_t index = cusp_index; index + 1 < path.size(); ++index)
|
|
{
|
|
CHECK(edgeIsForward(path[index], path[index + 1]) == terminal_forward);
|
|
CHECK(std::fabs(lateral(path[index], goal)) < 1e-7);
|
|
CHECK(std::fabs(normalizeAngle(
|
|
data_convert::getYaw(path[index].orientation) -
|
|
data_convert::getYaw(goal.orientation))) < 1e-7);
|
|
}
|
|
|
|
for (std::size_t index = 1; index < cusp_index; ++index)
|
|
{
|
|
CHECK(threePointCurvature(path[index - 1], path[index], path[index + 1]) <=
|
|
maximum_curvature + 1e-5);
|
|
}
|
|
return cusp_index;
|
|
}
|
|
|
|
/**
|
|
* @brief Assert the no-cusp contract: one travel direction for the whole path,
|
|
* curvature within the Ackermann limit, and a straight tail on the goal
|
|
* axis at least @p straight_distance long.
|
|
*/
|
|
void checkDirectEntry(const std::vector<robot_geometry_msgs::Pose>& path,
|
|
const robot_geometry_msgs::Pose& goal,
|
|
double maximum_curvature,
|
|
bool terminal_forward,
|
|
double straight_distance)
|
|
{
|
|
CHECK(path.size() > 3);
|
|
for (std::size_t index = 0; index + 1 < path.size(); ++index)
|
|
{
|
|
CHECK(edgeIsForward(path[index], path[index + 1]) == terminal_forward);
|
|
}
|
|
for (std::size_t index = 1; index + 1 < path.size(); ++index)
|
|
{
|
|
CHECK(threePointCurvature(path[index - 1], path[index], path[index + 1]) <=
|
|
maximum_curvature + 1e-5);
|
|
}
|
|
|
|
std::size_t entry_index = path.size();
|
|
for (std::size_t index = 0; index < path.size(); ++index)
|
|
{
|
|
if (std::fabs(lateral(path[index], goal)) < 1e-7)
|
|
{
|
|
entry_index = index;
|
|
break;
|
|
}
|
|
}
|
|
CHECK(entry_index + 1 < path.size());
|
|
// Once the path reaches the axis it must stay on it, pointing at the goal.
|
|
for (std::size_t index = entry_index; index < path.size(); ++index)
|
|
{
|
|
CHECK(std::fabs(lateral(path[index], goal)) < 1e-7);
|
|
CHECK(std::fabs(normalizeAngle(
|
|
data_convert::getYaw(path[index].orientation) -
|
|
data_convert::getYaw(goal.orientation))) < 1e-7);
|
|
}
|
|
CHECK(std::fabs(longitudinal(path[entry_index], goal)) >= straight_distance - 1e-6);
|
|
}
|
|
|
|
/**
|
|
* @brief Assert the straight-pivot-straight contract: one straight leg, one
|
|
* explicit on-the-spot rotation, one straight terminal, one travel
|
|
* direction throughout.
|
|
*
|
|
* @param expected_vertex_distance where the rotation must happen, measured
|
|
* along the goal axis. It has to clear the swept circle, not just the
|
|
* mating extent, or a corner of the body hits the dock while it turns.
|
|
*/
|
|
void checkPivotPath(const std::vector<robot_geometry_msgs::Pose>& path,
|
|
const robot_geometry_msgs::Pose& goal,
|
|
bool terminal_forward,
|
|
double expected_vertex_distance)
|
|
{
|
|
CHECK(path.size() > 3);
|
|
const double goal_yaw = data_convert::getYaw(goal.orientation);
|
|
|
|
// Locate the run of poses that share a position: that is the rotation.
|
|
std::size_t block_start = path.size();
|
|
std::size_t block_end = 0;
|
|
for (std::size_t index = 1; index < path.size(); ++index)
|
|
{
|
|
if (std::hypot(path[index].position.x - path[index - 1].position.x,
|
|
path[index].position.y - path[index - 1].position.y) <= 1e-9)
|
|
{
|
|
if (block_start == path.size())
|
|
{
|
|
block_start = index - 1;
|
|
}
|
|
block_end = index;
|
|
}
|
|
}
|
|
CHECK(block_start < path.size());
|
|
// StanleyControl::planDivision only splits a rotation out of the plan after
|
|
// three consecutive same-position samples, so four poses is the hard floor.
|
|
// Fewer and the controller drives through the corner instead of turning.
|
|
CHECK(block_end >= block_start + 3);
|
|
|
|
for (std::size_t index = block_start; index <= block_end; ++index)
|
|
{
|
|
CHECK(std::fabs(lateral(path[index], goal)) < 1e-7);
|
|
CHECK(near(std::fabs(longitudinal(path[index], goal)),
|
|
expected_vertex_distance, 1e-6));
|
|
}
|
|
|
|
// Yaw steps one way only, never by less than the epsilon planDivision uses
|
|
// to decide two samples share a heading, and lands on the goal heading.
|
|
const double first_step = normalizeAngle(
|
|
data_convert::getYaw(path[block_start + 1].orientation) -
|
|
data_convert::getYaw(path[block_start].orientation));
|
|
CHECK(std::fabs(first_step) > 1e-6);
|
|
for (std::size_t index = block_start + 1; index <= block_end; ++index)
|
|
{
|
|
const double step = normalizeAngle(
|
|
data_convert::getYaw(path[index].orientation) -
|
|
data_convert::getYaw(path[index - 1].orientation));
|
|
CHECK(std::fabs(step) > 1e-6);
|
|
CHECK(step * first_step > 0.0);
|
|
}
|
|
CHECK(std::fabs(normalizeAngle(
|
|
data_convert::getYaw(path[block_end].orientation) - goal_yaw)) < 1e-7);
|
|
|
|
// One travel direction end to end: no cusp anywhere, which is the whole
|
|
// reason this shape is preferred over the single-cusp one.
|
|
for (std::size_t index = 0; index + 1 < path.size(); ++index)
|
|
{
|
|
if (std::hypot(path[index + 1].position.x - path[index].position.x,
|
|
path[index + 1].position.y - path[index].position.y) <= 1e-9)
|
|
{
|
|
continue;
|
|
}
|
|
CHECK(edgeIsForward(path[index], path[index + 1]) == terminal_forward);
|
|
}
|
|
|
|
// Terminal leg: on the axis and already at the goal heading.
|
|
for (std::size_t index = block_end; index < path.size(); ++index)
|
|
{
|
|
CHECK(std::fabs(lateral(path[index], goal)) < 1e-7);
|
|
CHECK(std::fabs(normalizeAngle(
|
|
data_convert::getYaw(path[index].orientation) - goal_yaw)) < 1e-7);
|
|
}
|
|
|
|
// The defining property: the path never reaches further away from the dock
|
|
// than the robot already stood, so it costs no extra aisle depth.
|
|
for (const auto& sample : path)
|
|
{
|
|
CHECK(std::fabs(longitudinal(sample, goal)) <=
|
|
std::fabs(longitudinal(path.front(), goal)) + 1e-9);
|
|
}
|
|
}
|
|
|
|
std::vector<robot_geometry_msgs::Pose> generatePath(
|
|
dock_planner::DockCalc& calculator,
|
|
const robot_geometry_msgs::PoseStamped& start,
|
|
const robot_geometry_msgs::PoseStamped& goal,
|
|
const std::vector<robot_geometry_msgs::Point>& robot_footprint,
|
|
const std::vector<robot_geometry_msgs::Point>& dock_footprint,
|
|
bool allow_stationary_block = false)
|
|
{
|
|
std::vector<robot_geometry_msgs::Pose> path;
|
|
CHECK(calculator.makePlanMoveToDock(start, goal, robot_footprint,
|
|
dock_footprint, path));
|
|
CHECK(path.size() > 3);
|
|
CHECK(near(path.front().position.x, start.pose.position.x));
|
|
CHECK(near(path.front().position.y, start.pose.position.y));
|
|
CHECK(near(path.back().position.x, goal.pose.position.x));
|
|
CHECK(near(path.back().position.y, goal.pose.position.y));
|
|
|
|
for (std::size_t index = 0; index < path.size(); ++index)
|
|
{
|
|
const auto& current = path[index];
|
|
CHECK(std::isfinite(current.position.x));
|
|
CHECK(std::isfinite(current.position.y));
|
|
CHECK(std::isfinite(current.orientation.z));
|
|
CHECK(std::isfinite(current.orientation.w));
|
|
// The pivot shape deliberately repeats a position while the body turns,
|
|
// so that check only applies to the shapes made of motion alone.
|
|
if (index > 0 && !allow_stationary_block)
|
|
{
|
|
CHECK(std::hypot(current.position.x - path[index - 1].position.x,
|
|
current.position.y - path[index - 1].position.y) > 1e-9);
|
|
}
|
|
}
|
|
return path;
|
|
}
|
|
|
|
dock_planner::DockPlannerConfig apmConfig()
|
|
{
|
|
dock_planner::DockPlannerConfig config;
|
|
config.wheel_base = 1.3268;
|
|
config.max_steering_angle = 0.50;
|
|
config.path_point_spacing = 0.05;
|
|
// The cusp cases below have to keep exercising the cusp: several of their
|
|
// starts are far enough that the direct entry would take over.
|
|
config.direct_entry_min_curve_room = 0.0;
|
|
return config;
|
|
}
|
|
|
|
void testConfig()
|
|
{
|
|
dock_planner::DockPlannerConfig config;
|
|
std::string error;
|
|
CHECK(config.validate(error));
|
|
CHECK(error.empty());
|
|
CHECK(std::isnan(config.minimumTurningRadius()));
|
|
CHECK(near(config.pivot_backoff_max_distance, 0.0));
|
|
CHECK(!config.pivot_check_costmap);
|
|
|
|
config.wheel_base = 1.3268;
|
|
CHECK(near(config.minimumTurningRadius(),
|
|
config.wheel_base / std::tan(config.max_steering_angle)));
|
|
|
|
config.max_steering_angle = 0.0;
|
|
CHECK(!config.validate(error));
|
|
config = dock_planner::DockPlannerConfig{};
|
|
config.front_axle_frame = config.rear_axle_frame;
|
|
CHECK(!config.validate(error));
|
|
config = dock_planner::DockPlannerConfig{};
|
|
config.maximum_forward_extension = config.minimum_forward_distance - 0.01;
|
|
CHECK(!config.validate(error));
|
|
config = dock_planner::DockPlannerConfig{};
|
|
config.path_point_spacing = std::numeric_limits<double>::quiet_NaN();
|
|
CHECK(!config.validate(error));
|
|
config = dock_planner::DockPlannerConfig{};
|
|
config.pivot_fallback_extension = -0.01;
|
|
CHECK(!config.validate(error));
|
|
config = dock_planner::DockPlannerConfig{};
|
|
config.pivot_safety_margin = -0.01;
|
|
CHECK(!config.validate(error));
|
|
for (const auto anchor : {dock_planner::DockAnchor::kCenter,
|
|
dock_planner::DockAnchor::kFace})
|
|
{
|
|
config = dock_planner::DockPlannerConfig{};
|
|
config.dock_anchor = anchor;
|
|
config.dock_face_offset = 0.4;
|
|
CHECK(!config.validate(error));
|
|
CHECK(error.find("dock_face_offset is only valid with dock_anchor: mating_edge") !=
|
|
std::string::npos);
|
|
CHECK(error.find(anchor == dock_planner::DockAnchor::kCenter ? "got center" : "got face") !=
|
|
std::string::npos);
|
|
}
|
|
config = dock_planner::DockPlannerConfig{};
|
|
config.dock_anchor = dock_planner::DockAnchor::kMatingEdge;
|
|
config.dock_face_offset = 0.0;
|
|
CHECK(!config.validate(error));
|
|
config.dock_face_offset = -0.01;
|
|
CHECK(!config.validate(error));
|
|
config.dock_face_offset = std::numeric_limits<double>::quiet_NaN();
|
|
CHECK(!config.validate(error));
|
|
config.dock_face_offset = 2.01;
|
|
CHECK(!config.validate(error));
|
|
config.dock_face_offset.reset();
|
|
config.dock_pivot_safety_margin = -0.01;
|
|
CHECK(!config.validate(error));
|
|
config.dock_pivot_safety_margin = std::numeric_limits<double>::quiet_NaN();
|
|
CHECK(!config.validate(error));
|
|
config.dock_pivot_safety_margin = 1.01;
|
|
CHECK(!config.validate(error));
|
|
|
|
// YAML null is the marker-binding clear value and must load exactly like an absent key.
|
|
robot::NodeHandle planner_nh;
|
|
planner_nh.setParam("dock_anchor", YAML::Node("mating_edge"));
|
|
planner_nh.setParam("dock_face_offset", YAML::Node(YAML::NodeType::Null));
|
|
planner_nh.setParam("dock_pivot_safety_margin", YAML::Node(YAML::NodeType::Null));
|
|
dock_planner::DockPlannerConfig loaded;
|
|
CHECK(dock_planner::DockPlannerConfig::load(planner_nh, loaded, error));
|
|
CHECK(!loaded.dock_face_offset.has_value());
|
|
CHECK(!loaded.dock_pivot_safety_margin.has_value());
|
|
|
|
planner_nh.setParam("dock_face_offset", 0.4);
|
|
planner_nh.setParam("dock_pivot_safety_margin", 0.1);
|
|
CHECK(dock_planner::DockPlannerConfig::load(planner_nh, loaded, error));
|
|
CHECK(loaded.dock_face_offset.has_value() && near(*loaded.dock_face_offset, 0.4));
|
|
CHECK(loaded.dock_pivot_safety_margin.has_value() &&
|
|
near(*loaded.dock_pivot_safety_margin, 0.1));
|
|
planner_nh.setParam("dock_anchor", YAML::Node("face"));
|
|
CHECK(!dock_planner::DockPlannerConfig::load(planner_nh, loaded, error));
|
|
CHECK(error.find("dock_face_offset is only valid with dock_anchor: mating_edge (got face)") !=
|
|
std::string::npos);
|
|
config = dock_planner::DockPlannerConfig{};
|
|
config.pivot_backoff_max_distance = -0.01;
|
|
CHECK(!config.validate(error));
|
|
config = dock_planner::DockPlannerConfig{};
|
|
config.pivot_backoff_max_distance = 3.01;
|
|
CHECK(!config.validate(error));
|
|
config = dock_planner::DockPlannerConfig{};
|
|
config.pivot_backoff_max_distance = std::numeric_limits<double>::infinity();
|
|
CHECK(!config.validate(error));
|
|
config = dock_planner::DockPlannerConfig{};
|
|
config.pivot_backoff_max_distance = 3.0;
|
|
CHECK(config.validate(error));
|
|
|
|
// A differential base has no steered axle, so empty axle frames and a zero
|
|
// steering angle must NOT stop it loading -- validating them there would
|
|
// reject a perfectly valid robot.
|
|
config = dock_planner::DockPlannerConfig{};
|
|
config.kinematic_model = dock_planner::KinematicModel::kDifferential;
|
|
config.max_steering_angle = 0.0;
|
|
config.front_axle_frame.clear();
|
|
config.rear_axle_frame.clear();
|
|
CHECK(config.validate(error));
|
|
CHECK(!config.requiresAxleTf());
|
|
// 0 is the answer, not a failure: it is what allows turning on the spot.
|
|
CHECK(near(config.minimumTurningRadius(), 0.0));
|
|
|
|
config.minimum_turning_radius = -0.1;
|
|
CHECK(!config.validate(error));
|
|
config.minimum_turning_radius = 1.5;
|
|
CHECK(config.validate(error));
|
|
CHECK(near(config.minimumTurningRadius(), 1.5));
|
|
|
|
// Ackermann still needs its axle TF resolved before it can plan.
|
|
config = dock_planner::DockPlannerConfig{};
|
|
CHECK(config.requiresAxleTf());
|
|
}
|
|
|
|
/** Footprint of the APM reference robot: 1.65 m of nose, 0.35 m of tail. */
|
|
std::vector<robot_geometry_msgs::Point> apmFootprint()
|
|
{
|
|
return {point(1.65, -0.40), point(1.65, 0.40),
|
|
point(-0.35, 0.40), point(-0.35, -0.40)};
|
|
}
|
|
|
|
std::vector<robot_geometry_msgs::Point> apmDockFootprint()
|
|
{
|
|
return {point(0.50, -0.40), point(0.50, 0.40),
|
|
point(-0.50, 0.40), point(-0.50, -0.40)};
|
|
}
|
|
|
|
std::vector<robot_geometry_msgs::Point> robotFootprint065x069()
|
|
{
|
|
return {point(0.325, -0.345), point(0.325, 0.345),
|
|
point(-0.325, 0.345), point(-0.325, -0.345)};
|
|
}
|
|
|
|
dock_planner::DockPlannerConfig differentialBackoffConfig()
|
|
{
|
|
dock_planner::DockPlannerConfig config;
|
|
config.kinematic_model = dock_planner::KinematicModel::kDifferential;
|
|
config.minimum_turning_radius = 1.0;
|
|
config.maximum_forward_extension = 0.5;
|
|
config.direct_entry_min_curve_room = 0.3;
|
|
config.pivot_fallback_extension = 1.2;
|
|
config.pivot_safety_margin = 0.15;
|
|
config.straight_length = 0.4;
|
|
config.path_point_spacing = 0.05;
|
|
return config;
|
|
}
|
|
|
|
void checkBackoffPivotPath(const std::vector<robot_geometry_msgs::Pose>& path,
|
|
const robot_geometry_msgs::PoseStamped& start,
|
|
const robot_geometry_msgs::PoseStamped& goal,
|
|
double pivot_vertex_distance)
|
|
{
|
|
CHECK(path.size() > 12);
|
|
CHECK(samePoseExactly(path.front(), start.pose));
|
|
CHECK(samePoseExactly(path.back(), goal.pose));
|
|
|
|
const double start_yaw = data_convert::getYaw(start.pose.orientation);
|
|
std::size_t first_rotation_begin = path.size();
|
|
for (std::size_t index = 1; index < path.size(); ++index)
|
|
{
|
|
const bool same_position =
|
|
std::hypot(path[index].position.x - path[index - 1].position.x,
|
|
path[index].position.y - path[index - 1].position.y) <= 1e-9;
|
|
const double yaw_change = normalizeAngle(
|
|
data_convert::getYaw(path[index].orientation) -
|
|
data_convert::getYaw(path[index - 1].orientation));
|
|
if (same_position && std::fabs(yaw_change) > 1e-6)
|
|
{
|
|
first_rotation_begin = index - 1;
|
|
break;
|
|
}
|
|
}
|
|
CHECK(first_rotation_begin > 0);
|
|
CHECK(first_rotation_begin < path.size());
|
|
if (first_rotation_begin >= path.size())
|
|
{
|
|
return;
|
|
}
|
|
|
|
double previous_longitudinal = longitudinal(path.front(), goal.pose);
|
|
for (std::size_t index = 0; index <= first_rotation_begin; ++index)
|
|
{
|
|
CHECK(std::fabs(normalizeAngle(
|
|
data_convert::getYaw(path[index].orientation) - start_yaw)) < 1e-7);
|
|
const double current_longitudinal = longitudinal(path[index], goal.pose);
|
|
CHECK(current_longitudinal + 1e-8 >= previous_longitudinal);
|
|
previous_longitudinal = current_longitudinal;
|
|
}
|
|
CHECK(longitudinal(path[first_rotation_begin], goal.pose) >=
|
|
pivot_vertex_distance + 0.05 - 1e-7);
|
|
|
|
int rotation_blocks = 0;
|
|
bool in_rotation = false;
|
|
std::size_t last_rotation_end = 0;
|
|
for (std::size_t index = 1; index < path.size(); ++index)
|
|
{
|
|
const bool same_position =
|
|
std::hypot(path[index].position.x - path[index - 1].position.x,
|
|
path[index].position.y - path[index - 1].position.y) <= 1e-9;
|
|
const double yaw_change = normalizeAngle(
|
|
data_convert::getYaw(path[index].orientation) -
|
|
data_convert::getYaw(path[index - 1].orientation));
|
|
if (same_position && std::fabs(yaw_change) > 1e-6)
|
|
{
|
|
if (!in_rotation)
|
|
{
|
|
++rotation_blocks;
|
|
}
|
|
in_rotation = true;
|
|
last_rotation_end = index;
|
|
}
|
|
else if (!same_position)
|
|
{
|
|
in_rotation = false;
|
|
}
|
|
}
|
|
CHECK(rotation_blocks >= 2);
|
|
CHECK(last_rotation_end + 1 < path.size());
|
|
for (std::size_t index = last_rotation_end; index + 1 < path.size(); ++index)
|
|
{
|
|
CHECK(!edgeIsForward(path[index], path[index + 1]));
|
|
CHECK(std::fabs(lateral(path[index], goal.pose)) < 1e-7);
|
|
CHECK(std::fabs(normalizeAngle(
|
|
data_convert::getYaw(path[index].orientation) -
|
|
data_convert::getYaw(goal.pose.orientation))) < 1e-7);
|
|
}
|
|
}
|
|
|
|
void testBackoffPivotRobotFailures()
|
|
{
|
|
const auto robot_footprint = robotFootprint065x069();
|
|
const std::vector<robot_geometry_msgs::Point> no_dock_footprint;
|
|
const auto goal = pose(0.0, 0.0, 0.0);
|
|
const double pivot_vertex = std::hypot(0.325, 0.345) + 0.15;
|
|
const std::vector<robot_geometry_msgs::PoseStamped> starts = {
|
|
pose(0.579, 0.292, 0.0),
|
|
pose(0.427, 0.155, 0.0),
|
|
// 29/10 15:36: 0.375 m out and yawed about 10 deg, so a rear corner
|
|
// projects behind the goal line. A removed start-footprint check
|
|
// rejected this although the real charger face was 0.45 m away.
|
|
pose(0.375, -0.149, 0.17),
|
|
};
|
|
|
|
for (const auto& start : starts)
|
|
{
|
|
auto config = differentialBackoffConfig();
|
|
dock_planner::DockCalc disabled(config);
|
|
std::vector<robot_geometry_msgs::Pose> failed_path;
|
|
CHECK(!disabled.makePlanMoveToDock(start, goal, robot_footprint,
|
|
no_dock_footprint, failed_path));
|
|
CHECK(failed_path.empty());
|
|
|
|
config.pivot_backoff_max_distance = 1.0;
|
|
dock_planner::DockCalc enabled(config);
|
|
std::vector<robot_geometry_msgs::Pose> path;
|
|
CHECK(enabled.makePlanMoveToDock(start, goal, robot_footprint,
|
|
no_dock_footprint, path));
|
|
checkBackoffPivotPath(path, start, goal, pivot_vertex);
|
|
}
|
|
}
|
|
|
|
void testMatingEdgeAnchor()
|
|
{
|
|
// KIT charger: the detector already offsets the goal to the docked
|
|
// base_link pose, so the charger face is at the robot's rear edge there.
|
|
const auto robot_footprint = robotFootprint065x069();
|
|
const std::vector<robot_geometry_msgs::Point> no_dock_footprint;
|
|
const auto goal = pose(0.0, 0.0, 0.0);
|
|
const double circumscribed = std::hypot(0.325, 0.345);
|
|
const double face_vertex = circumscribed + 0.15;
|
|
// max(straight_length 0.4, 0.474 - 0.325 + 0.15 = 0.299)
|
|
const double mating_vertex = std::max(0.4, circumscribed - 0.325 + 0.15);
|
|
CHECK(near(mating_vertex, 0.4));
|
|
|
|
auto face_config = differentialBackoffConfig();
|
|
face_config.dock_anchor = dock_planner::DockAnchor::kFace;
|
|
face_config.pivot_backoff_max_distance = 1.0;
|
|
auto mating_config = face_config;
|
|
mating_config.dock_anchor = dock_planner::DockAnchor::kMatingEdge;
|
|
dock_planner::DockCalc face_calc(face_config);
|
|
dock_planner::DockCalc mating_calc(mating_config);
|
|
|
|
// The two 29/10 starts that needed a back-off with face now pivot in place
|
|
// at 0.4 m, with no back-off leg.
|
|
for (const auto& start : {pose(0.579, 0.292, 0.0), pose(0.427, 0.155, 0.0)})
|
|
{
|
|
std::vector<robot_geometry_msgs::Pose> path;
|
|
CHECK(mating_calc.makePlanMoveToDock(start, goal, robot_footprint,
|
|
no_dock_footprint, path));
|
|
checkPivotPath(path, goal.pose, false, mating_vertex);
|
|
}
|
|
|
|
// 29/10 15:36 start: still closer than the vertex, so it backs off, but
|
|
// only to vertex + spacing (0.45 m) instead of 0.674 m.
|
|
const auto close_start = pose(0.375, -0.149, 0.17);
|
|
std::vector<robot_geometry_msgs::Pose> face_path;
|
|
std::vector<robot_geometry_msgs::Pose> mating_path;
|
|
CHECK(face_calc.makePlanMoveToDock(close_start, goal, robot_footprint,
|
|
no_dock_footprint, face_path));
|
|
CHECK(mating_calc.makePlanMoveToDock(close_start, goal, robot_footprint,
|
|
no_dock_footprint, mating_path));
|
|
checkBackoffPivotPath(face_path, close_start, goal, face_vertex);
|
|
checkBackoffPivotPath(mating_path, close_start, goal, mating_vertex);
|
|
double furthest = 0.0;
|
|
for (const auto& path_pose : mating_path)
|
|
{
|
|
furthest = std::max(furthest, longitudinal(path_pose, goal.pose));
|
|
}
|
|
CHECK(furthest < mating_vertex + 0.05 + 1e-6);
|
|
CHECK(mating_path.size() < face_path.size());
|
|
}
|
|
|
|
void testMatingEdgeFaceOffset()
|
|
{
|
|
const auto robot_footprint = robotFootprint065x069();
|
|
const std::vector<robot_geometry_msgs::Point> no_dock_footprint;
|
|
const auto goal = pose(0.0, 0.0, 0.0);
|
|
const double circumscribed = std::hypot(0.325, 0.345);
|
|
|
|
auto config = differentialBackoffConfig();
|
|
config.minimum_turning_radius = 0.0;
|
|
config.direct_entry_min_curve_room = 0.0;
|
|
config.straight_length = 0.2;
|
|
config.dock_anchor = dock_planner::DockAnchor::kMatingEdge;
|
|
config.dock_face_offset = 0.40;
|
|
config.dock_pivot_safety_margin = 0.10;
|
|
const double kit_minimum_cusp_distance = std::max(
|
|
std::max(0.325 - *config.dock_face_offset, 0.0) +
|
|
config.reverse_distance_padding,
|
|
config.path_point_spacing);
|
|
const double kit_straight_distance =
|
|
std::max(kit_minimum_cusp_distance, config.straight_length);
|
|
CHECK(near(kit_minimum_cusp_distance, 0.05));
|
|
CHECK(near(kit_straight_distance, 0.2));
|
|
const double kit_vertex = std::max(
|
|
kit_straight_distance,
|
|
circumscribed - *config.dock_face_offset +
|
|
*config.dock_pivot_safety_margin);
|
|
CHECK(near(kit_vertex, 0.2));
|
|
|
|
dock_planner::DockCalc kit_calculator(config);
|
|
for (const auto& start : {pose(0.579, 0.292, 0.0),
|
|
pose(0.427, 0.155, 0.0),
|
|
pose(0.375, -0.149, 0.17)})
|
|
{
|
|
std::vector<robot_geometry_msgs::Pose> path;
|
|
CHECK(kit_calculator.makePlanMoveToDock(start, goal, robot_footprint,
|
|
no_dock_footprint, path));
|
|
checkPivotPath(path, goal.pose, false, kit_vertex);
|
|
bool checked_terminal_length = false;
|
|
for (std::size_t index = 1; index < path.size(); ++index)
|
|
{
|
|
if (std::hypot(path[index].position.x - path[index - 1].position.x,
|
|
path[index].position.y - path[index - 1].position.y) <= 1e-9)
|
|
{
|
|
CHECK(near(std::fabs(longitudinal(path[index], goal.pose)), 0.2));
|
|
checked_terminal_length = true;
|
|
break;
|
|
}
|
|
}
|
|
CHECK(checked_terminal_length);
|
|
// The pivot lies between every start and the goal, so none of these paths backs off.
|
|
CHECK(longitudinal(path.front(), goal.pose) > kit_vertex);
|
|
}
|
|
|
|
// With no explicit offset, the mating edge remains the assumed face. A short
|
|
// terminal is therefore raised to the rotation-clearance vertex, 0.299 m.
|
|
config.dock_face_offset.reset();
|
|
config.dock_pivot_safety_margin.reset();
|
|
config.straight_length = 0.1;
|
|
const double default_offset_vertex = std::max(
|
|
config.straight_length,
|
|
circumscribed - 0.325 + config.pivot_safety_margin);
|
|
CHECK(near(default_offset_vertex, 0.299, 1e-3));
|
|
dock_planner::DockCalc default_offset_calculator(config);
|
|
std::vector<robot_geometry_msgs::Pose> default_offset_path;
|
|
CHECK(default_offset_calculator.makePlanMoveToDock(
|
|
pose(0.579, 0.292, 0.0), goal, robot_footprint,
|
|
no_dock_footprint, default_offset_path));
|
|
checkPivotPath(default_offset_path, goal.pose, false, default_offset_vertex);
|
|
}
|
|
|
|
void testDockPivotSafetyMarginOverride()
|
|
{
|
|
const auto robot_footprint = robotFootprint065x069();
|
|
const std::vector<robot_geometry_msgs::Point> trolley_footprint = {
|
|
point(0.375, -0.2735), point(0.375, 0.2735),
|
|
point(-0.375, 0.2735), point(-0.375, -0.2735)};
|
|
const auto start = pose(1.6, 0.4, 0.0);
|
|
const auto goal = pose(0.0, 0.0, 0.0);
|
|
const double circumscribed = std::hypot(0.325, 0.345);
|
|
|
|
auto center_config = differentialBackoffConfig();
|
|
center_config.minimum_turning_radius = 0.0;
|
|
center_config.direct_entry_min_curve_room = 0.0;
|
|
center_config.straight_length = 0.2;
|
|
center_config.dock_anchor = dock_planner::DockAnchor::kCenter;
|
|
center_config.dock_pivot_safety_margin.reset();
|
|
center_config.dock_face_offset.reset();
|
|
|
|
// With neither optional key set, preserve the prior center-anchor path pose for pose.
|
|
dock_planner::DockCalc center_default(center_config);
|
|
std::vector<robot_geometry_msgs::Pose> center_default_path;
|
|
CHECK(center_default.makePlanMoveToDock(start, goal, robot_footprint,
|
|
trolley_footprint, center_default_path));
|
|
auto center_no_keys_config = center_config;
|
|
center_no_keys_config.dock_face_offset.reset();
|
|
center_no_keys_config.dock_pivot_safety_margin.reset();
|
|
dock_planner::DockCalc center_no_keys(center_no_keys_config);
|
|
std::vector<robot_geometry_msgs::Pose> center_no_keys_path;
|
|
CHECK(center_no_keys.makePlanMoveToDock(start, goal, robot_footprint,
|
|
trolley_footprint, center_no_keys_path));
|
|
CHECK(pathsEqualExactly(center_default_path, center_no_keys_path));
|
|
|
|
const std::vector<robot_geometry_msgs::Point> no_dock_footprint;
|
|
auto face_config = center_config;
|
|
face_config.dock_anchor = dock_planner::DockAnchor::kFace;
|
|
dock_planner::DockCalc face_default(face_config);
|
|
std::vector<robot_geometry_msgs::Pose> face_default_path;
|
|
CHECK(face_default.makePlanMoveToDock(start, goal, robot_footprint,
|
|
no_dock_footprint, face_default_path));
|
|
|
|
// DockCalc itself also ignores an invalid non-mating-edge override. Plugin validation below
|
|
// still rejects these configs before initialize() succeeds.
|
|
for (const auto anchor : {dock_planner::DockAnchor::kCenter,
|
|
dock_planner::DockAnchor::kFace})
|
|
{
|
|
auto rejected_config = center_config;
|
|
rejected_config.dock_anchor = anchor;
|
|
rejected_config.dock_pivot_safety_margin = 0.10;
|
|
std::string error;
|
|
CHECK(!rejected_config.validate(error));
|
|
CHECK(error.find("dock_pivot_safety_margin is only valid with dock_anchor: mating_edge") !=
|
|
std::string::npos);
|
|
CHECK(error.find(anchor == dock_planner::DockAnchor::kCenter ? "got center" : "got face") !=
|
|
std::string::npos);
|
|
|
|
// DockCalc validates its config before planning, so an override declared on
|
|
// center/face is refused there too: no path, rather than a silently ignored key.
|
|
dock_planner::DockCalc refused_override(rejected_config);
|
|
std::vector<robot_geometry_msgs::Pose> refused_override_path;
|
|
const auto& dock_footprint = anchor == dock_planner::DockAnchor::kCenter
|
|
? trolley_footprint
|
|
: no_dock_footprint;
|
|
CHECK(!refused_override.makePlanMoveToDock(
|
|
start, goal, robot_footprint, dock_footprint, refused_override_path));
|
|
CHECK(refused_override_path.empty());
|
|
}
|
|
|
|
auto mating_config = center_config;
|
|
mating_config.dock_anchor = dock_planner::DockAnchor::kMatingEdge;
|
|
mating_config.dock_face_offset = 0.40;
|
|
mating_config.straight_length = 0.1;
|
|
mating_config.dock_pivot_safety_margin.reset();
|
|
std::string mating_config_error;
|
|
CHECK(mating_config.validate(mating_config_error));
|
|
dock_planner::DockCalc mating_default(mating_config);
|
|
std::vector<robot_geometry_msgs::Pose> mating_default_path;
|
|
CHECK(mating_default.makePlanMoveToDock(
|
|
pose(0.579, 0.292, 0.0), goal, robot_footprint, {}, mating_default_path));
|
|
|
|
mating_config.dock_pivot_safety_margin = 0.10;
|
|
dock_planner::DockCalc overridden(mating_config);
|
|
std::vector<robot_geometry_msgs::Pose> overridden_path;
|
|
CHECK(overridden.makePlanMoveToDock(
|
|
pose(0.579, 0.292, 0.0), goal, robot_footprint, {}, overridden_path));
|
|
const double face_offset = 0.40;
|
|
const double straight_distance = 0.1;
|
|
const double default_vertex = std::max(
|
|
straight_distance,
|
|
circumscribed - face_offset + center_config.pivot_safety_margin);
|
|
const double override_vertex = std::max(
|
|
straight_distance, circumscribed - face_offset + 0.10);
|
|
CHECK(near(default_vertex, 0.224, 1e-3));
|
|
CHECK(near(override_vertex, 0.174, 1e-3));
|
|
checkPivotPath(mating_default_path, goal.pose, false, default_vertex);
|
|
checkPivotPath(overridden_path, goal.pose, false, override_vertex);
|
|
CHECK(!pathsEqualExactly(mating_default_path, overridden_path));
|
|
}
|
|
|
|
void testExistingPlansUnchangedByBackoff()
|
|
{
|
|
const auto robot_footprint = apmFootprint();
|
|
const auto dock_footprint = apmDockFootprint();
|
|
const auto goal = pose(0.0, 0.0, 0.0);
|
|
|
|
struct Case
|
|
{
|
|
dock_planner::DockPlannerConfig config;
|
|
robot_geometry_msgs::PoseStamped start;
|
|
};
|
|
std::vector<Case> cases;
|
|
|
|
auto cusp_config = apmConfig();
|
|
cases.push_back({cusp_config, pose(2.8, 0.6, -1.2)});
|
|
cases.push_back({cusp_config, pose(-2.8, 0.6, 0.0)});
|
|
|
|
auto direct_config = apmConfig();
|
|
direct_config.direct_entry_min_curve_room = 0.5;
|
|
cases.push_back({direct_config, pose(2.8, 0.6, -1.2)});
|
|
cases.push_back({direct_config, pose(-4.0, 0.6, 0.0)});
|
|
|
|
auto pivot_config = apmConfig();
|
|
pivot_config.pivot_fallback_extension = 1.0;
|
|
cases.push_back({pivot_config, pose(2.8, 0.6, -1.2)});
|
|
cases.push_back({pivot_config, pose(-2.8, 0.6, 0.0)});
|
|
|
|
for (const auto& test_case : cases)
|
|
{
|
|
auto baseline_config = test_case.config;
|
|
baseline_config.pivot_backoff_max_distance = 0.0;
|
|
baseline_config.pivot_check_costmap = false;
|
|
auto candidate_config = baseline_config;
|
|
candidate_config.pivot_backoff_max_distance = 1.0;
|
|
|
|
dock_planner::DockCalc baseline(baseline_config);
|
|
dock_planner::DockCalc candidate(candidate_config);
|
|
std::vector<robot_geometry_msgs::Pose> baseline_path;
|
|
std::vector<robot_geometry_msgs::Pose> candidate_path;
|
|
CHECK(baseline.makePlanMoveToDock(test_case.start, goal, robot_footprint,
|
|
dock_footprint, baseline_path));
|
|
CHECK(candidate.makePlanMoveToDock(test_case.start, goal, robot_footprint,
|
|
dock_footprint, candidate_path));
|
|
// A key-zero plan is the pre-feature behavior: the fallback is only
|
|
// reached after every old ladder candidate fails. Exact field equality
|
|
// catches even changes to sampling, quaternion signs, or endpoints.
|
|
CHECK(pathsEqualExactly(baseline_path, candidate_path));
|
|
}
|
|
}
|
|
|
|
void testBackoffPivotGates()
|
|
{
|
|
const auto robot_footprint = robotFootprint065x069();
|
|
const std::vector<robot_geometry_msgs::Point> no_dock_footprint;
|
|
const auto goal = pose(0.0, 0.0, 0.0);
|
|
auto config = differentialBackoffConfig();
|
|
config.pivot_backoff_max_distance = 1.0;
|
|
|
|
dock_planner::DockCalc perpendicular(config);
|
|
std::vector<robot_geometry_msgs::Pose> path;
|
|
CHECK(!perpendicular.makePlanMoveToDock(
|
|
pose(0.579, 0.292, kPi / 2.0), goal, robot_footprint,
|
|
no_dock_footprint, path));
|
|
CHECK(path.empty());
|
|
|
|
config.pivot_backoff_max_distance = 0.3;
|
|
dock_planner::DockCalc too_far(config);
|
|
CHECK(!too_far.makePlanMoveToDock(
|
|
pose(0.1, 0.4, 0.0), goal, robot_footprint,
|
|
no_dock_footprint, path));
|
|
CHECK(path.empty());
|
|
|
|
auto ackermann_config = config;
|
|
ackermann_config.kinematic_model = dock_planner::KinematicModel::kAckermann;
|
|
ackermann_config.wheel_base = std::tan(0.5);
|
|
ackermann_config.max_steering_angle = 0.5;
|
|
dock_planner::DockCalc ackermann(ackermann_config);
|
|
CHECK(!ackermann.makePlanMoveToDock(
|
|
pose(0.579, 0.292, 0.0), goal, robot_footprint,
|
|
no_dock_footprint, path));
|
|
CHECK(path.empty());
|
|
}
|
|
|
|
void testCostmapCheckCallbacks()
|
|
{
|
|
const auto robot_footprint = robotFootprint065x069();
|
|
const std::vector<robot_geometry_msgs::Point> no_dock_footprint;
|
|
const auto goal = pose(0.0, 0.0, 0.0);
|
|
const auto start = pose(0.579, 0.292, 0.0);
|
|
auto config = differentialBackoffConfig();
|
|
config.pivot_backoff_max_distance = 1.0;
|
|
config.pivot_check_costmap = true;
|
|
const double expected_rotation_radius =
|
|
std::hypot(0.325, 0.345) + config.pivot_safety_margin;
|
|
|
|
int rotation_calls = 0;
|
|
dock_planner::DockCalc rotation_blocked(config);
|
|
rotation_blocked.setCostmapCheckCallbacks(
|
|
[&rotation_calls, expected_rotation_radius](
|
|
const robot_geometry_msgs::Pose&, double radius)
|
|
{
|
|
++rotation_calls;
|
|
CHECK(near(radius, expected_rotation_radius));
|
|
return false;
|
|
},
|
|
[](const robot_geometry_msgs::Pose&) { return true; });
|
|
std::vector<robot_geometry_msgs::Pose> path;
|
|
CHECK(!rotation_blocked.makePlanMoveToDock(
|
|
start, goal, robot_footprint, no_dock_footprint, path));
|
|
CHECK(path.empty());
|
|
CHECK(rotation_calls > 0);
|
|
|
|
int footprint_calls = 0;
|
|
dock_planner::DockCalc footprint_blocked(config);
|
|
footprint_blocked.setCostmapCheckCallbacks(
|
|
[](const robot_geometry_msgs::Pose&, double) { return true; },
|
|
[&footprint_calls](const robot_geometry_msgs::Pose& sample)
|
|
{
|
|
++footprint_calls;
|
|
return !(sample.position.x > 0.60 && sample.position.x < 0.67 &&
|
|
sample.position.y > 0.25 && sample.position.y < 0.33);
|
|
});
|
|
CHECK(!footprint_blocked.makePlanMoveToDock(
|
|
start, goal, robot_footprint, no_dock_footprint, path));
|
|
CHECK(path.empty());
|
|
CHECK(footprint_calls > 0);
|
|
|
|
int start_pose_checks = 0;
|
|
dock_planner::DockCalc start_pose_skipped(config);
|
|
start_pose_skipped.setCostmapCheckCallbacks(
|
|
[](const robot_geometry_msgs::Pose&, double) { return true; },
|
|
[&start_pose_checks, &start](const robot_geometry_msgs::Pose& sample)
|
|
{
|
|
if (near(sample.position.x, start.pose.position.x) &&
|
|
near(sample.position.y, start.pose.position.y))
|
|
{
|
|
++start_pose_checks;
|
|
return false;
|
|
}
|
|
return true;
|
|
});
|
|
CHECK(start_pose_skipped.makePlanMoveToDock(
|
|
start, goal, robot_footprint, no_dock_footprint, path));
|
|
CHECK(start_pose_checks == 0);
|
|
|
|
// A blocked old pivot falls through to the old cusp when that cusp remains
|
|
// feasible, proving the check also gates straight_pivot_straight.
|
|
auto old_pivot_config = apmConfig();
|
|
old_pivot_config.wheel_base = std::tan(0.5);
|
|
old_pivot_config.max_steering_angle = 0.5;
|
|
old_pivot_config.maximum_forward_extension = 3.0;
|
|
old_pivot_config.pivot_fallback_extension = 0.5;
|
|
old_pivot_config.pivot_check_costmap = true;
|
|
dock_planner::DockCalc old_pivot(old_pivot_config);
|
|
old_pivot.setCostmapCheckCallbacks(
|
|
[](const robot_geometry_msgs::Pose&, double) { return false; },
|
|
[](const robot_geometry_msgs::Pose&) { return true; });
|
|
const auto old_pivot_path = generatePath(
|
|
old_pivot, pose(2.8, 0.6, -1.2), goal, apmFootprint(),
|
|
apmDockFootprint());
|
|
checkSingleCuspPath(old_pivot_path, goal.pose, 1.0, false);
|
|
|
|
// A lethal cell in the terminal corridor is expected at the charger/dock
|
|
// interface. Pivot approach legs and rotation remain clear, so the old
|
|
// pivot plan must stay exactly the same as with the check switched off.
|
|
auto terminal_pivot_config = apmConfig();
|
|
terminal_pivot_config.kinematic_model =
|
|
dock_planner::KinematicModel::kDifferential;
|
|
terminal_pivot_config.minimum_turning_radius = 0.0;
|
|
const auto terminal_pivot_start = pose(2.8, 0.6, -1.2);
|
|
dock_planner::DockCalc terminal_pivot_unchecked(terminal_pivot_config);
|
|
std::vector<robot_geometry_msgs::Pose> terminal_pivot_baseline;
|
|
CHECK(terminal_pivot_unchecked.makePlanMoveToDock(
|
|
terminal_pivot_start, goal, apmFootprint(), apmDockFootprint(),
|
|
terminal_pivot_baseline));
|
|
checkPivotPath(terminal_pivot_baseline, goal.pose, false,
|
|
std::hypot(1.65, 0.40) + 0.50 +
|
|
terminal_pivot_config.pivot_safety_margin);
|
|
|
|
terminal_pivot_config.pivot_check_costmap = true;
|
|
const double terminal_pivot_distance = std::max(
|
|
0.35 + 0.50 + terminal_pivot_config.reverse_distance_padding,
|
|
terminal_pivot_config.straight_length);
|
|
dock_planner::DockCalc terminal_pivot_checked(terminal_pivot_config);
|
|
terminal_pivot_checked.setCostmapCheckCallbacks(
|
|
[](const robot_geometry_msgs::Pose&, double) { return true; },
|
|
[&goal, terminal_pivot_distance](const robot_geometry_msgs::Pose& sample)
|
|
{
|
|
return std::hypot(sample.position.x - goal.pose.position.x,
|
|
sample.position.y - goal.pose.position.y) >
|
|
terminal_pivot_distance;
|
|
});
|
|
std::vector<robot_geometry_msgs::Pose> terminal_pivot_path;
|
|
CHECK(terminal_pivot_checked.makePlanMoveToDock(
|
|
terminal_pivot_start, goal, apmFootprint(), apmDockFootprint(),
|
|
terminal_pivot_path));
|
|
checkPivotPath(terminal_pivot_path, goal.pose, false,
|
|
std::hypot(1.65, 0.40) + 0.50 +
|
|
terminal_pivot_config.pivot_safety_margin);
|
|
CHECK(pathsEqualExactly(terminal_pivot_baseline, terminal_pivot_path));
|
|
|
|
auto check_off_config = differentialBackoffConfig();
|
|
check_off_config.pivot_backoff_max_distance = 1.0;
|
|
dock_planner::DockCalc no_callbacks(check_off_config);
|
|
dock_planner::DockCalc ignored_callbacks(check_off_config);
|
|
ignored_callbacks.setCostmapCheckCallbacks(
|
|
[](const robot_geometry_msgs::Pose&, double) { return false; },
|
|
[](const robot_geometry_msgs::Pose&) { return false; });
|
|
std::vector<robot_geometry_msgs::Pose> no_callback_path;
|
|
std::vector<robot_geometry_msgs::Pose> ignored_callback_path;
|
|
CHECK(no_callbacks.makePlanMoveToDock(start, goal, robot_footprint,
|
|
no_dock_footprint, no_callback_path));
|
|
CHECK(ignored_callbacks.makePlanMoveToDock(
|
|
start, goal, robot_footprint, no_dock_footprint,
|
|
ignored_callback_path));
|
|
CHECK(pathsEqualExactly(no_callback_path, ignored_callback_path));
|
|
|
|
// The back-off fallback also ignores cells in the terminal corridor while
|
|
// still checking its rotation and both approach legs.
|
|
dock_planner::DockCalc terminal_corridor_blocked(config);
|
|
const double backoff_terminal_distance = config.straight_length;
|
|
terminal_corridor_blocked.setCostmapCheckCallbacks(
|
|
[](const robot_geometry_msgs::Pose&, double) { return true; },
|
|
[&goal, backoff_terminal_distance](const robot_geometry_msgs::Pose& sample)
|
|
{
|
|
return std::hypot(sample.position.x - goal.pose.position.x,
|
|
sample.position.y - goal.pose.position.y) >
|
|
backoff_terminal_distance;
|
|
});
|
|
std::vector<robot_geometry_msgs::Pose> terminal_corridor_backoff_path;
|
|
CHECK(terminal_corridor_blocked.makePlanMoveToDock(
|
|
start, goal, robot_footprint, no_dock_footprint,
|
|
terminal_corridor_backoff_path));
|
|
checkBackoffPivotPath(terminal_corridor_backoff_path, start, goal,
|
|
std::hypot(0.325, 0.345) + config.pivot_safety_margin);
|
|
CHECK(pathsEqualExactly(ignored_callback_path,
|
|
terminal_corridor_backoff_path));
|
|
}
|
|
|
|
/**
|
|
* Where the rotation has to happen for the footprints above. The swept circle
|
|
* is the binding constraint, not the mating extent: hypot(1.65, 0.40) is
|
|
* 1.6978 m, so the vertex ends up 1.50 m further out than the 0.85 m the rear
|
|
* mating extent plus dock face would have suggested.
|
|
*/
|
|
double apmPivotVertex(double pivot_safety_margin)
|
|
{
|
|
return std::max(0.85, std::hypot(1.65, 0.40) + 0.50 + pivot_safety_margin);
|
|
}
|
|
|
|
void testPivotFallback()
|
|
{
|
|
dock_planner::DockPlannerConfig config = apmConfig();
|
|
config.pivot_fallback_extension = 1.0;
|
|
dock_planner::DockCalc calculator(config);
|
|
|
|
const auto robot_footprint = apmFootprint();
|
|
const auto dock_footprint = apmDockFootprint();
|
|
const auto goal = pose(0.0, 0.0, 0.0);
|
|
const double maximum_curvature = 1.0 / config.minimumTurningRadius();
|
|
const double vertex = apmPivotVertex(config.pivot_safety_margin);
|
|
|
|
// 0.60 m of lateral offset needs a 1.598 m cusp extension at min_radius
|
|
// 2.4287 m, past the 1.0 m threshold, so the pivot shape takes over.
|
|
const auto pivot_path = generatePath(calculator, pose(2.8, 0.6, -1.2), goal,
|
|
robot_footprint, dock_footprint, true);
|
|
checkPivotPath(pivot_path, goal.pose, false, vertex);
|
|
|
|
// Same start, mirrored to the far side of the goal: the docking edge flips,
|
|
// so the whole path drives FORWARD instead, and the vertex is unchanged
|
|
// because the swept circle, not the mating extent, decides where it sits.
|
|
const auto front_pivot = generatePath(calculator, pose(-2.8, 0.6, 0.0), goal,
|
|
robot_footprint, dock_footprint, true);
|
|
checkPivotPath(front_pivot, goal.pose, true, vertex);
|
|
|
|
// Only 0.05 m of lateral offset: the cusp costs 0.490 m, under the
|
|
// threshold, so nothing changes and the cusp is still planned.
|
|
const auto cusp_path = generatePath(calculator, pose(2.8, 0.05, 0.0), goal,
|
|
robot_footprint, dock_footprint);
|
|
checkSingleCuspPath(cusp_path, goal.pose, maximum_curvature, false);
|
|
|
|
// Vertex behind the robot (start 1.5 m out, vertex 2.348 m): the pivot
|
|
// shape cannot be built and the planner must fall back to the cusp rather
|
|
// than refuse a path.
|
|
const auto behind_path = generatePath(calculator, pose(1.5, 0.3, 0.0), goal,
|
|
robot_footprint, dock_footprint);
|
|
checkSingleCuspPath(behind_path, goal.pose, maximum_curvature, false);
|
|
|
|
// The safety margin really does move the vertex: pushing it 0.50 m further
|
|
// out puts it past the 2.8 m start, so the same case falls back to a cusp.
|
|
config.pivot_safety_margin = 0.65;
|
|
calculator.setConfig(config);
|
|
const auto margin_path = generatePath(calculator, pose(2.8, 0.6, -1.2), goal,
|
|
robot_footprint, dock_footprint);
|
|
checkSingleCuspPath(margin_path, goal.pose, maximum_curvature, false);
|
|
|
|
// A cusp that cannot be placed at all used to be a hard failure. With the
|
|
// pivot shape available it is a path instead: refusing to dock is strictly
|
|
// worse than docking with one extra stop.
|
|
config = apmConfig();
|
|
config.maximum_forward_extension = 0.30;
|
|
std::vector<robot_geometry_msgs::Pose> refused;
|
|
dock_planner::DockCalc no_pivot(config);
|
|
CHECK(!no_pivot.makePlanMoveToDock(pose(2.8, 0.6, 0.0), goal,
|
|
robot_footprint, dock_footprint, refused));
|
|
CHECK(refused.empty());
|
|
|
|
config.pivot_fallback_extension = 1.0;
|
|
dock_planner::DockCalc rescued(config);
|
|
const auto rescue_path = generatePath(rescued, pose(2.8, 0.6, 0.0), goal,
|
|
robot_footprint, dock_footprint, true);
|
|
checkPivotPath(rescue_path, goal.pose, false,
|
|
apmPivotVertex(config.pivot_safety_margin));
|
|
}
|
|
|
|
void testDifferentialModel()
|
|
{
|
|
dock_planner::DockPlannerConfig config;
|
|
config.kinematic_model = dock_planner::KinematicModel::kDifferential;
|
|
config.minimum_turning_radius = 0.0;
|
|
config.path_point_spacing = 0.05;
|
|
config.direct_entry_min_curve_room = 0.0;
|
|
// Deliberately left at 0: a differential base pivots because it can, not
|
|
// because a threshold turned the shape on.
|
|
config.pivot_fallback_extension = 0.0;
|
|
dock_planner::DockCalc calculator(config);
|
|
|
|
const auto robot_footprint = apmFootprint();
|
|
const auto dock_footprint = apmDockFootprint();
|
|
const auto goal = pose(0.0, 0.0, 0.0);
|
|
const double vertex = apmPivotVertex(config.pivot_safety_margin);
|
|
|
|
CHECK(near(config.minimumTurningRadius(), 0.0));
|
|
|
|
const auto rear_path = generatePath(calculator, pose(2.8, 0.6, -1.2), goal,
|
|
robot_footprint, dock_footprint, true);
|
|
checkPivotPath(rear_path, goal.pose, false, vertex);
|
|
|
|
// Barely off the axis: an Ackermann base would have taken the cheap cusp
|
|
// here, but a base that turns on the spot always prefers the shape that
|
|
// claims no extra aisle.
|
|
const auto aligned_path = generatePath(calculator, pose(2.8, 0.05, 0.0), goal,
|
|
robot_footprint, dock_footprint, true);
|
|
checkPivotPath(aligned_path, goal.pose, false, vertex);
|
|
|
|
const auto front_path = generatePath(calculator, pose(-2.8, 0.6, 0.0), goal,
|
|
robot_footprint, dock_footprint, true);
|
|
checkPivotPath(front_path, goal.pose, true, vertex);
|
|
|
|
// Turning on the spot forbidden -- a tall load, say. The base is still
|
|
// differential, but the planner must go back to arc-based shapes.
|
|
config.minimum_turning_radius = 1.5;
|
|
dock_planner::DockCalc loaded(config);
|
|
const auto loaded_path = generatePath(loaded, pose(2.8, 0.6, -1.2), goal,
|
|
robot_footprint, dock_footprint);
|
|
checkSingleCuspPath(loaded_path, goal.pose, 1.0 / 1.5, false);
|
|
}
|
|
|
|
void testPathGeneration()
|
|
{
|
|
dock_planner::DockPlannerConfig config = apmConfig();
|
|
dock_planner::DockCalc calculator(config);
|
|
|
|
const std::vector<robot_geometry_msgs::Point> robot_footprint = {
|
|
point(1.65, -0.40), point(1.65, 0.40),
|
|
point(-0.35, 0.40), point(-0.35, -0.40)};
|
|
const std::vector<robot_geometry_msgs::Point> dock_footprint = {
|
|
point(0.50, -0.40), point(0.50, 0.40),
|
|
point(-0.50, 0.40), point(-0.50, -0.40)};
|
|
|
|
const auto goal = pose(0.0, 0.0, 0.0);
|
|
const double maximum_curvature = 1.0 / config.minimumTurningRadius();
|
|
for (const auto& start : {pose(2.8, 0.6, -1.2),
|
|
pose(2.8, 0.0, 2.0),
|
|
pose(2.8, -0.6, 1.2)})
|
|
{
|
|
const auto path = generatePath(calculator, start, goal,
|
|
robot_footprint, dock_footprint);
|
|
const std::size_t cusp = checkSingleCuspPath(path, goal.pose,
|
|
maximum_curvature, false);
|
|
CHECK(longitudinal(path[cusp], goal.pose) > longitudinal(start.pose, goal.pose));
|
|
CHECK(std::fabs(normalizeAngle(
|
|
data_convert::getYaw(path.front().orientation) -
|
|
data_convert::getYaw(start.pose.orientation))) > 0.1);
|
|
}
|
|
|
|
const auto rotated_goal = pose(0.0, 0.0, kPi / 2.0);
|
|
const auto rotated_path = generatePath(
|
|
calculator, pose(0.6, 2.8, 0.0), rotated_goal,
|
|
robot_footprint, dock_footprint);
|
|
checkSingleCuspPath(rotated_path, rotated_goal.pose, maximum_curvature, false);
|
|
|
|
// The previous projection<=1 failure is now valid: the robot first drives
|
|
// away from the dock until the curvature-safe cusp, then reverses straight.
|
|
const auto close_path = generatePath(calculator, pose(0.8, 0.2, 0.0), goal,
|
|
robot_footprint, dock_footprint);
|
|
checkSingleCuspPath(close_path, goal.pose, maximum_curvature, false);
|
|
|
|
// Standing on the far side of the goal is no longer an error: the docking
|
|
// edge is derived from the side the robot is on, so the same geometry runs
|
|
// mirrored -- reverse lead-in, then a straight FORWARD terminal. This is the
|
|
// charging-contact case (APM mates with the front of the robot).
|
|
const auto front_path = generatePath(calculator, pose(-2.8, 0.6, 0.0), goal,
|
|
robot_footprint, dock_footprint);
|
|
const std::size_t front_cusp =
|
|
checkSingleCuspPath(front_path, goal.pose, maximum_curvature, true);
|
|
// The cusp must sit on the far side of the goal from the rear-dock cases,
|
|
// and the clearance must come from front_extent (1.65 m) plus the dock's
|
|
// near face (0.50 m), not from rear_extent (0.35 m).
|
|
CHECK(longitudinal(front_path[front_cusp], goal.pose) < 0.0);
|
|
CHECK(std::fabs(longitudinal(front_path[front_cusp], goal.pose)) >= 2.15);
|
|
CHECK(std::fabs(lateral(front_path[front_cusp], goal.pose)) < 1e-7);
|
|
|
|
// A start exactly on the goal's lateral axis belongs to neither side, so no
|
|
// docking edge can be derived and the plan must be refused.
|
|
std::vector<robot_geometry_msgs::Pose> path;
|
|
CHECK(!calculator.makePlanMoveToDock(pose(0.0, 0.6, 0.0), goal,
|
|
robot_footprint, dock_footprint, path));
|
|
CHECK(path.empty());
|
|
|
|
auto invalid_start = pose(2.8, 0.6, 0.0);
|
|
invalid_start.pose.position.x = std::numeric_limits<double>::infinity();
|
|
CHECK(!calculator.makePlanMoveToDock(invalid_start, goal, robot_footprint,
|
|
dock_footprint, path));
|
|
CHECK(path.empty());
|
|
CHECK(!calculator.makePlanMoveToDock(pose(2.8, 0.6, 0.0), goal, {},
|
|
dock_footprint, path));
|
|
|
|
config.maximum_forward_extension = 0.30;
|
|
calculator.setConfig(config);
|
|
CHECK(!calculator.makePlanMoveToDock(pose(2.8, 0.6, 0.0), goal,
|
|
robot_footprint, dock_footprint, path));
|
|
CHECK(path.empty());
|
|
}
|
|
|
|
void testDirectEntry()
|
|
{
|
|
dock_planner::DockPlannerConfig config = apmConfig();
|
|
config.direct_entry_min_curve_room = 0.5;
|
|
dock_planner::DockCalc calculator(config);
|
|
|
|
const std::vector<robot_geometry_msgs::Point> robot_footprint = {
|
|
point(1.65, -0.40), point(1.65, 0.40),
|
|
point(-0.35, 0.40), point(-0.35, -0.40)};
|
|
const std::vector<robot_geometry_msgs::Point> dock_footprint = {
|
|
point(0.50, -0.40), point(0.50, 0.40),
|
|
point(-0.50, 0.40), point(-0.50, -0.40)};
|
|
|
|
const auto goal = pose(0.0, 0.0, 0.0);
|
|
const double maximum_curvature = 1.0 / config.minimumTurningRadius();
|
|
|
|
// Rear edge: clearance 0.35 (rear_extent) + 0.50 (dock near face) = 0.85 m,
|
|
// so a start 2.8 m out leaves 1.95 m of curve room against the 1.598 m the
|
|
// 0.60 m lateral offset needs at min_radius 2.4287 m. The whole path reverses.
|
|
const double rear_straight = 0.35 + 0.50;
|
|
for (const auto& start : {pose(2.8, 0.6, -1.2), pose(2.8, -0.6, 1.2)})
|
|
{
|
|
const auto direct_path = generatePath(calculator, start, goal,
|
|
robot_footprint, dock_footprint);
|
|
checkDirectEntry(direct_path, goal.pose, maximum_curvature, false,
|
|
rear_straight);
|
|
}
|
|
|
|
// Already on the dock axis: the arc degenerates and the robot drives one
|
|
// straight line all the way in, instead of the pointless drive-away-and-back
|
|
// the cusp maneuver would produce.
|
|
const auto aligned_path = generatePath(calculator, pose(2.8, 0.0, 0.5), goal,
|
|
robot_footprint, dock_footprint);
|
|
checkDirectEntry(aligned_path, goal.pose, maximum_curvature, false,
|
|
rear_straight);
|
|
for (const auto& sample : aligned_path)
|
|
{
|
|
CHECK(std::fabs(lateral(sample, goal.pose)) < 1e-7);
|
|
}
|
|
|
|
// Front edge: clearance 1.65 (front_extent) + 0.50 = 2.15 m, so the start has
|
|
// to be much farther out for the arc to fit. The whole path drives forward.
|
|
const double front_straight = 1.65 + 0.50;
|
|
const auto front_direct = generatePath(calculator, pose(-4.0, 0.6, 0.0), goal,
|
|
robot_footprint, dock_footprint);
|
|
checkDirectEntry(front_direct, goal.pose, maximum_curvature, true,
|
|
front_straight);
|
|
|
|
// Enough room to pass the threshold (1.15 m > 0.50 m) but not enough for the
|
|
// radius (needs 1.598 m), so the planner must fall back to the cusp rather
|
|
// than emit an arc tighter than the steering limit.
|
|
const auto fallback_path = generatePath(calculator, pose(2.0, 0.6, 0.0), goal,
|
|
robot_footprint, dock_footprint);
|
|
checkSingleCuspPath(fallback_path, goal.pose, maximum_curvature, false);
|
|
|
|
// Too close for a straight terminal of its own length: still a cusp.
|
|
const auto close_path = generatePath(calculator, pose(1.0, 0.2, 0.0), goal,
|
|
robot_footprint, dock_footprint);
|
|
checkSingleCuspPath(close_path, goal.pose, maximum_curvature, false);
|
|
|
|
// A longer requested straight terminal eats the curve room, so the same start
|
|
// that took the direct entry above falls back to the cusp.
|
|
config.straight_length = 2.5;
|
|
calculator.setConfig(config);
|
|
const auto long_terminal = generatePath(calculator, pose(2.8, 0.6, -1.2), goal,
|
|
robot_footprint, dock_footprint);
|
|
checkSingleCuspPath(long_terminal, goal.pose, maximum_curvature, false);
|
|
}
|
|
|
|
bool pathsEqual(const std::vector<robot_geometry_msgs::Pose>& first,
|
|
const std::vector<robot_geometry_msgs::Pose>& second)
|
|
{
|
|
if (first.size() != second.size())
|
|
{
|
|
return false;
|
|
}
|
|
for (std::size_t index = 0; index < first.size(); ++index)
|
|
{
|
|
if (!near(first[index].position.x, second[index].position.x) ||
|
|
!near(first[index].position.y, second[index].position.y) ||
|
|
!near(first[index].orientation.z, second[index].orientation.z) ||
|
|
!near(first[index].orientation.w, second[index].orientation.w))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void testAsymmetricFootprint()
|
|
{
|
|
dock_planner::DockPlannerConfig config;
|
|
config.wheel_base = 1.0;
|
|
config.max_steering_angle = 1.0;
|
|
dock_planner::DockCalc calculator(config);
|
|
|
|
const std::vector<robot_geometry_msgs::Point> stacker_footprint = {
|
|
point(0.8, -0.5), point(0.8, 0.5), point(-1.2, 0.5), point(-1.2, -0.5)};
|
|
const std::vector<robot_geometry_msgs::Point> rear_matched_footprint = {
|
|
point(1.2, -0.5), point(1.2, 0.5), point(-1.2, 0.5), point(-1.2, -0.5)};
|
|
const std::vector<robot_geometry_msgs::Point> smaller_rear_footprint = {
|
|
point(0.8, -0.5), point(0.8, 0.5), point(-0.8, 0.5), point(-0.8, -0.5)};
|
|
const std::vector<robot_geometry_msgs::Point> dock_footprint = {
|
|
point(0.5, -0.4), point(0.5, 0.4), point(-0.5, 0.4), point(-0.5, -0.4)};
|
|
|
|
const auto start = pose(0.5, 0.5, 0.0);
|
|
const auto goal = pose(0.0, 0.0, 0.0);
|
|
std::vector<robot_geometry_msgs::Pose> asymmetric_path;
|
|
std::vector<robot_geometry_msgs::Pose> reference_path;
|
|
CHECK(calculator.makePlanMoveToDock(start, goal, stacker_footprint,
|
|
dock_footprint, asymmetric_path));
|
|
CHECK(calculator.makePlanMoveToDock(start, goal, rear_matched_footprint,
|
|
dock_footprint, reference_path));
|
|
CHECK(pathsEqual(asymmetric_path, reference_path));
|
|
CHECK(calculator.makePlanMoveToDock(start, goal, smaller_rear_footprint,
|
|
dock_footprint, reference_path));
|
|
CHECK(!pathsEqual(asymmetric_path, reference_path));
|
|
}
|
|
|
|
void testDockAnchor()
|
|
{
|
|
dock_planner::DockPlannerConfig config;
|
|
config.wheel_base = 1.0;
|
|
config.max_steering_angle = 1.0;
|
|
const std::vector<robot_geometry_msgs::Point> robot_footprint = {
|
|
point(0.50, -0.35), point(0.50, 0.35),
|
|
point(-0.50, 0.35), point(-0.50, -0.35)};
|
|
const std::vector<robot_geometry_msgs::Point> dock_footprint = {
|
|
point(0.9, -0.8), point(0.9, 0.8), point(-0.9, 0.8), point(-0.9, -0.8)};
|
|
const auto start = pose(0.5, 0.4, 0.0);
|
|
const auto goal = pose(0.0, 0.0, 0.0);
|
|
|
|
config.dock_anchor = dock_planner::DockAnchor::kFace;
|
|
dock_planner::DockCalc face_calculator(config);
|
|
std::vector<robot_geometry_msgs::Pose> face_path;
|
|
CHECK(face_calculator.makePlanMoveToDock(start, goal, robot_footprint,
|
|
dock_footprint, face_path));
|
|
|
|
config.dock_anchor = dock_planner::DockAnchor::kCenter;
|
|
dock_planner::DockCalc center_calculator(config);
|
|
std::vector<robot_geometry_msgs::Pose> no_dock_path;
|
|
CHECK(center_calculator.makePlanMoveToDock(start, goal, robot_footprint,
|
|
{}, no_dock_path));
|
|
CHECK(pathsEqual(face_path, no_dock_path));
|
|
|
|
std::vector<robot_geometry_msgs::Pose> center_path;
|
|
CHECK(center_calculator.makePlanMoveToDock(start, goal, robot_footprint,
|
|
dock_footprint, center_path));
|
|
CHECK(!pathsEqual(face_path, center_path));
|
|
}
|
|
|
|
} // namespace
|
|
|
|
int main()
|
|
{
|
|
testConfig();
|
|
testBackoffPivotRobotFailures();
|
|
testMatingEdgeAnchor();
|
|
testMatingEdgeFaceOffset();
|
|
testDockPivotSafetyMarginOverride();
|
|
testExistingPlansUnchangedByBackoff();
|
|
testBackoffPivotGates();
|
|
testCostmapCheckCallbacks();
|
|
testPathGeneration();
|
|
testDirectEntry();
|
|
testPivotFallback();
|
|
testDifferentialModel();
|
|
testAsymmetricFootprint();
|
|
testDockAnchor();
|
|
if (failures != 0)
|
|
{
|
|
std::cerr << failures << " DockPlanner test assertion(s) failed.\n";
|
|
return 1;
|
|
}
|
|
std::cout << "DockPlanner tests passed.\n";
|
|
return 0;
|
|
}
|