Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ros2 docking charging dock wibotic msgs #436

Merged
merged 25 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c9faeb3
Fixed namespaces and updated ros_component_description
delihus Oct 10, 2024
076a5dc
Changed GetDockPose approach
delihus Oct 29, 2024
1b09ff7
Cleanup charger
delihus Oct 29, 2024
72a6b81
Added unit tests
delihus Oct 29, 2024
d212d79
Update docs:
delihus Oct 30, 2024
791fc8f
Merge remote-tracking branch 'origin/ros2-docking' into ros2-docking-…
delihus Oct 30, 2024
d4edaaf
Fix upside down
delihus Oct 31, 2024
4a04543
Added updateAndPublishStagingPose method
delihus Oct 31, 2024
4a23171
Added suggestins | added reading docking_server parameter is dock pos…
delihus Oct 31, 2024
38186f8
Remove redundant tests
delihus Nov 4, 2024
5b6f5c7
Added reading wibotic_info
delihus Oct 7, 2024
6e96685
Added launching wibotic_connector_can
delihus Nov 5, 2024
12ed571
Added right condition to wibotic_connector_can
delihus Nov 5, 2024
def8fd2
wibotic_ros is needed to build
delihus Nov 12, 2024
7ae2294
Update repose, update parameters
delihus Nov 12, 2024
860b1cf
Merge remote-tracking branch 'origin/ros2-docking' into ros2-docking-…
delihus Nov 12, 2024
bef1139
Added condition for use_docking
delihus Nov 12, 2024
4977ccb
update repose
delihus Nov 12, 2024
b6624d4
Fixed use_wibotic_info param
delihus Nov 15, 2024
90ca7aa
Merge remote-tracking branch 'origin/ros2-docking' into ros2-docking-…
delihus Nov 15, 2024
7605e89
Merge remote-tracking branch 'origin/ros2-docking-charging-dock-wibot…
delihus Nov 15, 2024
0a84793
Rafal's suggestions applied
delihus Nov 15, 2024
48374e1
README update and comment delete
delihus Nov 19, 2024
f2af2f8
Update docs
delihus Nov 19, 2024
8f82837
Update .repose
delihus Nov 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Launch arguments are largely common to both simulation and physical robot. Howev
| 🤖🖥️ | `use_ekf` | Enable or disable EKF. <br/> ***bool:*** `True` |
| 🤖🖥️ | `use_sim` | Whether simulation is used. <br/> ***bool:*** `False` |
| 🤖🖥️ | `user_led_animations_file` | Path to a YAML file with a description of the user-defined animations. <br/> ***string:*** `''` |
| 🤖🖥️ | `use_wibotic_info` |Whether Wibotic information is used. <br/> **bool**: `True` |
| 🤖🖥️ | `wheel_config_path` | Path to wheel configuration file. <br/> ***string:*** [`{wheel_type}.yaml`](./panther_description/config) |
| 🤖🖥️ | `wheel_type` | Type of wheel. If you choose a value from the preset options ('WH01', 'WH02', 'WH04'), you can ignore the 'wheel_config_path' and 'controller_config_path' parameters. For custom wheels, please define these parameters to point to files that accurately describe the custom wheels. <br/> ***string:*** `WH01` (choices: `WH01`, `WH02`, `WH04`, `custom`) |
| 🖥️ | `x` | Initial robot position in the global 'x' axis. <br/> ***float:*** `0.0` |
Expand Down
6 changes: 5 additions & 1 deletion panther/panther_hardware.repos
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ repositories:
ros_components_description:
type: git
url: https://github.com/husarion/ros_components_description.git
version: b29f41ac00ab1a6fbac3e1d03602575094de277a
version: fa3a4a9a09d793b16ed23cbeb09cf4c4a892b9e3
ros2_controllers: # Caused by two error: 1. https://github.com/ros-controls/ros2_controllers/pull/1104 2. There is no nice way to change `sensor_name` imu_bradcaster param when spawning multiple robots -> ros2_control refer only to single imu entity
type: git
url: https://github.com/husarion/ros2_controllers/
version: 9da42a07a83bbf3faf5cad11793fff22f25068af
wibotic_ros:
type: git
url: https://github.com/husarion/wibotic_ros/
version: 0.1.0
6 changes: 5 additions & 1 deletion panther/panther_simulation.repos
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repositories:
ros_components_description:
type: git
url: https://github.com/husarion/ros_components_description.git
version: b29f41ac00ab1a6fbac3e1d03602575094de277a
version: fa3a4a9a09d793b16ed23cbeb09cf4c4a892b9e3
ros2_controllers: # Caused by two error: 1. https://github.com/ros-controls/ros2_controllers/pull/1104 2. There is no nice way to change `sensor_name` imu_bradcaster param when spawning multiple robots -> ros2_control refer only to single imu entity
type: git
url: https://github.com/husarion/ros2_controllers/
Expand All @@ -23,3 +23,7 @@ repositories:
type: git
url: https://github.com/husarion/husarion_gz_worlds.git
version: 9d514a09c74bca2afbfba76cf2c87134918bbf97
wibotic_ros:
type: git
url: https://github.com/husarion/wibotic_ros/
version: 0.1.0
3 changes: 2 additions & 1 deletion panther_docking/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ set(PACKAGE_DEPENDENCIES
sensor_msgs
std_srvs
tf2_geometry_msgs
tf2_ros)
tf2_ros
wibotic_msgs)

