Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit 375357a

Browse files
committed
Example with rmf_demos commit 2371649
Signed-off-by: chianfern <[email protected]>
1 parent 83f0cb4 commit 375357a

18 files changed

+3637
-0
lines changed

README.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,97 @@
11
# Free Fleet ROS2
2+
3+
## Contents
4+
5+
- **[About](#About)**
6+
- **[Installation Instructions](#installation-instructions)**
7+
- [Prerequisites](#prerequisites)
8+
- **[Examples](#examples)**
9+
- [Barebones Example](#barebones-example)
10+
</br>
11+
</br>
12+
13+
## About
14+
15+
Implementation of a Fleet Adapter to integrate [Free Fleet (an upcoming version)](https://github.com/open-rmf/free_fleet/tree/develop) clients with RMF [demos](https://github.com/open-rmf/rmf_demos).
16+
17+
</br>
18+
</br>
19+
20+
## Installation Instructions
21+
22+
### Prerequisites
23+
24+
* [Ubuntu 20.04 LTS](https://releases.ubuntu.com/20.04/)
25+
* [ROS2 - Galactic](https://docs.ros.org/en/galactic/index.html)
26+
* [RMF demos](https://github.com/open-rmf/rmf_demos)
27+
* [Free Fleet - develop branch](https://github.com/open-rmf/free_fleet/tree/develop)
28+
29+
</br>
30+
31+
### Installation
32+
Assuming free_fleet and fleet_fleet_ros2 are to be located in your home directory.
33+
34+
#### Free Fleet (develop)
35+
36+
```
37+
cd ~
38+
git clone https://github.com/open-rmf/free_fleet.git -b develop
39+
source /opt/ros/galactic/setup.bash
40+
source ~/rmf_ws/install/setup.bash
41+
cd ~/free_fleet
42+
# free_fleet dependencies
43+
colcon build
44+
```
45+
46+
#### Free Fleet ROS2 Implementation
47+
```bash
48+
cd ~
49+
git clone https://github.com/open-rmf/free_fleet_ros2.git -b develop
50+
source /opt/ros/galactic/setup.bash
51+
source ~/rmf_ws/install/setup.bash # requires rmf_fleet_msgs and rmf_task_msgs
52+
source ~/free_fleet/install/setup.bash
53+
colcon build
54+
```
55+
### Examples
56+
57+
To get the demos to use the free_fleet_ros2 adapter instead, modify this launch file:
58+
Edit ~/rmf_ws/src/rmf/rmf_ros2/rmf_fleet_adapter/launch/fleet_adapter.launch.xml
59+
Comment out lines 43-46
60+
```xml
61+
<!-- <node pkg="rmf_fleet_adapter"
62+
exec="$(var control_type)"
63+
name="$(var fleet_name)_fleet_adapter"
64+
output="both"> -->
65+
<node pkg="free_fleet_ros2_adapter"
66+
exec="adapter"
67+
name="free_fleet_ros2_adapter"
68+
output="both">
69+
```
70+
71+
Rebuild to use the updated launch file:
72+
`cd ~/rmf_ws; colcon build --packages-select rmf_fleet_adapter`
73+
74+
Open one terminal for the demo+adapters and one for the clients.
75+
In each:
76+
```
77+
source /opt/ros/galactic/setup.bash
78+
source ~/rmf_ws/install/setup.bash
79+
source ~/free_fleet_ros2/install/setup.bash
80+
81+
```
82+
#### Launch demo
83+
```
84+
ros2 launch rmf_demos_gz hotel.launch.xml
85+
```
86+
#### Launch clients
87+
The demo should be running before the clients are started.
88+
```
89+
ros2 launch free_fleet_ros2_examples hotel_clients.launch.xml
90+
```
91+
92+
### To do
93+
During Cleaning and other tasks which are performed while docking, visualization will not work correctly.
94+
Support new speed limit in Location.
95+
Complete testing of opening and closing of lanes.
96+
Better approach to launch files and address upcoming changes to `rmf_demos` launch and config files.
97+
Launch files for remaining demo worlds.

adapter/CMakeLists.txt

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
cmake_minimum_required(VERSION 3.7.0)
2+
project(free_fleet_ros2_adapter)
3+
4+
if(NOT CMAKE_CXX_STANDARD)
5+
set(CMAKE_CXX_STANDARD 17)
6+
endif()
7+
8+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
9+
add_compile_options(-Wall -Wextra -Wpedantic)
10+
endif()
11+
12+
if(NOT CMAKE_BUILD_TYPE)
13+
# Use the Release build type by default if the user has not specified one
14+
set(CMAKE_BUILD_TYPE Release)
15+
endif()
16+
17+
find_package(ament_cmake REQUIRED)
18+
include(GNUInstallDirs)
19+
20+
set(dep_pkgs
21+
rclcpp
22+
rmf_fleet_msgs
23+
rmf_task_msgs
24+
rmf_traffic
25+
rmf_traffic_ros2
26+
rmf_fleet_adapter
27+
free_fleet
28+
free_fleet_cyclonedds
29+
CycloneDDS
30+
)
31+
foreach(pkg ${dep_pkgs})
32+
find_package(${pkg} REQUIRED)
33+
endforeach()
34+
35+
# -----------------------------------------------------------------------------
36+
add_executable(adapter
37+
src/main.cpp
38+
)
39+
40+
target_link_libraries(adapter
41+
PRIVATE
42+
free_fleet::free_fleet
43+
free_fleet_cyclonedds::free_fleet_cyclonedds
44+
rmf_fleet_adapter::rmf_fleet_adapter
45+
rmf_traffic::rmf_traffic
46+
${rclcpp_LIBRARIES}
47+
${rmf_fleet_msgs_LIBRARIES}
48+
${rmf_task_msgs_LIBRARIES}
49+
CycloneDDS::ddsc
50+
)
51+
target_include_directories(adapter
52+
PRIVATE
53+
${rmf_fleet_msgs_INCLUDE_DIRS}
54+
${rmf_task_msgs_INCLUDE_DIRS}
55+
)
56+
57+
install(TARGETS
58+
adapter
59+
DESTINATION lib/${PROJECT_NAME}
60+
)
61+
ament_package()

adapter/package.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="3">
4+
<name>free_fleet_ros2_adapter</name>
5+
<version>1.1.0</version>
6+
<description>Free fleet ROS 2 implementations</description>
7+
<maintainer email="[email protected]">Aaron</maintainer>
8+
<license>Apache License 2.0</license>
9+
10+
<buildtool_depend>ament_cmake</buildtool_depend>
11+
<depend>rclcpp</depend>
12+
<depend>rmf_utils</depend>
13+
<depend>rmf_traffic</depend>
14+
<depend>rmf_traffic_ros2</depend>
15+
<depend>rmf_fleet_adapter</depend>
16+
17+
<depend>free_fleet</depend>
18+
<depend>free_fleet_cyclonedds</depend>
19+
20+
<build_depend>eigen</build_depend>
21+
22+
<test_depend>ament_cmake_catch2</test_depend>
23+
<test_depend>rmf_cmake_uncrustify</test_depend>
24+
25+
<export>
26+
<build_type>ament_cmake</build_type>
27+
</export>
28+
</package>

adapter/src/load_param.cpp

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/*
2+
* Copyright (C) 2019 Open Source Robotics Foundation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
#include "load_param.hpp"
19+
20+
#include <rmf_traffic/geometry/Circle.hpp>
21+
22+
namespace rmf_fleet_adapter {
23+
24+
//==============================================================================
25+
std::chrono::nanoseconds get_parameter_or_default_time(
26+
rclcpp::Node& node,
27+
const std::string& param_name,
28+
const double default_value)
29+
{
30+
const double value =
31+
get_parameter_or_default(node, param_name, default_value);
32+
33+
return std::chrono::duration_cast<std::chrono::nanoseconds>(
34+
std::chrono::duration<double, std::ratio<1>>(value));
35+
}
36+
37+
//==============================================================================
38+
std::string get_fleet_name_parameter(rclcpp::Node& node)
39+
{
40+
std::string fleet_name = node.declare_parameter("fleet_name", std::string());
41+
if (fleet_name.empty())
42+
{
43+
RCLCPP_ERROR(
44+
node.get_logger(),
45+
"The fleet_name parameter must be specified!");
46+
throw std::runtime_error("fleet_name parameter is missing");
47+
}
48+
49+
return fleet_name;
50+
}
51+
52+
//==============================================================================
53+
rmf_traffic::agv::VehicleTraits get_traits_or_default(rclcpp::Node& node,
54+
const double default_v_nom, const double default_w_nom,
55+
const double default_a_nom, const double default_alpha_nom,
56+
const double default_r_f, const double default_r_v)
57+
{
58+
const double v_nom =
59+
get_parameter_or_default(node, "linear_velocity", default_v_nom);
60+
const double w_nom =
61+
get_parameter_or_default(node, "angular_velocity", default_w_nom);
62+
const double a_nom =
63+
get_parameter_or_default(node, "linear_acceleration", default_a_nom);
64+
const double b_nom =
65+
get_parameter_or_default(node, "angular_acceleration", default_alpha_nom);
66+
const double r_f =
67+
get_parameter_or_default(node, "footprint_radius", default_r_f);
68+
const double r_v =
69+
get_parameter_or_default(node, "vicinity_radius", default_r_v);
70+
const bool reversible =
71+
get_parameter_or_default(node, "reversible", true);
72+
73+
if (!reversible)
74+
std::cout << " ===== We have an irreversible robot" << std::endl;
75+
76+
auto traits = rmf_traffic::agv::VehicleTraits{
77+
{v_nom, a_nom},
78+
{w_nom, b_nom},
79+
rmf_traffic::Profile{
80+
rmf_traffic::geometry::make_final_convex<
81+
rmf_traffic::geometry::Circle>(r_f),
82+
rmf_traffic::geometry::make_final_convex<
83+
rmf_traffic::geometry::Circle>(r_v)
84+
}
85+
};
86+
87+
traits.get_differential()->set_reversible(reversible);
88+
return traits;
89+
}
90+
91+
92+
//==============================================================================
93+
std::optional<rmf_battery::agv::BatterySystem> get_battery_system(
94+
rclcpp::Node& node,
95+
const double default_voltage,
96+
const double default_capacity,
97+
const double default_charging_current)
98+
{
99+
const double voltage =
100+
get_parameter_or_default(node, "battery_voltage", default_voltage);
101+
const double capacity =
102+
get_parameter_or_default(node, "battery_capacity", default_capacity);
103+
const double charging_current =
104+
get_parameter_or_default(
105+
node, "battery_charging_current", default_charging_current);
106+
107+
auto battery_system = rmf_battery::agv::BatterySystem::make(
108+
voltage, capacity, charging_current);
109+
110+
return battery_system;
111+
}
112+
113+
//==============================================================================
114+
std::optional<rmf_battery::agv::MechanicalSystem> get_mechanical_system(
115+
rclcpp::Node& node,
116+
const double default_mass,
117+
const double default_moment,
118+
const double default_friction)
119+
{
120+
const double mass =
121+
get_parameter_or_default(node, "mass", default_mass);
122+
const double moment_of_inertia =
123+
get_parameter_or_default(node, "inertia", default_moment);
124+
const double friction =
125+
get_parameter_or_default(node, "friction_coefficient", default_friction);
126+
127+
auto mechanical_system = rmf_battery::agv::MechanicalSystem::make(
128+
mass, moment_of_inertia, friction);
129+
130+
return mechanical_system;
131+
}
132+
133+
} // namespace rmf_fleet_adapter

0 commit comments

Comments
 (0)