Repository navigation
Add chicken head and demo motion modes with a Motion modes panel - #58
yassinsolim wants to merge 14 commits into
Conversation
…und it Switching it on moves the tool tip, in a straight line in joint space and at the selected speed, to a head spot set in xbox_teleop.yaml (30 cm forward, 55 cm up, tool level). It then holds the tip there while the left stick tilts the tool about it and the right stick rolls it, so the shoulder, elbow and wrist swing around a tip that stays put. The sticks are ignored during the approach, and a stick still held on arrival must be centred first. Stop, home and a group change end the mode, it needs every arm joint, and a tilt that reaches the end of its range names the joint that stopped it.
TCP may hand back a frame in pieces, so reading it once made the test fail now and then.
The teleop node serves arm/chicken_head/set_enabled (SetBool) and publishes the mode's state on arm/chicken_head, for the RViz panel that follows. The RViz label reads HEAD while it is on, and the teleop.group and teleop.speed rows describe it.
A checkbox in the right-hand dock, under Arm setup, switches chicken head mode. It reads the latched /arm/chicken_head topic and calls /arm/chicken_head/set_enabled, so the box follows what the teleop node reports rather than the click, and a refusal such as "Press Start first" is shown instead. Like the other panels it sends no motion commands. The Qt-free model has gtests; the panel's height logic moves to panel_fit.hpp so the setup panel and this one share it, and this panel also refuses spare height so the dock gives it to the panels beside it. The layout's saved window state is rebuilt for the new dock.
The hold message said "left stick" and "right stick" whatever chicken_head.axes held. It now names the configured inputs. Two tests tie the RViz panel to the node: the topic, service and row names, and every state the node publishes, must be the ones the panel's model reads.
Switching the mode off from RViz while a stick was still held let the active group's mapping take that stick at once: in the test the shoulder swung 29 degrees in a second. The mode now holds the arm until the sticks are centred, as pressing Y already does, and says so. With the sticks centred nothing waits and the note stays.
Each joint swings sinusoidally about the pose the arm is in when the mode starts, at its own rate, so the motion does not repeat before a 120 s loop is over. The swing grows from nothing over a minimum-jerk ramp and shrinks back over one when the mode is switched off, which returns the arm to exactly the pose it began from. The ramp can be reversed at any moment without a jump in speed or acceleration, and a short trip takes proportionally less time. It goes through the same path as the sticks (acceleration limit, joint limits, collision check), so it can run on the real arm. It needs Start, the sticks do nothing, B, Start, Y, A and a lost controller end it at once, and the speed level can slow it but never speed it up. A joint that is locked or switched off stays still, one near a limit swings less, and a swing whose extremes would reach the table or the base is made smaller or refused. If a step runs into something anyway the mode ends and holds the arm. The settings are refused at load if a joint could exceed max_speed_deg_s. With the defaults, joints peak at about 7 deg/s, 3 deg/s2, and the tool tip at under 10 cm/s.
arm/demo/set_enabled (std_srvs/SetBool) switches the mode and answers with why it cannot start, and arm/demo carries its state (off, running, stopping or unavailable) and what is going on, republished every 0.5 s like the chicken head topic. A mode that stopped itself keeps saying why as a warning until it is switched on again. The RViz label shows DEMO, and the diagnostics rows show the demo's own speed limit.
A second mode would have meant a second panel that copied the first one. The panel now has a row for each motion mode, built from a table in mode_model.cpp: the row, topic and service the teleop node uses for it, the words for its states, and which of them count as on. Chicken head is the only row for now, and behaves as before: the same 19 real-mouse checks in RViz pass. A row whose report is marked as a warning is shown in the warning colour, and the waiting message is shown once for the panel instead of in every row. The layout's saved window state is rebuilt for the new name, from the state before chicken head so that it carries no stale dock.
A second row, built from a second table in mode_model.cpp: /arm/demo and /arm/demo/set_enabled, with the states off, running, stopping (shown as returning, and not ticked, so ticking the box again resumes the demo) and unavailable. The refusal shows in the panel, for example "Switch Chicken head off first", and a demo that stopped because something was in the way keeps saying so in the warning colour. Checked in real RViz with real mouse clicks on the simulated station: refused before Start, runs, chicken head refused while it runs, sticks do nothing, D-pad down halves the pace, unticking brings every joint back to its start pose (0.000 deg off), ticking during the return resumes, B and a lost controller end it and the box follows. Measured from the simulated drives, joints peak at 6.3 deg/s, the tool tip at 7.8 cm/s, and the arm follows the command to 0.014 deg rms.
The drive-health stall check needs the encoder to move at least 1 degree in 2 seconds while motion is commanded, but any nonzero commanded speed counted as motion. A joint told to crawl, such as one at the end of a slow swing, covers less than that even when it does exactly what it is told, so it was reported STALLED: a drive row in ERROR for a second at a time, with the setup guide flipping to "Checking the drives". Demo mode made it show up: on the simulated drives the base, shoulder and wrists were flagged at the start and the end of every swing. The drive node now passes motion as commanded only when the commanded output speed would cover 1.5 times the stall distance in the stall window. A drive that does not move at a walking pace is still called stalled, as before, and a large error is still caught as a following error. With this, 135 s of demo mode on the simulated drives produced no health change at all.
Wander.rollback was meant for pausing the demo when a step is refused, but the mode ends and holds the arm instead, so nothing used it. A demo that stopped now says "blocked by" followed by what stopped it, which reads right for a link in the way as well as a joint limit.
That branch only gained a merge of main, which changes no file, so the merge keeps this branch's files as they are.
Screenshots from a real RViz window with the simulated drives: demo mode running, chicken head refused while it runs, and demo mode refused before Start. They show what the panel says in each case, so an operator can match it against what they see.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
There was a problem hiding this comment.
🟡 Changes recommended
Pressing A can leave either mode active and moving when started from the incision group with the tool withdrawn, while premature relay disconnects can hang the echo test indefinitely.
2 open issues
What changed in this PR
Adds chicken head tip-holding and autonomous demo motion to the existing teleop system, with a shared RViz panel for control and status.
Changes:
- Adds configurable motion modes, ROS services and status topics, safety checks, and controller handover behavior.
- Integrates the Motion modes panel into the ground station layout.
- Expands tests and operator guidance, adjusts slow-motion stall detection, and handles fragmented relay echoes in testing.
| File | Description |
|---|---|
waybionic_teleop/waybionic_teleop/xbox_teleop_node.py |
Exposes mode services, status topics, and diagnostics. |
waybionic_teleop/waybionic_teleop/wander.py |
Generates demo swings and reversible ramps. |
waybionic_teleop/waybionic_teleop/teleop.py |
Implements mode configuration, motion, and transitions. |
waybionic_teleop/waybionic_teleop/sim_arm_drives_node.py |
Qualifies stall detection by commanded speed. |
waybionic_teleop/waybionic_teleop/demo_mode.py |
Defines the demo status contract. |
waybionic_teleop/waybionic_teleop/chicken_head.py |
Defines the chicken head status contract. |
waybionic_teleop/test/test_xbox_teleop_node.py |
Tests mode services, reporting, and controller-loss handling. |
waybionic_teleop/test/test_wander.py |
Tests ramps, swing bounds, and tempo changes. |
waybionic_teleop/test/test_sim_arm_drives_node.py |
Tests stall detection during slow motion. |
waybionic_teleop/test/test_motion_modes_panel.py |
Checks Python and C++ mode contracts agree. |
waybionic_teleop/test/test_demo_mode.py |
Tests demo motion, limits, and transitions. |
waybionic_teleop/test/test_chicken_head.py |
Tests approach, tip holding, and handover. |
waybionic_teleop/test/test_carrier_relay.py |
Collects fragmented TCP echo responses. |
waybionic_teleop/test/conftest.py |
Makes the parameter fixture session-scoped. |
waybionic_teleop/config/xbox_teleop.yaml |
Adds default settings for both modes. |
waybionic_rviz_plugins/test/test_mode_model.cpp |
Tests status parsing and mode definitions. |
waybionic_rviz_plugins/src/setup_panel.cpp |
Reuses the shared panel-height helper. |
waybionic_rviz_plugins/src/motion_modes_panel.cpp |
Implements mode switches and status display. |
waybionic_rviz_plugins/src/mode_model.cpp |
Defines mode tables and status parsing. |
waybionic_rviz_plugins/src/ground_station_rviz.cpp |
Places Motion modes in the right dock. |
waybionic_rviz_plugins/README.md |
Documents the panel and mode contracts. |
waybionic_rviz_plugins/plugin_description.xml |
Registers the Motion modes plugin. |
waybionic_rviz_plugins/include/waybionic_rviz_plugins/panel_fit.hpp |
Shares width-aware panel-height sizing. |
waybionic_rviz_plugins/include/waybionic_rviz_plugins/motion_modes_panel.hpp |
Declares panel state and ROS interfaces. |
waybionic_rviz_plugins/include/waybionic_rviz_plugins/mode_model.hpp |
Declares mode definitions and parsing interfaces. |
waybionic_rviz_plugins/CMakeLists.txt |
Builds the panel, model, and model tests. |
waybionic_bringup/rviz/waybionic_unified.rviz |
Adds the panel and updates saved geometry. |
docs/operator_guide.md |
Explains mode operation, controls, and safety precautions. |
Review effort: Balanced
| if homing and not incision: | ||
| self.end_head() | ||
| self.end_demo() |
| client.sendall(frame) | ||
| echoed = b'' | ||
| while len(echoed) < len(frame): | ||
| echoed += client.recv(64) |
dda292a to
f720fbc
Compare
a657769 to
3b8466e
Compare