foreach(PACKAGE IN ITEMS ${PACKAGE_DEPENDENCIES})
find_package(${PACKAGE} REQUIRED)
Expand Down
12 changes: 7 additions & 5 deletions panther_docking/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ The package contains a `PantherChargingDock` plugin for the [opennav_docking](ht

- `base_frame` [*string*, default: **base_link**]: A base frame id of a robot.
- `fixed_frame` [*string*, default: **odom**]: A fixed frame id of a robot.
- `<dock_type>.external_detection_timeout` [*double*, default: **0.2**]: A timeout in seconds for looking up a transformation from an april tag of a dock to a base frame id.
- `<dock_type>.docking_distance_threshold` [*double*, default: **0.05**]: A threshold of a distance between a robot pose and a dock pose to declare if docking succeed.
- `<dock_type>.docking_yaw_threshold` [*double*, default: **0.3**]: A threshold of a difference of yaw angles between a robot pose and a dock pose to declare if docking succeed.
- `<dock_type>.staging_x_offset` [*double*, default: **-0.7**]: A staging pose is defined by offsetting a dock pose in axis X.
- `<dock_type>.filter_coef` [*double*, default: **0.1**]: A key parameter that influences the trade-off between the filter's responsiveness and its smoothness, balancing how quickly it reacts to new pose data pose how much it smooths out fluctuations.
- `panther_charging_dock.external_detection_timeout` [*double*, default: **0.2**]: A timeout in seconds for looking up a transformation from an april tag of a dock to a base frame id.
- `panther_charging_dock.docking_distance_threshold` [*double*, default: **0.05**]: A threshold of a distance between a robot pose and a dock pose to declare if docking succeed.
- `panther_charging_dock.docking_yaw_threshold` [*double*, default: **0.3**]: A threshold of a difference of yaw angles between a robot pose and a dock pose to declare if docking succeed.
- `panther_charging_dock.staging_x_offset` [*double*, default: **-0.7**]: A staging pose is defined by offsetting a dock pose in axis X.
- `panther_charging_dock.filter_coef` [*double*, default: **0.1**]: A key parameter that influences the trade-off between the filter's responsiveness and its smoothness, balancing how quickly it reacts to new pose data pose how much it smooths out fluctuations.
- `panther_charging_dock.use_wibotic_info` [*bool*, default: **True**]: Whether Wibotic information is used.
- `panther_charging_dock.wibotic_info_timeout` [*double*, default: **1.5**]: A timeout in seconds to receive wibotic_info.
10 changes: 6 additions & 4 deletions panther_docking/config/panther_docking_server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ros__parameters:
controller_frequency: 50.0
initial_perception_timeout: 5.0
wait_charge_timeout: 5.0
wait_charge_timeout: 10.0
dock_approach_timeout: 20.0
undock_linear_tolerance: 0.08
undock_angular_tolerance: 0.08
Expand All @@ -17,10 +17,12 @@
panther_charging_dock:
plugin: panther_docking::PantherChargingDock
external_detection_timeout: 0.1
docking_distance_threshold: 0.08
docking_yaw_threshold: 0.1
docking_distance_threshold: 0.12
docking_yaw_threshold: 0.15
staging_x_offset: -0.5
filter_coef: 0.1
use_wibotic_info: <use_wibotic_info_param>
wibotic_info_timeout: 1.0
rafal-gorecki marked this conversation as resolved.
Show resolved Hide resolved

docks: ["main"]
main:
Expand All @@ -32,5 +34,5 @@
k_phi: 1.0
k_delta: 2.0
v_linear_min: 0.0
v_linear_max: 0.3
v_linear_max: 0.1
v_angular_max: 0.15
27 changes: 27 additions & 0 deletions panther_docking/include/panther_docking/panther_charging_dock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@
#include <sensor_msgs/msg/battery_state.hpp>
#include <std_srvs/srv/set_bool.hpp>

#include "wibotic_msgs/msg/wibotic_info.hpp"

namespace panther_docking
{

constexpr double kWiboticChargingCurrentThreshold = 0.0;

/**
* @class PantherChargingDock
* @brief A class to represent a Panther charging dock.
Expand All @@ -45,6 +49,7 @@ class PantherChargingDock : public opennav_docking_core::ChargingDock
using SharedPtr = std::shared_ptr<PantherChargingDock>;
using UniquePtr = std::unique_ptr<PantherChargingDock>;
using PoseStampedMsg = geometry_msgs::msg::PoseStamped;
using WiboticInfoMsg = wibotic_msgs::msg::WiboticInfo;

/**
* @brief Configure the dock with the necessary information.
Expand Down Expand Up @@ -140,10 +145,27 @@ class PantherChargingDock : public opennav_docking_core::ChargingDock
*/
void getParameters(const rclcpp_lifecycle::LifecycleNode::SharedPtr & node);

/**
* @brief Method to update and publish the staging pose.
*
* Uses staging_x_offset_ and staging_yaw_offset_ to calculate the staging pose.
*/
void updateAndPublishStagingPose();

/**
* @brief Dock pose callback, used for external detection.
*
* @param pose The dock pose.
*/
void setDockPose(const PoseStampedMsg::SharedPtr pose);

/**
* @brief Wibotic info callback, used when `use_wibotic_info` is enabled.
*
* @param msg The Wibotic info message.
*/
void setWiboticInfo(const WiboticInfoMsg::SharedPtr msg);
rafal-gorecki marked this conversation as resolved.
Show resolved Hide resolved

std::string base_frame_name_;
std::string fixed_frame_name_;
std::string dock_frame_;
Expand All @@ -156,9 +178,11 @@ class PantherChargingDock : public opennav_docking_core::ChargingDock

rclcpp::Publisher<PoseStampedMsg>::SharedPtr staging_pose_pub_;
rclcpp::Subscription<PoseStampedMsg>::SharedPtr dock_pose_sub_;
rclcpp::Subscription<WiboticInfoMsg>::SharedPtr wibotic_info_sub_;

PoseStampedMsg dock_pose_;
PoseStampedMsg staging_pose_;
WiboticInfoMsg::SharedPtr wibotic_info_;

double external_detection_timeout_;

Expand All @@ -171,6 +195,9 @@ class PantherChargingDock : public opennav_docking_core::ChargingDock
double staging_yaw_offset_;

double pose_filter_coef_;

bool use_wibotic_info_;
double wibotic_info_timeout_;
};

} // namespace panther_docking
Expand Down
89 changes: 68 additions & 21 deletions panther_docking/launch/docking.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
# limitations under the License.

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument # , IncludeLaunchDescription
from launch.conditions import IfCondition # , UnlessCondition

