Skip to content

2. The GUI for runs

A GUI to set up a training run, start it, watch the robot learn, stop it when it goes wrong, and compare runs, without writing a script. It trains with the same environments and the same PPO of Stable-Baselines3 as the training chapter; the GUI is only a way to set the run up and to look at what it writes. The video tour on the ReDySim website (about 6 minutes, with voice and captions) shows a run being set up, watched, continued and compared.

Ten tasks are in the GUI: the fixed-base joint_reach, task_reach, acrobot_swing_up, cartpole_balance, cartpole_swing_up and platform_reach (the 3-RRR parallel robot), and the floating-base space_reach, wheeled_nav, car_parking and quadruped_velocity, each with its own reward terms, observation signals and replay (the space robot with its base drawn as a box, the wheeled robot seen from above between its obstacles, the parking car seen from above in its street with the parked cars and its path, the quadruped from the side with the view following it). The first five were trained through the GUI, as described below. The quadruped was trained there too: with the default reward and 15 M steps (the default is 3 M) a run walks with short, quick steps on all four legs, each foot landing about seven times a second and lifting 2 to 5 cm, and follows commands of 0.3 to 0.5 m/s (100 % of 256 new commands; 17 minutes on 4 cores; see the limits).

Start it

pip install torch --index-url https://download.pytorch.org/whl/cpu   # Linux only: CPU build, 1.0 GB instead of 5.4 GB (first)
pip install "./redysim_rl-1.0[gui]"     # adds PySide6, matplotlib, SB3, PyTorch
redysim-rl-gui                          # or: python -m redysim_rl.gui
redysim-rl-gui my_run.yaml              # start from the settings of a run file

Training runs in a separate process, so the GUI stays responsive while it works. That process is started with the Python named in Files > Python for training (by default the one that started the GUI); it needs redysim_rl, Stable-Baselines3 and the floating-base package (the gui extra asks for it, and the fixed-base and floating-base packages are installed before it).

The GUI

The GUI: the settings of a run on the left, the replay and the result tabs on the right

The window has the look of the ReDySim GUI. The bar at the top holds buttons only: Open run file, Save run file, Compare runs, Save curves, Delete run (it removes the run shown in the Replay tab from the disk, after asking, and not while that run trains), and, on the right, Help (F1), About, Larger text (for a projector), Full screen (F11) and Dark mode. Under it the left half sets the run up and the right half shows what it did.

Left: the run. The settings are three tabs, each with a banner that says what it holds. Below them are New run, From policy, Continue, Load run settings and Stop, the progress bar with the time left, and the log.

Every number is typed in a box; it changes only when you type it (no arrows, and the mouse wheel does nothing). A box takes 0.05, 3e-4 or 1_000_000, and an angle in radians also as pi/36, radians(5) or 5d (5 degrees; shown as radians(5) when you leave the box). A wrong or out-of-range value turns the box red and its tip says why; a run does not start until it is put right, and the message names the box.

Problem and files has the Problem card (robot, task, action mode, seed; the robot narrows the list of tasks to the ones it can do), the Files card (run name, Python for training, runs folder), the signals the policy sees, what it commands (a list, nothing to set: how many numbers, what they mean, the force law and the force limit), and This run, a summary of what pressing New run will do. Everything that Continue keeps fixed (robot, task, action mode, observation signals) is on this tab:

The Problem and files tab, with the This run card

row of This run what it says
Training the total steps, the robots in parallel, the cores and the number of checkpoints
Learner how many PPO updates the run makes, how many samples each learns from, and how many passes over them
Episodes about how many episodes the run has, and the longest one, in seconds and in steps
Ends when an episode ends besides the maximum length (a crash, a fall, and so on)
Success what counts as a success in the tests

Reward has one row for every term of the reward: its name, its weight (untick a term to switch it off) and a line with what it computes. The settings (the tolerances, the width of the speed term) are listed below the weights:

The Reward tab

Learner and compute has the Compute card and the Learner card:

The Learner and compute tab

