Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/motion_modes_demo_running.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 71 additions & 1 deletion docs/operator_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ before starting the SDL bridge.
| Incision group: left stick up/down | Insert or withdraw the tool along its own axis |
| Incision group: right stick up/down | Tilt the tool about the incision point |
| Incision group: right stick left/right | Tool roll |
| Chicken head mode: left stick up/down | Tilt the tool about the held tip (the D-pad left/right tilt it too) |
| Chicken head mode: right stick left/right | Tool roll |
| Demo mode: sticks | Nothing: the demo moves the arm (RT / LT still work the tool) |
| RT / LT | Close / open the placeholder end effector |
| D-pad up/down | Speed: 10, 25, 50 or 100% of 60 deg/s, or of 50 mm/s and 30 deg/s of tilt in the Cartesian and incision groups |
| A (hold) | Return to the zero pose (not in the incision group) |
Expand Down Expand Up @@ -176,6 +179,72 @@ incision. With five joints, the tool can only tilt in the arm's vertical plane.
stops rather than pull the tool back: press Y, withdraw the tool in another group,
then select the incision group again.

**Chicken head mode** holds the tool tip at one spot while the rest of the arm moves around
it, as a chicken keeps its head still. Press Start first, then tick **Chicken head mode** in
the Motion modes panel (right-hand dock, under Arm setup). The same switch is the
`/arm/chicken_head/set_enabled` service (`std_srvs/SetBool`), and its state is on the latched
`/arm/chicken_head` topic. The arm moves every joint in a straight line to the head spot, at
the current speed level, which takes a few seconds, and then holds it there. The default spot
is 30 cm in front of the base and 55 cm up, with the tool pointing forward (`chicken_head` in
`xbox_teleop.yaml`). Once the panel says *holding*, centre the sticks: the left stick tilts the
tool and the right stick rolls it. The shoulder, elbow and wrist swing as far as the tilt needs,
and in simulation the tip stays within half a millimetre of the spot.

- The panel refuses, and says why, when teleop is not enabled, when a joint is locked or
switched off (the mode needs J1 to J5), when the tool is inserted through the incision
point, or when the head spot is out of reach of the arm's joint limits.
- The mode ends, and the arm holds where it is, when you untick the box, press B, press Y
(which also selects the next group) or A, stop teleop with Start, or the controller drops
out.
- Something in the way, such as the table or the base, stops the approach. After 1.5 s the
panel says *blocked* and names the joint. A tilt that reaches a joint limit stops there and
names the joint, and the tip stays held.
- The approach moves all five joints at once, so on a real arm try it first at a low speed
with the stop within reach.

**Demo mode** moves the arm around by itself, slowly and smoothly, to show it off or to look it
over. Press Start first, then tick **Demo mode** in the Motion modes panel. The same switch is the
`/arm/demo/set_enabled` service (`std_srvs/SetBool`), and its state is on the latched `/arm/demo`
topic (`off`, `running`, `stopping` or `unavailable`). Each joint swings about the pose the arm was
in when you ticked the box, at its own pace, so the motion does not repeat for two minutes. The
swing grows over 12 seconds, and when you untick the box it shrinks over as long, which brings the
arm back to exactly the pose it started from (the panel says *returning*). Ticking the box again
while it returns carries on from there. With the settings in `xbox_teleop.yaml` (`demo`), no joint
is commanded to go faster than 7 deg/s or to speed up or slow down by more than 3 deg/s each
second, and the tool tip stays under 8 cm/s. Through the simulated drives the arm follows that path
to within 0.2 degrees.

![The Motion modes panel while demo mode runs](images/motion_modes_demo_running.png)

Only one mode runs at a time, and the panel says why a mode is refused. While demo mode runs,
chicken head is refused; before Start has been pressed, demo mode is:

![Chicken head refused while demo mode runs](images/motion_modes_chicken_head_refused.png)

![Demo mode refused until Start is pressed, with the Arm setup panel above the Motion modes panel](images/motion_modes_refused_before_start.png)