# from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import (
LaunchConfiguration,
PathJoinSubstitution,
PythonExpression,
)
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare
from nav2_common.launch import ReplaceString
Expand Down Expand Up @@ -52,9 +55,23 @@ def generate_launch_description():
choices=["debug", "info", "warning", "error"],
)

use_wibotic_info = LaunchConfiguration("use_wibotic_info")
declare_use_wibotic_info_arg = DeclareLaunchArgument(
rafal-gorecki marked this conversation as resolved.
Show resolved Hide resolved
"use_wibotic_info",
default_value="True",
description="Whether Wibotic information is used",
choices=[True, False, "True", "False", "true", "false", "1", "0"],
)

namespaced_docking_server_config = ReplaceString(
source_file=docking_server_config_path,
replacements={"<robot_namespace>": namespace, "//": "/"},
replacements={
"<robot_namespace>": namespace,
"//": "/",
"<use_wibotic_info_param>": PythonExpression(
["'false' if '", use_sim, "' else '", use_wibotic_info, "'"]
),
},
)

docking_server_node = Node(
Expand Down Expand Up @@ -102,29 +119,59 @@ def generate_launch_description():
condition=IfCondition(use_docking),
)

# FIXME: This launch does not work with the simulation. It can be caused by different versions of opencv
# station_launch = IncludeLaunchDescription(
# PythonLaunchDescriptionSource(
# PathJoinSubstitution(
# [
# FindPackageShare("panther_docking"),
# "launch",
# "station.launch.py",
# ]
# ),
# ),
# launch_arguments={"namespace": namespace}.items(),
# condition=UnlessCondition(use_sim),
# )
station_launch = IncludeLaunchDescription(
rafal-gorecki marked this conversation as resolved.
Show resolved Hide resolved
PythonLaunchDescriptionSource(
PathJoinSubstitution(
[
FindPackageShare("panther_docking"),
"launch",
"station.launch.py",
]
),
),
launch_arguments={"namespace": namespace}.items(),
)

