Skip to content

Commit 65e49d1

Browse files
committed
Introducing new graph elements and properties (#103)
Signed-off-by: Michael X. Grey <[email protected]>
1 parent 5abe997 commit 65e49d1

File tree

17 files changed

+892
-95
lines changed

17 files changed

+892
-95
lines changed

.github/workflows/asan.yaml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,24 @@ on:
77
jobs:
88
asan:
99
name: asan
10-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-22.04
11+
container:
12+
image: osrf/ros:iron-desktop-jammy
1113
steps:
1214
- name: create_blacklist
13-
run: echo "fun:*Eigen*" > /home/runner/work/blacklist.txt
14-
- name: deps
15-
uses: ros-tooling/[email protected]
16-
with:
17-
required-ros-distributions: foxy
15+
run: |
16+
mkdir -p ${{ github.workspace }}/
17+
touch ${{ github.workspace }}/blacklist.txt
18+
echo "fun:*Eigen*" > ${{ github.workspace }}/blacklist.txt
19+
- name: install_clang_and_tools
20+
run: sudo apt update && sudo apt install -y clang clang-tools lld wget python3-pip python3-colcon-coveragepy-result python3-colcon-lcov-result lcov
1821
- name: build_and_test
19-
uses: ros-tooling/action-ros-ci@v0.2
22+
uses: ros-tooling/action-ros-ci@0.3.5
2023
env:
21-
CC: clang -fsanitize-blacklist=/home/runner/work/blacklist.txt
22-
CXX: clang++ -fsanitize-blacklist=/home/runner/work/blacklist.txt
24+
CC: clang -fsanitize-blacklist=${{ github.workspace }}/blacklist.txt
25+
CXX: clang++ -fsanitize-blacklist=${{ github.workspace }}/blacklist.txt
2326
with:
24-
target-ros2-distro: foxy
27+
target-ros2-distro: iron
2528
# build all packages listed in the meta package
2629
package-name: |
2730
rmf_traffic

.github/workflows/build.yaml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,33 @@ jobs:
1212
strategy:
1313
matrix:
1414
ros_distribution:
15-
- galactic
15+
- humble
16+
- iron
1617
- rolling
1718
include:
18-
# Galactic Geochelone (May 2021 - November 2022)
19-
- docker_image: ubuntu:focal
20-
ros_distribution: galactic
19+
# Humble Hawksbill (May 2022 - May 2027)
20+
- ubuntu_distribution: jammy
21+
ros_distribution: humble
22+
ros_version: 2
23+
# Iron Irwini (May 2023 - November 2024)
24+
- ubuntu_distribution: jammy
25+
ros_distribution: iron
2126
ros_version: 2
2227
# Rolling Ridley (No End-Of-Life)
23-
- docker_image: ubuntu:jammy
28+
- ubuntu_distribution: jammy
2429
ros_distribution: rolling
2530
ros_version: 2
2631
container:
27-
image: ${{ matrix.docker_image }}
32+
image: osrf/ros:${{ matrix.ros_distribution }}-desktop-${{ matrix.ubuntu_distribution }}
2833
steps:
2934
- name: pwd
3035
run: pwd
3136
- name: setup ROS environment
32-
uses: ros-tooling/setup-ros@v0.3
37+
uses: ros-tooling/setup-ros@0.7.1
3338
with:
3439
required-ros-distributions: ${{ matrix.ros_distribution }}
3540
- name: build
36-
uses: ros-tooling/action-ros-ci@v0.2
41+
uses: ros-tooling/action-ros-ci@0.3.5
3742
with:
3843
target-ros2-distro: ${{ matrix.ros_distribution }}
3944
# build all packages listed in the meta package

.github/workflows/tsan.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ on:
77
jobs:
88
tsan:
99
name: tsan
10-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-22.04
11+
container:
12+
image: osrf/ros:iron-desktop-jammy
1113
steps:
12-
- name: deps
13-
uses: ros-tooling/[email protected]
14-
with:
15-
required-ros-distributions: foxy
14+
- name: install_clang_and_tools
15+
run: sudo apt update && sudo apt install -y clang clang-tools lld wget python3-pip python3-colcon-coveragepy-result python3-colcon-lcov-result lcov
1616
- name: tsan_build_test
17-
uses: ros-tooling/[email protected]
18-
id: tsan_build_test
1917
env:
2018
CC: clang
2119
CXX: clang++
20+
uses: ros-tooling/[email protected]
21+
id: tsan_build_test
2222
with:
23-
target-ros2-distro: foxy
23+
target-ros2-distro: iron
2424
# build all packages listed in the meta package
2525
package-name: |
2626
rmf_traffic

rmf_traffic/QUALITY_DECLARATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ This is assumed to be **Quality Level 4** due to its provided feature documentat
158158
### Target platforms [6.i]
159159

160160
`rmf_traffic` does not support all of the tier 1 platforms as described in [REP-2000](https://www.ros.org/reps/rep-2000.html#support-tiers).
161-
`rmf_traffic` supports ROS Foxy.
161+
`rmf_traffic` supports ROS Iron.
162162

163163
## Security [7]
164164

rmf_traffic/include/rmf_traffic/Trajectory.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,13 @@ class Trajectory::base_iterator
367367
/// \return a copy of the iterator before it was decremented
368368
base_iterator operator--(int);
369369

370+
/// Get the iterator that would be offset from this one by the specified
371+
/// amount
372+
base_iterator operator+(int offset) const;
373+
374+
/// Get the iterator that would be offset from this one by the specified
375+
/// amount in the opposite direction.
376+
base_iterator operator-(int offset) const;
370377

371378
// TODO(MXG): Consider the spaceship operator when we can use C++20
372379

rmf_traffic/include/rmf_traffic/agv/Graph.hpp

Lines changed: 136 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727

2828
#include <vector>
2929
#include <unordered_map>
30+
#include <unordered_set>
3031
#include <optional>
32+
#include <iostream>
3133

3234
namespace rmf_traffic {
3335
namespace agv {
@@ -37,10 +39,80 @@ class Graph
3739
{
3840
public:
3941

40-
class Waypoint
42+
/// Properties related to lifts (elevators) that exist in the graph
43+
class LiftProperties
44+
{
45+
public:
46+
/// Get the name of the lift.
47+
const std::string& name() const;
48+
49+
/// Get the (x, y) location of the lift in RMF canonical coordinates.
50+
Eigen::Vector2d location() const;
51+
52+
/// Get the orientation (in radians) of the lift in RMF canonical
53+
/// coordinates.
54+
double orientation() const;
55+
56+
/// Get the dimensions of the lift, aligned with the lift's local (x, y)
57+
/// coordinates.
58+
Eigen::Vector2d dimensions() const;
59+
60+
/// Get whether the specified position, given in RMF canonical coordinates,
61+
/// is inside the lift. The envelope will expand the footprint of the lift
62+
/// that is used in the calculation.
63+
bool is_in_lift(Eigen::Vector2d position, double envelope = 0.0) const;
64+
65+
/// Constructor
66+
LiftProperties(
67+
std::string name,
68+
Eigen::Vector2d location,
69+
double orientations,
70+
Eigen::Vector2d dimensions);
71+
72+
class Implementation;
73+
private:
74+
rmf_utils::impl_ptr<Implementation> _pimpl;
75+
};
76+
using LiftPropertiesPtr = std::shared_ptr<LiftProperties>;
77+
78+
class DoorProperties
4179
{
4280
public:
81+
/// Get the name of the door.
82+
const std::string& name() const;
83+
84+
/// Get the start position of the door.
85+
Eigen::Vector2d start() const;
86+
87+
/// Get the end position of the door.
88+
Eigen::Vector2d end() const;
89+
90+
/// Get the name of the map that this door is on.
91+
const std::string& map() const;
92+
93+
/// Check if the line formed by p0 -> p1 intersects this door.
94+
bool intersects(
95+
Eigen::Vector2d p0,
96+
Eigen::Vector2d p1,
97+
double envelope = 0.0) const;
98+
99+
/// Constructor
100+
DoorProperties(
101+
std::string name,
102+
Eigen::Vector2d start,
103+
Eigen::Vector2d end,
104+
std::string map);
105+
106+
class Implementation;
107+
private:
108+
rmf_utils::impl_ptr<Implementation> _pimpl;
109+
};
110+
using DoorPropertiesPtr = std::shared_ptr<DoorProperties>;
43111

112+
/// Properties assigned to each waypoint (vertex) in the graph
113+
class Waypoint
114+
{
115+
public:
44116
/// Get the name of the map that this Waypoint exists on.
45117
const std::string& get_map_name() const;
46118

@@ -79,7 +151,6 @@ class Graph
79151
/// Set this Waypoint to be a parking spot.
80152
Waypoint& set_parking_spot(bool _is_parking_spot);
81153

82-
83154
/// Returns true if this Waypoint is a charger spot. Robots are routed to
84155
/// these spots when their batteries charge levels drop below the threshold
85156
/// value.
@@ -88,6 +159,14 @@ class Graph
88159
/// Set this Waypoint to be a parking spot.
89160
Waypoint& set_charger(bool _is_charger);
90161

162+
/// If this waypoint is inside the lift then this will return a pointer to
163+
/// the properties of the lift. Otherwise this will be a nullptr.
164+
LiftPropertiesPtr in_lift() const;
165+
166+
/// Set the properties of the lift that the waypoint is inside of, or
167+
/// provide a nullptr if it is not inside a lift.
168+
Waypoint& set_in_lift(LiftPropertiesPtr properties);
169+
91170
/// The index of this waypoint within the Graph. This cannot be changed
92171
/// after the waypoint is created.
93172
std::size_t index() const;
@@ -119,6 +198,25 @@ class Graph
119198
const std::string& name_format = "%s",
120199
const std::string& index_format = "#%d") const;
121200

201+
/// Get the mutex group that this waypoint is associated with. An empty
202+
/// string implies that it is not associated with any mutex group.
203+
///
204+
/// Only one robot at a time is allowed to occupy any waypoint or lane
205+
/// associated with a particular mutex group.
206+
const std::string& in_mutex_group() const;
207+
208+
/// Set what mutex group this waypoint is associated with. Passing in an
209+
/// empty string will disasscoiate the waypoint from any mutex group.
210+
Waypoint& set_in_mutex_group(std::string group_name);
211+
212+
/// Get a merge radius specific to this waypoint, if it has one. The radius
213+
/// indicates that any robot within this distance of the waypoint can merge
214+
/// onto this waypoint.
215+
std::optional<double> merge_radius() const;
216+
217+
/// Set the merge radius specific to this waypoint.
218+
Waypoint& set_merge_radius(std::optional<double> valeu);
219+
122220
class Implementation;
123221
private:
124222
Waypoint();
@@ -371,8 +469,8 @@ class Graph
371469
template<typename DerivedExecutor>
372470
DerivedExecutor& execute(DerivedExecutor& executor) const
373471
{
374-
return static_cast<DerivedExecutor&>(execute(
375-
static_cast<Executor&>(executor)));
472+
return static_cast<DerivedExecutor&>(
473+
execute(static_cast<Executor&>(executor)));
376474
}
377475

378476
/// Execute this event
@@ -468,6 +566,7 @@ class Graph
468566

469567
/// Construct a default set of properties
470568
/// * speed_limit: nullopt
569+
/// * mutex_group: ""
471570
Properties();
472571

473572
/// Get the speed limit along this lane. If a std::nullopt is returned,
@@ -478,6 +577,17 @@ class Graph
478577
/// indicates that there is no speed limit for the lane.
479578
Properties& speed_limit(std::optional<double> value);
480579

580+
/// Get the mutex group that this lane is associated with. An empty string
581+
/// implies that it is not associated with any mutex group.
582+
///
583+
/// Only one robot at a time is allowed to occupy any waypoint or lane
584+
/// associated with a particular mutex group.
585+
const std::string& in_mutex_group() const;
586+
587+
/// Set what mutex group this lane is associated with. Passing in an
588+
/// empty string will disassociate the lane from any mutex group.
589+
Properties& set_in_mutex_group(std::string group_name);
590+
481591
class Implementation;
482592
private:
483593
rmf_utils::impl_ptr<Implementation> _pimpl;
@@ -589,6 +699,28 @@ class Graph
589699
/// const-qualified lane_from()
590700
const Lane* lane_from(std::size_t from_wp, std::size_t to_wp) const;
591701

702+
/// Add a known lift to the graph. If this lift has the same name as one
703+
/// previously added, we will continue to use the same pointer as the original
704+
/// and override the properties because lift names are expected to be unique.
705+
LiftPropertiesPtr set_known_lift(LiftProperties lift);
706+
707+
/// Get all the known lifts.
708+
std::vector<LiftPropertiesPtr> all_known_lifts() const;
709+
710+
/// Find a known lift based on its name.
711+
LiftPropertiesPtr find_known_lift(const std::string& name) const;
712+
713+
/// Add a known door to the graph. If this door has the same name as one
714+
/// previously added, we will continue to use the same pointer as the original
715+
/// and override the properties because door names are expected to be unique.
716+
DoorPropertiesPtr set_known_door(DoorProperties door);
717+
718+
/// Get all the known doors.
719+
std::vector<DoorPropertiesPtr> all_known_doors() const;
720+
721+
/// Find a known door based on its name.
722+
DoorPropertiesPtr find_known_door(const std::string& name) const;
723+
592724
class Implementation;
593725
private:
594726
rmf_utils::impl_ptr<Implementation> _pimpl;

rmf_traffic/include/rmf_traffic/schedule/Participant.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ class Participant
100100
// TODO(MXG): This function needs to be unit tested.
101101
ItineraryVersion version() const;
102102

103+
/// Get the current progress version for this participant.
104+
ProgressVersion progress_version() const;
105+
103106
/// Get the description of this participant.
104107
const ParticipantDescription& description() const;
105108

rmf_traffic/src/rmf_traffic/Trajectory.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,38 @@ auto Trajectory::base_iterator<SegT>::operator--(int) -> base_iterator
690690
return _pimpl->post_decrement<SegT>();
691691
}
692692

693+
//==============================================================================
694+
template<typename SegT>
695+
auto Trajectory::base_iterator<SegT>::operator+(int offset) const
696+
-> base_iterator
697+
{
698+
const std::size_t N = std::abs(offset);
699+
const bool negative = offset < 0;
700+
701+
base_iterator result = *this;
702+
for (std::size_t i=0; i < N; ++i)
703+
{
704+
if (negative)
705+
{
706+
--result;
707+
}
708+
else
709+
{
710+
++result;
711+
}
712+
}
713+
714+
return result;
715+
}
716+
717+
//==============================================================================
718+
template<typename SegT>
719+
auto Trajectory::base_iterator<SegT>::operator-(int offset) const
720+
-> base_iterator
721+
{
722+
return *this + (-offset);
723+
}
724+
693725
//==============================================================================
694726
#define DEFINE_BASIC_ITERATOR_OP(op) \
695727
template<typename SegT> \

0 commit comments

Comments
 (0)