Problem
- while doing docking, we struggle to the issue that we can not pick up the item correctly.
- this may cause by several reason
- move forward distance not enough
- does not align the item
- we are going to fix this problem
About docking
everything about docking is in opennav_docking
it has its own BT, spinning Engine, self-define message type, controller, server
To be specific, docking behavior of our project is mainly determine by the controller & server. (but this is because we don't need another functionality in original opennav_docking)
Docking Server
Docking Server define the behavior of the lifecycle of docking, we can find function like on_activate, on_configure, etc.
the core function is dockRobot().
While in dockRobot(), we take the following action.
- get everything we need to act a dock
|
auto goal = docking_action_server_->get_current_goal(); |
|
auto result = std::make_shared<DockRobot::Result>(); |
- sending the robot to its staging point via navigator
|
publishDockingFeedback(DockRobot::Feedback::NAV_TO_STAGING_POSE); |
|
const auto initial_staging_pose = dock->getStagingPose(); |
|
const auto robot_pose = getRobotPoseInFrame( |
|
initial_staging_pose.header.frame_id); |
|
if (!goal->navigate_to_staging_pose || |
|
utils::l2Norm(robot_pose.pose, initial_staging_pose.pose) < dock_prestaging_tolerance_) |
|
{ |
|
RCLCPP_INFO(get_logger(), "\033[1;32m Robot already within pre-staging pose tolerance for dock \033[0m"); |
|
} else { |
|
navigator_->goToPose( |
|
initial_staging_pose, rclcpp::Duration::from_seconds(goal->max_staging_time)); |
|
// RCLCPP_INFO(get_logger(), "Successful navigation to staging pose"); |
|
} |
- perform dock from staging point
|
publishDockingFeedback(DockRobot::Feedback::NAV_TO_STAGING_POSE); |
|
const auto initial_staging_pose = dock->getStagingPose(); |
|
const auto robot_pose = getRobotPoseInFrame( |
|
initial_staging_pose.header.frame_id); |
|
if (!goal->navigate_to_staging_pose || |
|
utils::l2Norm(robot_pose.pose, initial_staging_pose.pose) < dock_prestaging_tolerance_) |
|
{ |
|
RCLCPP_INFO(get_logger(), "\033[1;32m Robot already within pre-staging pose tolerance for dock \033[0m"); |
|
} else { |
|
navigator_->goToPose( |
|
initial_staging_pose, rclcpp::Duration::from_seconds(goal->max_staging_time)); |
|
// RCLCPP_INFO(get_logger(), "Successful navigation to staging pose"); |
|
} |
- the actual perform function is
approachDock(dock, dock_pose) at line 277
this function will first check if we need to stop docking, compute the Twist command and send via controller, then check if we need to stop because of the obstacle(controller_->computeIfNeedStop(dock_pose.pose)) via we perform docking.
|
bool DockingServer::approachDock(Dock * dock, geometry_msgs::msg::PoseStamped & dock_pose) |
|
{ |
|
rclcpp::Rate loop_rate(controller_frequency_); |
|
auto start = this->now(); |
|
auto timeout = rclcpp::Duration::from_seconds(dock_approach_timeout_); |
|
while (rclcpp::ok()) { |
|
publishDockingFeedback(DockRobot::Feedback::CONTROLLING); |
|
|
|
// Determine if we want to stop |
|
if(stop_robot_) { |
|
publishZeroVelocity(); |
|
throw opennav_docking_core::StopRobot( |
|
"StopRobot activate, stop the robot"); |
|
} |
|
|
|
// Stop and report success if connected to dock |
|
if (dock->plugin->isDocked() || dock->plugin->isCharging()) { |
|
publishZeroVelocity(); |
|
return true; |
|
} |
|
|
|
// Stop if cancelled/preempted |
|
if (checkAndWarnIfCancelled(docking_action_server_, "dock_robot") || |
|
checkAndWarnIfPreempted(docking_action_server_, "dock_robot")) |
|
{ |
|
return false; |
|
} |
|
|
|
// Update perception |
|
if (!dock->plugin->getRefinedPose(dock_pose)) { |
|
throw opennav_docking_core::FailedToDetectDock("Failed dock detection"); |
|
} |
|
|
|
// ! Transform target_pose into base_link frame |
|
geometry_msgs::msg::PoseStamped target_pose = dock_pose; |
|
target_pose.header.stamp = rclcpp::Time(0); |
|
|
|
tf2_buffer_->transform(target_pose, target_pose, base_frame_); |
|
|
|
// Compute and publish controls |
|
geometry_msgs::msg::Twist command; |
|
if (!controller_->computeVelocityCommand(target_pose.pose, command, dock_backwards_)) { |
|
throw opennav_docking_core::FailedToControl("Failed to get control"); |
|
} |
|
|
|
if (this->now() - start > timeout) { |
|
throw opennav_docking_core::FailedToControl( |
|
"Timed out approaching dock"); |
|
} |
|
|
|
// Compute if rival is on the way |
|
if (controller_->computeIfNeedStop(dock_pose.pose)) { |
|
publishZeroVelocity(); |
|
throw opennav_docking_core::BlockByRival( |
|
"Goal blocked by rival, stop the robot"); |
|
} |
|
|
|
vel_publisher_->publish(command); |
|
|
|
loop_rate.sleep(); |
|
} |
|
return false; |
|
} |
Controller
Controller define the util function of actually control of the robot.
trace by yourself.
how to perform docking
the command rule is describe as follow
ros2 action send_goal /dock_robot opennav_docking_msgs/action/DockRobot "{
dock_type: 'your_dock_type',
use_dock_id: false,
navigate_to_staging_pose: true, // do we need to navigate to staging point
max_staging_time: 1000.0, // time for navigate to staging point
dock_pose: {
header: {
frame_id: 'map'
},
pose: {
position: {x: 1.0, y: 2.0, z: 0.0}, // x,y stand for staging point position, z stand for offset
orientation: {x: 0.0, y: 0.0, z: 0.0, w: 1.0}
}
}
}"
the dock_type support
default and recommend to use
- mission_dock_x
- mission_dock_y
| Category |
Keywords |
Effect |
| Controller |
fast, slow |
Adjusts speed profiles. |
| |
linearBoost |
Likely increases max linear acceleration/velocity. |
| |
angularBoost |
Likely increases max rotational acceleration/velocity. |
| Goal Checker |
precise |
Strict tolerance for success. |
| |
loose |
Relaxed tolerance (good for "Rush" mode). |
| Docking Style |
ordinary |
Standard behavior. |
| |
gentle |
Soft deceleration/approach. |
| |
rush |
Aggressive/competition mode. |
can be append in any order, for example:
You can mix and match these strings. The underscores _ are the standard separator.
- Safe / Testing Modes:
- dock_x_ordinary_slow_precise
- dock_y_gentle_slow
- Competition / Speed Modes:
- dock_x_rush_linearBoost_loose
- dock_y_fast_angularBoost
Issue
To increase the chance to get object we want with Aru Code on it, we need to cooperate with vision team.
- Given by vision team
- dx, dy of object respect to robot pose
- We need to
- adjust the direction slightly respect to the given dx, dy
To be specific:
- add util functions in
controller.cpp, subscribe vision topic, get dx,dy, robot_pose as input, adjust x or y according to dock_type. e.g. if mission_dock_x, you use dx to publish /cmd_vel with linear_x is some value and other value is 0.
- in
docking_server.cpp, before main control loop, given a parameter second for this feature to try, publish the /cmd_vel.
Problem
About docking
everything about docking is in opennav_docking
it has its own BT, spinning Engine, self-define message type, controller, server
To be specific, docking behavior of our project is mainly determine by the controller & server. (but this is because we don't need another functionality in original opennav_docking)
Docking Server
Docking Server define the behavior of the lifecycle of docking, we can find function like
on_activate,on_configure, etc.the core function is
dockRobot().While in
dockRobot(), we take the following action.Eurobot-2026-Navigation2/src/opennav_docking/opennav_docking/src/docking_server.cpp
Lines 214 to 215 in a0700cb
Eurobot-2026-Navigation2/src/opennav_docking/opennav_docking/src/docking_server.cpp
Lines 248 to 260 in a0700cb
Eurobot-2026-Navigation2/src/opennav_docking/opennav_docking/src/docking_server.cpp
Lines 248 to 260 in a0700cb
approachDock(dock, dock_pose)at line 277this function will first check if we need to stop docking, compute the
Twistcommand and send via controller, then check if we need to stop because of the obstacle(controller_->computeIfNeedStop(dock_pose.pose)) via we perform docking.Eurobot-2026-Navigation2/src/opennav_docking/opennav_docking/src/docking_server.cpp
Lines 398 to 460 in a0700cb
Controller
Controller define the util function of actually control of the robot.
trace by yourself.
how to perform docking
the command rule is describe as follow
the dock_type support
default and recommend to use
can be append in any order, for example:
You can mix and match these strings. The underscores
_are the standard separator.Issue
To increase the chance to get object we want with Aru Code on it, we need to cooperate with vision team.
To be specific:
controller.cpp, subscribe vision topic, get dx,dy, robot_pose as input, adjust x or y according to dock_type. e.g. if mission_dock_x, you use dx to publish /cmd_vel with linear_x is some value and other value is 0.docking_server.cpp, before main control loop, given a parameter second for this feature to try, publish the /cmd_vel.