card what it sets
Compute the total steps, the number of robots simulated in parallel, the maximum episode length (in seconds; the steps it works out to are shown beside it), the number of checkpoints, and the cores (a warning appears above 4)
Learner (PPO) the PPO settings, with a drop-down of named settings: ReDySim tuned (the default for the task) and SB3 standard (the library's own defaults); beside them, how many samples one update learns from, in how many minibatches

Right: the results. Six tabs in the order of the work, with the Run and Checkpoint boxes in the Replay tab and a short result line below the tabs (the checkpoint's success, error and return, the final test and the best checkpoint). The Legend box hides the legend of the curves.

tab what it shows
Replay the robot of the run chosen in the Run box (only the runs of the chosen robot and task are listed), as an animation, with Play, the speed, Loop (off: the episode plays once and stops; on: it repeats), New goals and Save animation
Success and error the success rate and the final error at every checkpoint, with the do-nothing baseline
Return by term the return of an episode split into the terms of the reward
Checkpoints a table of all the checkpoints, the best one marked; a click on a row replays that checkpoint
Episode one episode of the run shown, in the same three parts for every task: the measures its success is judged on (each with its tolerance as a dashed line), the actions of the policy, and the reward of each step split into its terms; a line follows the replay
Compare runs the curves, the final numbers and the settings of several runs (see below)

The Replay tab: the robot of a checkpoint

The Success and error tab

The Return by term tab

The Checkpoints tab

The Episode tab

A first run

  1. Leave the task at joint_reach and press New run. The GUI writes the settings to ~/redysim_rl_runs/joint_reach_3link/ (the run is named after the task and the robot; type another name if you like) and starts training.
  2. At every checkpoint the policy is tested, and the replay switches to the new checkpoint and plays it (Follow latest is on by default), while the curves grow. The first one is the untrained policy.
  3. Press Stop whenever the behaviour looks wrong, to change the reward and start again, or let it run to the end.

With the default settings (1 000 000 steps, 64 robots, 4 cores, 20 checkpoints) the run takes about 70 seconds.

The defaults are the best known settings, for at most 3 M steps. Each task and robot starts from the settings of the best run made with it, with no more than 3 000 000 steps, so a first run stays short. Where that run needed more, the table says how far 3 M gets: train on with Continue (or set more steps) to go further.

task, robot default success at the default success with more steps
joint_reach, three_link 1 M 97.7 %
joint_reach, kinova_gen3lite 2 M (bonus 2) 98.4 %
task_reach, three_link 2 M 99.2 %
task_reach, kinova_gen3lite 3 M about 3 % 94.5 % after 12 M
acrobot_swing_up, two_link 3 M (impedance, start_up 0.4) about 21 % 98.4 % after 15 M
cartpole_balance, pr 1.5 M (bonus 2) 100 %
cartpole_swing_up, pr 3 M about 40 % 100 % after 3.5 M
platform_reach, planar_3rrr 1 M 100 %
space_reach, satellite_arm7 3 M (w_base 0) 96.1 %
space_reach, space_robot 3 M low about 73 % after 20 M, from a trained policy
wheeled_nav, pioneer 3 M about 84 % 93.8 % after 5.4 M
quadruped_velocity, quadruped 3 M about 88 % 100 % after 3.8 M
car_parking, four_wheel_car 3 M 100 %

Each is one run with one seed: a new run may land a few points lower.

Reading the results

  • Checkpoint tests. At each checkpoint the policy is tested on 128 robots, each with its own random goal; the goals are the same at every checkpoint, so the curves compare like with like. The replay keeps seven of those robots (the Episode box): the two that did best (a success first, then the smallest error), the two that did worst (a failure first, then the largest error) and three picked at random among the others, so you see what the policy does well, how it fails and what it does on a typical goal. (Runs stored before keep the three best and the two worst.)
  • Success rate is the share of the test robots that are within the tolerance of the goal at the last step of the episode. A robot that reached the goal and drifted away counts as a failure. The tolerance is the within value in the Reward card.
  • Final error is the mean distance (or angle) to the goal at the end of the episode.
  • Episode tab. The top plots are what the success test of the task looks at, at every step: the joint error (joint_reach), the tip or hand distance (task_reach, space_reach), the tip height and the fastest joint (acrobot), the pole angle, the cart position and the pole speed (cart-pole), the distance to the goal and the clearance to the obstacles (wheeled_nav), the errors along and across the street and of the heading (car_parking), or the speed and turn rate errors (quadruped_velocity). The robot succeeds when they are below their dashed lines at the end. The middle plot is what the policy commands (every output is in [-1, 1]: a curve stuck at a dotted line is saturated), the bottom one the reward of each step, term by term, with the total in black. A checkpoint stored by an older version has no actions or terms: Recreate runs its test again with the saved policy and adds them, but only when the motion comes out the same as stored (when the task code has changed since, it says so and leaves the file as it was).
  • Return by term splits the return of an episode into the terms of the reward, so you can see which term decides it: a penalty that dominates the total is the one to give a smaller weight. The curves add up to the total. This is the plain sum over the episode, not the discounted return the learner maximises.
  • The dashed line is what a zero action (doing nothing) scores, and the star marks the best checkpoint. While a run goes, that is the checkpoint with the highest success (then the lowest error) in the checkpoint tests. At the end the five best of those and the last one are tested again on 256 other goals, and the winner is kept as best.zip: the checkpoint tests alone would often pick a lucky one once the success rate has levelled off.
  • The result line below the tabs shows the numbers of the checkpoint you select in the Checkpoint box, and, when the run has ended, a final test: the final policy and the best checkpoint on 256 robots with goals that were not used before.

What these runs reached: one run each, with one seed, 4 cores and 20 checkpoints, in ~/redysim_rl_runs/ (most were continued to more steps with Continue):

task (run) steps final test (256 new goals) training time
joint_reach (joint_reach_run) 1 100 000 99.6 % at the goal, error 0.018 rad 110 s
task_reach (task_reach_run_3) 2 000 000 97.7 % within 2 cm, error 0.023 m 195 s
space_reach (space_reach_3M) 5 000 000 91.8 % within 5 cm, error 0.042 m 662 s
wheeled_nav (wheeled_nav_3M, 128 robots) 8 000 000 91.4 % reached the goal 932 s

car_parking starts from the settings of the run of examples/train_parking.py (3 000 000 steps, 128 robots, car drive, the reward weights shown in the Reward tab): that run parked 99 % of 256 starts in 4.4 s without a collision, as well as the manoeuvre written by hand (98 % in 5.4 s). It was trained with the script, not through the GUI.

platform_reach starts with PD targets on the three motors (within 0.9 rad of the start pose), 1 000 000 steps and 64 robots. A run with these settings brought the centre of the triangle within 1 cm of its goal for 100 % of 256 new goals (final error 1.4 mm; holding the start pose: 0 %, 123 mm off), in 157 s. The replay draws each leg as a bar from its pivot, the triangle as a plate and the goal pose as a ghost.

The checkpoint tests (128 robots, one episode each) move in steps of about 1 %, so the success curve is noisy; the final test on more robots is the number to quote. Differences of a point or two between two policies are within the noise of 256 robots (about three points). The choice of the best checkpoint is optimistic on the goals it was made on, which is why it is reported on others: the space_reach checkpoint chosen as best scored 94.5 % on the 256 goals it was chosen on and 91.8 % in the final test.

The space robot reaching a goal, with its return by term

The wheeled robot driving to a goal between obstacles, with its return by term

What a run writes

The folder ~/redysim_rl_runs/<name>/ holds everything, so a run can be looked at again or compared later:

file content
config.yaml the settings of the run
progress.csv, terms.csv one row per checkpoint: return, success, error, and the return by term
baseline.json the same numbers for a zero action
best.json, best.zip the best checkpoint and its policy
final.json the final test
policy.zip, policies/ the latest policy, and the policy of every checkpoint
rollouts/ the stored episodes of the replay
config.before-<step>.yaml, resumes.json the settings before each Continue, and what changed
rollouts_new/, tests.json the tests of a checkpoint on new goals, and their results

Two quadruped runs compared: their curves, a table of their final numbers, and the settings that differ

The Compare runs tab (the button in the bar opens it) lists only the runs of the task you are working on, with the newest ticked. It overlays their curves and has a table of their final tests. Under it is the Settings table, one column per ticked run and one row per setting: with two or more runs it lists only what differs (untick Only what differs for all of it), a value that differs from the first run is marked in orange, and a setting a run does not have (a run made before the setting existed) says "not set". With one run ticked it shows all of that run's settings, so this is also where to read the settings of a single run; Load run settings copies them into the form. Save curves in the bar saves the curves of the shown run as a picture, and Save animation next to the replay controls writes a GIF of the robot you are looking at (an MP4 if ffmpeg is installed).

Continue a run, and test on new goals

  • Continue trains the run shown on the right further, from its saved policy (policy.zip), up to the Total steps in the window. Use it for a run you stopped, or raise Total steps to train a finished run on. Press Load run settings first to put that run's settings into the window, change what you want (the reward weights, the learner settings, the number of checkpoints) and press Continue. The task, the robot, the action mode, the observation signals and the hidden units stay as they were, because the network is built from them; the GUI says so if they differ. The run name must stay the same too: Continue extends that run's folder, and with a new name the GUI refuses and points to New run, which makes a new run from scratch. The old settings are kept as config.before-<step>.yaml and the changes are noted in resumes.json. A run that was stopped gets its final test when it reaches the total.
  • From policy makes a new run that begins from the saved policy of the run shown on the right, with the settings in the window and a new run name (the shown run is not changed). Use it to try another reward on a trained policy without touching the old run, or to branch one run into several. The new run counts its own steps from 0 and tests the starting policy first, so its first row shows how the old policy does under the new settings; from.json in its folder records which run and step it started from. The task, robot, action mode, observation signals and hidden units must be the same as in the old run, as for Continue.
  • New goals (next to the replay) tests the shown checkpoint on a new set of 128 goals, which the policy has not seen, and adds the test to the Checkpoint box ("step 1 003 520 · new goals (seed 41873) · 98 %"). Its replay opens on a robot picked at random (random 1): the best robots of every test look alike, because a policy is most precise in the same part of the workspace, while the random ones show the new goals. Press it again for another set of goals.

The run file

The settings of a run are one YAML file; the GUI reads and writes it (Open run file, Save run file), and every run keeps its copy as config.yaml. You only need the keys you want to change, the others take the defaults of the task and robot:

name: my_reach
task: joint_reach
robot: three_link          # a bundled model, or the path of your own model file
action_mode: impedance
steps: 500000
max_time: 4.0            # the longest episode, in seconds
reward: {w_act: 0.0, bonus: 2.0}
observation: [q, dq, error]
ppo: {gamma: 0.98, n_epochs: 10}

A wrong key or value is reported by name and nothing is changed. An angle can be written as pi/36 or radians(5) (reward: {tol: radians(3)}).

A task of your own is named by its class and its Python file (task: HoldHeight, task_file: custom_task.py), or loaded with Load... beside the Task box; see Writing your own task.

A robot of your own

The robot and the task are separate: the robot is a ReDySim model file, the task says what is learned. Any bundled model, or a model you made, can be used for a task:

  1. Make or change the model in the ReDySim GUI (fixed base or floating base) and try it there: its links, masses and joints, and whether it moves as it should under a simple controller.
  2. In this GUI press Browse... beside the Robot box and pick the model file, or write its path in a run file (relative to the run file, or absolute):
task: task_reach
robot: ../robots/my_arm4.yaml

The run is named after the task and the file (task_reach_my_arm4), the Action card counts the driven joints of the file (those not marked actuated: false), and the robot stays when you choose another task. A fixed-base task needs a fixed-base model with an open chain; the floating-base tasks need a floating-base model of the kind the task drives (wheels for wheeled_nav, four legs for quadruped_velocity). A model of the wrong kind (a floating-base model for a fixed-base task or the other way round, no driven joint) is refused when the run starts, with the reason in the log; one that loads but does not suit the task (an arm for the cart-pole) only learns badly.

A task of your own can name its robots in ROBOTS, or take any model file the same way.

Speed

  • The learner, which updates the policy network on the CPU, takes about four fifths of the time of a reach run; the simulator the rest. A checkpoint costs about 0.3 s, so 20 of them add a few seconds.
  • Use about 4 cores. The cores setting is used for the simulator and for the learner, and more of them made the same reach run slower in a test: 200 000 steps took 9 s with 4 cores, 18 s with 8 and 122 s with 16. To use a larger machine, start several runs with 2 to 4 cores each.
  • SB3 standard is made for one environment: with 64 robots one update uses 131 000 samples, so there are far fewer updates for the same number of steps.

Using a saved policy

The GUI shows, continues and compares runs; to use a policy outside it, load the saved file with Stable-Baselines3 and step an environment with the same task, action mode and observation:

from pathlib import Path
import numpy as np
from stable_baselines3 import PPO
import redysim_rl

run = Path.home() / "redysim_rl_runs" / "joint_reach_3link"   # the run of "A first run" above
model = PPO.load(run / "best.zip", device="cpu")
env = redysim_rl.make_vec("joint_reach", num_envs=256, action_mode="impedance")
obs, _ = env.reset(seed=7)                 # goals the policy has not seen
for _ in range(env.unwrapped.max_episode_steps):
    obs, reward, terminated, truncated, info = env.step(model.predict(obs, deterministic=True)[0])
print("reached the goal:", np.mean(info["is_success"]))

If the run changed the observation signals or the reward settings, pass the same ones to make_vec as task_kwargs={"obs": [...], ...}.

Limits

  • Quadruped. Success there means the robot stayed up for the whole episode and its speed followed the command to within the Tracking within value (0.15 m/s) on average: staying up alone would count a robot that just stands. The final error is the mean speed error over the episode, and the dashed line, a robot that stands still, already scores about 27 % because some of the commands are below the tolerance. The mean turn-rate error must also stay below Mean turn rate within (0.3 rad/s), so a robot that walks in circles does not pass. The Turn reward needs speed tracking setting (1.0) pays the turn-rate reward only while the speed is tracked: without it a robot that stands still collects it, and with Turn rate tracking at 0 nothing stops the circling. Of the gait terms of the Reward card, pose (0.3) and foot swing (5) are on by default, with the trunk-height penalty; slip, knee, torque, pitch and foot held up are off. With these defaults a run of 15 M steps (256 robots, 4 cores, 17 minutes) walks on all four legs. Earlier runs with all the gait terms on from the first step learned to stand still, so switch the others on one at a time with Continue. A quadruped needs more steps than the arm tasks: train it for 15 M, not the default 3 M.
  • A stopped run keeps its checkpoints and policies but has no final test until you Continue it to its total. A policy file from outside a run folder cannot be loaded into the GUI; use the snippet above.
  • The numbers above are single runs with one seed and no tuning.
  • Like the rest of the package, the GUI runs where the fixed-base package runs (Linux x86-64 today).