- It is not the other two demos. `autoplay:=true` (the self-running demo, above) plays a scripted
controller, presses Start itself and runs only on simulated drives. `demo_mode:=true` sweeps each
joint once to check the TF, also in simulation only. Demo mode needs your Start press and is
checked like any other motion, so it can run on the real arm.
- The sticks do nothing, and D-pad down slows it to half and then a fifth of its pace, including the
start and the return. D-pad up never speeds it up.
- B, Start, Y, A or losing the controller end it at once and hold the arm where it is, as they do
for any motion. Unticking the box is the gentle way out.
- The arm stays 10 degrees clear of its joint limits. A joint that is locked or switched off stays
still, and one with less than 3 degrees of room does too. If a link would reach the table or the
base at the extremes of the swing, the whole swing is made smaller, and if no size fits the panel
says what is in the way and the mode does not start. If a step runs into something anyway, the
mode ends, the arm holds, the controller rumbles and the panel says why until you start it again.
- It is refused, with the reason, until teleop is enabled, while chicken head mode is on (and the
other way round), and while the tool is through the incision point. If you untick it while still
holding a stick, the sticks have to be centred before they move the arm.
- The swing of each joint, its pace, the time to grow and shrink and the speed limit are in the
`demo` section of `xbox_teleop.yaml`. Settings that would let a joint go faster than
`max_speed_deg_s` are refused when teleop starts.
- On the real arm it moves by itself: keep the emergency stop within reach, and press D-pad down
twice before the first run to see it at a fifth of its pace.

### Joint limits and collision checks

The current arm URDF has provisional joint limits, and the collision checks model
Expand Down Expand Up @@ -224,7 +293,8 @@ again whenever the controller has been left alone for 30 seconds. The arm lifts,
draws a square and a vertical line with the tool tip, and tilts the tool about its
tip, with the path and a caption in RViz. Touching any button, stick or trigger
stops the demo and leaves teleop disabled; press Start to drive the arm yourself.
The demo runs only with simulated drives.
The demo runs only with simulated drives. To see the real arm move around by itself, use
[Demo mode](#how-teleop-behaves) instead.

- **Windows:** double-click `scripts\windows-demo.cmd`. It starts Docker Desktop if
needed, opens the controller bridge in its own window if Python 3 is installed,
Expand Down
6 changes: 5 additions & 1 deletion waybionic_bringup/rviz/waybionic_unified.rviz
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Panels:
SyncSource: ""
- Class: waybionic_rviz_plugins/SetupPanel
Name: SetupPanel
- Class: waybionic_rviz_plugins/MotionModesPanel
Name: MotionModesPanel
- Class: waybionic_rviz_plugins/JointControlPanel
Name: JointControlPanel
- Class: waybionic_rviz_plugins/DiagnosticsPanel
Expand Down Expand Up @@ -214,14 +216,16 @@ Window Geometry:
collapsed: false
JointControlPanel:
collapsed: false
MotionModesPanel:
collapsed: false
SetupPanel:
collapsed: false
Displays:
collapsed: false
Height: 800
Hide Left Dock: false
Hide Right Dock: false
QMainWindow State: 000000ff00000000fd0000000300000000000000fa000002b4fc0200000001fc00000014000002b40000007601000023fa000000000200000004fb000000100044006900730070006c0061007900730100000000ffffffff0000005200fffffffb0000000a005600690065007700730100000000ffffffff0000005200fffffffb0000001200530065006c0065006300740069006f006e0100000000ffffffff0000005200fffffffb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000000ffffffff0000005200ffffff00000001000001b8000002b4fc0200000003fb000000140053006500740075007000500061006e0065006c0100000014000000970000005200fffffffb00000022004a006f0069006e00740043006f006e00740072006f006c00500061006e0065006c01000000b1000000970000005200fffffffb000000200044006900610067006e006f0073007400690063007300500061006e0065006c010000014e0000017a0000005200ffffff000000030000050000000052fc0100000001fb0000000800540069006d00650100000000000005000000003d00ffffff00000242000002b400000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
QMainWindow State: 000000ff00000000fd0000000300000000000000fa000002b4fc0200000001fc00000014000002b40000004e01000023fa000000000200000004fb000000100044006900730070006c0061007900730100000000ffffffff0000002a00fffffffb0000000a005600690065007700730100000000ffffffff0000002a00fffffffb0000001200530065006c0065006300740069006f006e0100000000ffffffff0000002a00fffffffb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000000ffffffff0000002a00ffffff00000001000001b8000002b4fc0200000004fb000000140053006500740075007000500061006e0065006c0100000014000000870000002a00fffffffb00000020004d006f00740069006f006e004d006f00640065007300500061006e0065006c01000000a1000000430000002a00fffffffb00000022004a006f0069006e00740043006f006e00740072006f006c00500061006e0065006c01000000ea000000870000002a00fffffffb000000200044006900610067006e006f0073007400690063007300500061006e0065006c0100000177000001510000002a00ffffff000000030000050000000052fc0100000001fb0000000800540069006d00650100000000000005000000003d00ffffff00000242000002b400000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
Selection:
collapsed: false
Time:
Expand Down
17 changes: 17 additions & 0 deletions waybionic_rviz_plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,19 @@ add_library(${PROJECT_NAME} SHARED
include/waybionic_rviz_plugins/diagnostics_panel.hpp
include/waybionic_rviz_plugins/joint_control_model.hpp
include/waybionic_rviz_plugins/joint_control_panel.hpp
include/waybionic_rviz_plugins/mode_model.hpp
include/waybionic_rviz_plugins/motion_modes_panel.hpp
include/waybionic_rviz_plugins/motion_test_panel.hpp
include/waybionic_rviz_plugins/panel_fit.hpp
include/waybionic_rviz_plugins/ros_diagnostics_source.hpp
include/waybionic_rviz_plugins/setup_model.hpp
include/waybionic_rviz_plugins/setup_panel.hpp
src/diagnostics_panel.cpp
src/joint_control_model.cpp
src/joint_control_panel.cpp
src/mock_diagnostics_source.cpp
src/mode_model.cpp
src/motion_modes_panel.cpp
src/ros_diagnostics_source.cpp
src/motion_test_panel.cpp
src/setup_model.cpp
Expand Down Expand Up @@ -169,6 +174,18 @@ if(BUILD_TESTING)
)
ament_target_dependencies(test_setup_model diagnostic_msgs)
endif()

ament_add_gtest(test_mode_model
test/test_mode_model.cpp
src/mode_model.cpp
TIMEOUT 60
)
if(TARGET test_mode_model)
target_include_directories(test_mode_model PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
)
ament_target_dependencies(test_mode_model diagnostic_msgs)
endif()
endif()

ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET)
Expand Down
37 changes: 29 additions & 8 deletions waybionic_rviz_plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ colcon test-result --verbose