Adds two motion modes to teleop, switched from a new Motion modes RViz panel:
What it adds
Chicken head mode
xbox_teleop.yaml(30 cm forward, 55 cm up, tool level), then holds the tip there. The sticks are ignored during the approach, and a stick still held on arrival has to be centred first.arm/chicken_head/set_enabled(std_srvs/SetBool) switches it andarm/chicken_head(latched) reports it.Demo mode
max_speed_deg_s(12) are refused when teleop starts. The speed level can slow the demo but never speeds it up.arm/demo/set_enabledswitches it, andarm/demoreportsoff,running,stoppingorunavailable, republished every 0.5 s.The Motion modes panel
ModeSpectable inmode_model.cpp: the topic and service the teleop node uses, the words for its states and which of them count as on. A third mode is a table entry plus a ROS contract module inwaybionic_teleop(test_motion_modes_panel.pychecks that the two agree).Refusals say why. Only one mode runs at a time:
A drive-health change that affects real drives: false STALLED reports
The stall check needs the encoder to move at least 1 degree in 2 seconds while motion is commanded, but any non-zero commanded speed counted as motion. A joint told to crawl, such as at the end of a slow swing, covers less than that even when it does exactly what it is told, so it was reported STALLED (a drive row in ERROR for a second at a time, and the setup guide flipping to "Checking the drives"). Demo mode made it visible on the simulated drives.
sim_arm_drives_nodenow passesmotion_commandedonly when the commanded output speed would cover 1.5 times the stall distance in the stall window, which is 0.75 deg/s with the current thresholds. Trade-off to review: a drive commanded slower than that is no longer checked for a stall, because the slow end of a swing cannot be told apart from a stuck joint. Stalls at normal speeds are still caught.Also
docs/operator_guide.mdand the RViz plugin README describe both modes; the guide now shows the panel (screenshots indocs/images/, about 460 KB each).How it was tested
docker compose --progress plain build test) on this branch's last code commit: 1747 tests, 0 failures. GitHub CI runs on this PR.Known gaps