Skip to content

Commit 0ae3273

Browse files
Merge pull request #12 from DarmawanRobotics/fix/ci-foxy
fix(ci): Foxy build and tests green
2 parents 690e6f8 + cbb786b commit 0ae3273

16 files changed

Lines changed: 77 additions & 38 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,10 @@ jobs:
136136
run: |
137137
apt-get update
138138
rosdep update --rosdistro "$ROS_DISTRO" --include-eol-distros
139-
# python3-loguru has no focal package: installed below
139+
# python3-loguru has no focal package: installed below. HotDog runs on the M20's own
140+
# odometry: dharma_odometry's FAST-LIO / legKILO (and their Livox driver) are not used.
140141
rosdep install --from-paths src --ignore-src -y --rosdistro "$ROS_DISTRO" \
141-
--skip-keys "python3-loguru" > rosdep.log 2>&1 || {
142+
--skip-keys "python3-loguru fast_lio legkilo livox_ros_driver2" > rosdep.log 2>&1 || {
142143
cat rosdep.log
143144
report "rosdep failed ($ROS_DISTRO)" rosdep.log
144145
exit 1

‎docs/HotDog-Technician-Guide.pdf‎

11 Bytes
Binary file not shown.

‎docs/technician/technician-guide.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ gimbal settle time (2.5 s), the thermal samples and, with `acoustic`, the detect
212212
| `near_m`, `dock_clearance_m` | 2.0, 1.0 | where the way back starts and how far before the dock it ends |
213213

214214
An operator pause, the e-stop or REMOTE is never overruled. The way back is the taught route,
215-
reversed from the earliest waypoint near the robot, without stop points, into
215+
reversed from the nearest waypoint of its first pass, without stop points, into
216216
`<site>/patrol/return.csv`; then `charge_start` docks the M20.
217217

218218
## The schedule

‎scripts/setup.sh‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ install_repos() {
135135
}
136136

137137
# python3-loguru has no rosdep rule on Ubuntu 20.04: the tools component installs loguru.
138-
ROSDEP_SKIP=(--skip-keys python3-loguru)
138+
# HotDog runs on the M20's own odometry: dharma_odometry's LiDAR-inertial estimators (FAST-LIO,
139+
# legKILO and the Livox driver they bring) are never started, so they are not installed.
140+
ROSDEP_SKIP=(--skip-keys "python3-loguru fast_lio legkilo livox_ros_driver2")
139141
check_rosdep() {
140142
check_ros > /dev/null || { echo "needs ROS"; return 1; }
141143
[[ -d /etc/ros/rosdep/sources.list.d ]] || { echo "rosdep not initialised"; return 1; }

‎src/hotdog/test/ros/test_launch.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ def include_arguments(actions, package: str) -> dict:
104104
for group in (a for a in actions if isinstance(a, GroupAction)):
105105
for sub in group.get_sub_entities():
106106
if isinstance(sub, IncludeLaunchDescription):
107-
location = Path(sub.launch_description_source.location)
107+
source = sub.launch_description_source
108+
source.get_launch_description(LaunchContext()) # Foxy: location after loading
109+
location = Path(source.location)
108110
if location.parent.parent.name == package:
109111
return {text(k): text(v) for k, v in sub.launch_arguments}
110112
raise AssertionError(f'no include of {package}')

‎src/hotdog_alerts/test/ros/test_alert_node.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def rig(tmp_path, monkeypatch):
5252
executor.add_node(helper)
5353
spinner = Spinner(executor)
5454
assert wait_for(lambda: all(p.get_subscription_count() > 0 for p in pubs.values()), 10.0)
55-
yield tmp_path, api, pubs, test, spinner
55+
yield tmp_path, api, pubs, test, spinner, node
5656
spinner.stop()
5757
helper.destroy_node()
5858
node.destroy_node()
@@ -65,7 +65,7 @@ def kinds(api) -> list:
6565

6666

6767
def test_a_critical_finding_reaches_the_webhook(rig):
68-
tmp_path, api, pubs, _, _ = rig
68+
tmp_path, api, pubs, *_ = rig
6969
folder = tmp_path / '20261101' / '090200_bay1'
7070
folder.mkdir(parents=True)
7171
(folder / 'report.json').write_text(json.dumps(REPORT))
@@ -76,9 +76,10 @@ def test_a_critical_finding_reaches_the_webhook(rig):
7676

7777

7878
def test_patrols_after_start_and_health_errors(rig):
79-
_, api, pubs, _, _ = rig
79+
_, api, pubs, _, _, node = rig
8080
old = PatrolStatus(state=PatrolStatus.DONE, report='/r/20261031/patrol_090000.json')
8181
pubs['patrol'].publish(old) # ended before the node started: not announced
82+
assert wait_for(lambda: old.report in node.patrols, 10.0) # latched: the next replaces it
8283
new = PatrolStatus(state=PatrolStatus.FAILED, report='/r/20261101/patrol_090000.json',
8384
message='lost', site='gi') # fmt: skip
8485
pubs['patrol'].publish(new)
@@ -90,7 +91,7 @@ def test_patrols_after_start_and_health_errors(rig):
9091

9192

9293
def test_the_test_alert(rig):
93-
_, api, _, test, spinner = rig
94+
_, api, _, test, spinner, _ = rig
9495
answer = spinner.call(test, Trigger.Request())
9596
assert answer.success, answer.message
9697
assert wait_for(lambda: 'test' in kinds(api), 10.0)

‎src/hotdog_patrol/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ Every second while a patrol runs:
6868

6969
**The way back** (`patrol/return`, or the watchdog with `abort.return_to_dock`): nothing is
7070
mapped, so the only ground known to be clear is the taught route. The follower is stopped, the
71-
route is cut at the earliest waypoint within `abort.near_m` of the robot (a route out and back
72-
along one walkway returns the short way), reversed without stop points into
71+
route is cut at the nearest waypoint of its first pass within `abort.near_m` of the robot (a
72+
route out and back along one walkway returns the short way), reversed without stop points into
7373
`<site>/patrol/return.csv` and followed, facing the way, to `abort.dock_clearance_m` before
7474
the route's start; then the M20 docks itself (`finish.dock_service`). `patrol/status` shows
7575
`RETURNING`, then the patrol ends `STOPPED` (operator) or `FAILED` (watchdog) with

‎src/hotdog_patrol/config/patrol.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ patrol_node:
2222
max_duration_min: 120.0 # a patrol running longer goes back (0: off)
2323
hold_timeout_sec: 180.0 # blocked this long: back; off the route or not localized: stop
2424
nav_timeout_sec: 5.0 # navigation/status silent this long: the patrol fails
25-
near_m: 2.0 # the way back starts at the earliest route point this near the robot
25+
near_m: 2.0 # the way back starts at the nearest point of the first pass this near
2626
dock_clearance_m: 1.0 # the way back ends this far from the route's start (the dock)
2727
schedule:
2828
enabled: false # live: ros2 param set /patrol_node schedule.enabled true

‎src/hotdog_patrol/hotdog_patrol/core/retreat.py‎

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
The way back to the dock: the taught route walked backwards from where the robot stands.
33
44
Odometry only, nothing is mapped, so the only ground known to be clear is the taught route.
5-
The return starts at the earliest waypoint near the robot (a route out and back along the same
6-
walkway returns the short way), runs back towards the route's start (the dock, where every
7-
route is taught from) without stop points, and ends dock_clearance_m before it: the M20 docks
8-
itself from there (charge_start).
5+
The return starts at the nearest waypoint of the route's first pass near the robot (a route
6+
out and back along the same walkway returns the short way), runs back towards the route's
7+
start (the dock, where every route is taught from) without stop points, and ends
8+
dock_clearance_m before it: the M20 docks itself from there (charge_start).
99
"""
1010

1111
from __future__ import annotations
@@ -20,12 +20,21 @@
2020

2121

2222
def start_index(points: list[RoutePoint], x: float, y: float, near_m: float) -> int:
23-
"""Return the earliest waypoint within near_m of (x, y), else the nearest one."""
23+
"""Return where the way back starts.
24+
25+
The nearest waypoint of the route's first pass within near_m of (x, y), so an out-and-back
26+
route returns the short way; without one, the nearest waypoint.
27+
"""
2428
distances = [math.hypot(p.x - x, p.y - y) for p in points]
25-
for i, d in enumerate(distances):
26-
if d <= near_m:
27-
return i
28-
return min(range(len(points)), key=distances.__getitem__)
29+
near = [i for i, d in enumerate(distances) if d <= near_m]
30+
if not near:
31+
return min(range(len(points)), key=distances.__getitem__)
32+
run = [near[0]]
33+
for i in near[1:]:
34+
if i != run[-1] + 1:
35+
break
36+
run.append(i)
37+
return min(run, key=distances.__getitem__)
2938

3039

3140
def first_beyond(points: list[RoutePoint], distance: float):

‎src/hotdog_patrol/hotdog_patrol/core/session.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class Session:
6161
reason: str = '' # why the patrol returns
6262
inspections: list = field(default_factory=list) # report directories of the points
6363
ignore_before: float = 0.0 # s, follower statuses stamped earlier are not this route's
64+
# (set once the follower accepted the start: a later status is this route's for sure)
6465

6566
@property
6667
def busy(self) -> bool:
@@ -86,8 +87,10 @@ def on_navigation(self, nav_state: int, message: str = '', stamp: float = 0.0) -
8687
NAV_FAILED: (State.FAILED, f'the follower failed: {message}'),
8788
NAV_INACTIVE: (State.STOPPED, 'the follower was stopped'),
8889
}
89-
# a state left from before this patrol's start (not active yet) ends nothing
90-
if not self.active or nav_state not in ends:
90+
# a state left from before this patrol's start ends nothing: this route's are the ones
91+
# after an active state, or stamped after the follower accepted the start
92+
fresh = self.active or 0.0 < self.ignore_before < math.inf
93+
if not fresh or nav_state not in ends:
9194
return False
9295
self.returned = self.state is State.RETURNING and nav_state == NAV_GOAL_REACHED
9396
return self.end(*ends[nav_state])

0 commit comments

Comments
 (0)