## Operator panels

Both panels are in the ground station's right-hand dock, above the diagnostics panel
The panels are in the ground station's right-hand dock, above the diagnostics panel
(`ground_station_rviz` stacks them; a plain `rviz2` leaves them wherever the layout puts them).
It also puts the joint control and diagnostics panels in scroll areas, so that the three together
do not make the window taller than a laptop screen; the setup panel asks for the height its text
needs and does not scroll.
It also puts the joint control and diagnostics panels in scroll areas, so that the panels together
do not make the window taller than a laptop screen; the setup and motion modes panels ask for the
height their text needs (`fitPanelHeight`) and do not scroll.

**Arm setup** (`waybionic_rviz_plugins/SetupPanel`) lists the start-up steps the `setup_guide`
node publishes on the latched `/arm/setup` topic (a DiagnosticArray of `setup.<step>` rows:
Expand All @@ -61,17 +61,32 @@ is off is held by the drive node, which refuses a change while the arm is enable
shows that refusal and leaves the box as the topic says. A joint with no drive is shown but
cannot be switched.

Both publishers repeat their message every 0.5 s, so three seconds of silence greys a panel out
as waiting. The parsing of each topic lives in a Qt-free unit (`joint_control_model.*`,
`setup_model.*`) with gtests that build fabricated messages.
**Motion modes** (`waybionic_rviz_plugins/MotionModesPanel`) has one checkbox for each mode in which
the teleop node moves the arm by itself. Chicken head mode holds the tool tip at a preset spot while
the sticks tilt and roll the tool, and demo mode moves the arm around slowly and smoothly. Each mode
has a latched topic with one row whose `state` says what it is doing (`/arm/chicken_head`: `off`,
`approach`, `hold`, `blocked` or `unavailable`; `/arm/demo`: `off`, `running`, `stopping` or
`unavailable`) and whose message says what is going on, and a `std_srvs/SetBool` service the panel
calls when the box is clicked (`/arm/chicken_head/set_enabled`, `/arm/demo/set_enabled`). As in the
joint control panel, a box follows the topic, not the click: a refusal such as "Press Start first"
is shown for a few seconds and the box stays as it was, and a row that is a warning, such as a demo
that stopped because something was in the way, is shown in the warning colour. The panel sends only
the switches, never a motion command; the teleop node moves the arm. The modes, their topics and the words for their states are one table
each in `mode_model.cpp` (`ModeSpec`), and a test in `waybionic_teleop` keeps the table in step with
the node's own module for the mode. Adding a mode to the panel is adding a table.

All three publishers repeat their message every 0.5 s, so three seconds of silence greys a panel
out as waiting. The parsing of each topic lives in a Qt-free unit (`joint_control_model.*`,
`setup_model.*`, `mode_model.*`) with gtests that build fabricated messages.

## Package Layout

```text
waybionic_rviz_plugins/
CMakeLists.txt # Builds the shared RViz plugin library + tests
package.xml # Generic deps only; no Annin/AR4 exec deps
plugin_description.xml # Registers DiagnosticsPanel, SetupPanel, JointControlPanel, MotionTestPanel
plugin_description.xml # Registers DiagnosticsPanel, SetupPanel, MotionModesPanel, JointControlPanel,
# MotionTestPanel
scripts/
temporary_diagnostics_publisher.py
diagnostics_recorder.py
Expand All @@ -82,6 +97,9 @@ waybionic_rviz_plugins/
joint_control_model.hpp # Qt-free parsing of /arm/joint_control
joint_control_panel.hpp # Joint on/off checkboxes
mock_diagnostics_source.hpp
mode_model.hpp # Qt-free parsing of the motion mode topics
motion_modes_panel.hpp # Motion mode checkboxes
panel_fit.hpp # Height a panel asks of its dock
ros_diagnostics_source.hpp
setup_model.hpp # Qt-free parsing of /arm/setup
setup_panel.hpp # Start-up steps and the Zero button
Expand All @@ -90,6 +108,8 @@ waybionic_rviz_plugins/
joint_control_model.cpp
joint_control_panel.cpp
mock_diagnostics_source.cpp
mode_model.cpp
motion_modes_panel.cpp
ros_diagnostics_source.cpp
setup_model.cpp
setup_panel.cpp
Expand All @@ -101,6 +121,7 @@ waybionic_rviz_plugins/
test/
test_package_metadata.py
test_joint_control_model.cpp # /arm/joint_control parsing
test_mode_model.cpp # Motion mode topic parsing
test_ros_diagnostics_source.cpp # Live/mock source handoff stress tests
test_setup_model.cpp # /arm/setup parsing
docs/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#ifndef WAYBIONIC_RVIZ_PLUGINS__MODE_MODEL_HPP_
#define WAYBIONIC_RVIZ_PLUGINS__MODE_MODEL_HPP_

#include <chrono>
#include <optional>
#include <string>
#include <vector>

#include <diagnostic_msgs/msg/diagnostic_array.hpp>

namespace waybionic_rviz_plugins
{

/// The teleop node republishes every mode's state every 0.5 s and on every change, so this long
/// without a message means it is gone.
constexpr std::chrono::milliseconds kTeleopQuietAfter{3000};

/// How a state is shown beside its checkbox.
enum class Tone
{
Quiet,
Active,
Warning
};

/// One state a mode reports on its topic.
struct ModeState
{
/// As published, for example "hold".
std::string name;
/// Shown beside the checkbox.
std::string word;
/// The mode counts as switched on, so its checkbox is ticked.
bool on{false};
Tone tone{Tone::Quiet};
};

/// A mode the teleop node switches on and off for the operator: where it reports and what it says.
struct ModeSpec
{
/// Name of the row on the topic, for example "chicken_head".
std::string row;
/// Text of the checkbox.
std::string label;
/// What the mode does; shown while the node has nothing else to say about it.
std::string hint;
/// Latched topic with one row, and the std_srvs/SetBool service that switches the mode.
std::string topic;
std::string service;
std::vector<ModeState> states;
};

struct ModeSnapshot
{
bool valid{false};
/// The state reported; meaningful only when `valid`.
ModeState state;
/// What is going on, or what is wrong; may be empty while the mode is off.
std::string message;
/// The row's level was a warning: the mode cannot be used, or stopped by itself.
bool warning{false};
/// Summary of the problem when the report is not valid; empty otherwise.
std::string error;
};

/// Chicken head mode: the tool tip is held at a spot while the sticks tilt and roll the tool.
const ModeSpec & chickenHeadSpec();

/// Demo mode: the arm moves around slowly by itself, and comes back to where it started.
const ModeSpec & demoSpec();

/// The modes in the order the panel lists them.
const std::vector<const ModeSpec *> & modeSpecs();

/// Reads one mode's message. Never throws: a malformed message is reported through `valid` and
/// `error` so the caller can keep showing the last good one.
ModeSnapshot parseMode(const diagnostic_msgs::msg::DiagnosticArray & array, const ModeSpec & spec);

/// True when the teleop node should be treated as gone: nothing has been received, or the last
/// message is at least kTeleopQuietAfter old.
bool teleopQuiet(
const std::optional<std::chrono::steady_clock::time_point> & last_message,
std::chrono::steady_clock::time_point now);

/// What the panel says while a mode has no report to show. `seen_report` is whether a valid
/// report has ever arrived, and `teleop_quiet` is teleopQuiet().
std::string modeWaitingMessage(bool seen_report, bool teleop_quiet);

} // namespace waybionic_rviz_plugins

#endif // WAYBIONIC_RVIZ_PLUGINS__MODE_MODEL_HPP_
Loading