wibotic_connector_can = Node(
package="wibotic_connector_can",
executable="wibotic_connector_can",
namespace=namespace,
emulate_tty=True,
arguments=["--ros-args", "--log-level", log_level, "--log-level", "rcl:=INFO"],
condition=IfCondition(
PythonExpression(["not ", use_sim, " and ", use_wibotic_info, " and ", use_docking])
),
)

# FIXME: Remove before release
panther_manager_dir = FindPackageShare("panther_manager")
docking_manager_node = Node(
package="panther_manager",
executable="docking_manager_node",
name="docking_manager",
parameters=[
PathJoinSubstitution([panther_manager_dir, "config", "docking_manager.yaml"]),
{
"bt_project_path": PathJoinSubstitution(
[panther_manager_dir, "behavior_trees", "DockingBT.btproj"]
)
},
],
namespace=namespace,
emulate_tty=True,
)

return LaunchDescription(
[
declare_use_docking_arg,
declare_docking_server_config_path_arg,
declare_log_level,
# station_launch,
declare_use_wibotic_info_arg,
station_launch,
docking_server_node,
docking_server_activate_node,
dock_pose_publisher,
wibotic_connector_can,
docking_manager_node,
]
)
3 changes: 2 additions & 1 deletion panther_docking/launch/station.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
from launch_ros.actions import Node
from launch_ros.parameter_descriptions import ParameterValue
from launch_ros.substitutions import FindPackageShare
from moms_apriltag import TagGenerator2


def generate_apriltag_and_get_path(tag_id):
from moms_apriltag import TagGenerator2

tag_generator = TagGenerator2("tag36h11")
tag_image = tag_generator.generate(tag_id, scale=1000)

Expand Down
3 changes: 3 additions & 0 deletions panther_docking/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<depend>geometry_msgs</depend>
<depend>nav2_util</depend>
<depend>opennav_docking</depend>
<depend>panther_manager</depend>
<depend>panther_utils</depend>
<depend>pluginlib</depend>
<depend>python3-pip</depend>
Expand All @@ -25,9 +26,11 @@
<depend>sensor_msgs</depend>
<depend>std_srvs</depend>
<depend>tf2_ros</depend>
<depend>wibotic_msgs</depend>

<exec_depend>nav2_lifecycle_manager</exec_depend>
<exec_depend>python3-imageio</exec_depend>
<exec_depend>wibotic_connector_can</exec_depend>
<exec_depend>xacro</exec_depend>

<buildtool_depend>ament_cmake</buildtool_depend>
Expand Down
Loading