refactor & optimal
This commit is contained in:
@@ -133,6 +133,47 @@ bool DockPlanner::initialize(std::string name,
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Match StanleyControl's axle-TF contract: lookup the front axle in
|
||||
// the rear-axle frame, then use the planar translation norm.
|
||||
const tf3::TransformStampedMsg axle_transform =
|
||||
costmap_robot->getTfBuffer().lookupTransform(
|
||||
loaded_config.rear_axle_frame,
|
||||
loaded_config.front_axle_frame,
|
||||
tf3::Time());
|
||||
loaded_config.wheel_base = std::hypot(
|
||||
axle_transform.transform.translation.x,
|
||||
axle_transform.transform.translation.y);
|
||||
}
|
||||
catch (const tf3::TransformException& exception)
|
||||
{
|
||||
robot::log_error(
|
||||
"[dock_planner] Cannot resolve wheel base from TF %s -> %s: %s.\n",
|
||||
loaded_config.front_axle_frame.c_str(),
|
||||
loaded_config.rear_axle_frame.c_str(), exception.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!std::isfinite(loaded_config.wheel_base) || loaded_config.wheel_base <= 0.0)
|
||||
{
|
||||
robot::log_error(
|
||||
"[dock_planner] Wheel base resolved to %.6f m from TF %s -> %s.\n",
|
||||
loaded_config.wheel_base, loaded_config.front_axle_frame.c_str(),
|
||||
loaded_config.rear_axle_frame.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
const double minimum_turning_radius = loaded_config.minimumTurningRadius();
|
||||
if (!std::isfinite(minimum_turning_radius) || minimum_turning_radius <= 0.0)
|
||||
{
|
||||
robot::log_error(
|
||||
"[dock_planner] Cannot derive minimum turning radius from wheel_base=%.6f m "
|
||||
"and max_steering_angle=%.6f rad.\n",
|
||||
loaded_config.wheel_base, loaded_config.max_steering_angle);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<robot_geometry_msgs::Point> loaded_footprint;
|
||||
if (loaded_config.dock_anchor == DockAnchor::kFace)
|
||||
{
|
||||
@@ -164,6 +205,13 @@ bool DockPlanner::initialize(std::string name,
|
||||
footprint_dock_ = std::move(loaded_footprint);
|
||||
dock_calc_.setConfig(loaded_config);
|
||||
initialized_ = true;
|
||||
|
||||
robot::log_info(
|
||||
"[dock_planner] Initialized forward-then-reverse maneuver: TF %s -> %s, "
|
||||
"wheel_base=%.4f m, max_steering_angle=%.4f rad, minimum_turning_radius=%.4f m.\n",
|
||||
loaded_config.front_axle_frame.c_str(), loaded_config.rear_axle_frame.c_str(),
|
||||
loaded_config.wheel_base, loaded_config.max_steering_angle,
|
||||
minimum_turning_radius);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user