Skip to content

Part 1: Run the examples

1.1 Install

You need Python 3.10 or newer. The ready-built downloads (with the compiled core) are for Linux x86-64 and Windows 10 or 11 (64-bit); macOS on Apple Silicon is coming soon. Check what you have by typing, in a terminal:

python3 --version        (Ubuntu)
py --version             (Windows)

If it is the wrong version or missing, install a current Python from python.org. On Windows, tick "Add python.exe to PATH" in the installer.

The ReDySim Fixed-base and Floating-base download holds both simulators, fixed-base and floating-base, and installs both in one step. Unpack it and open a terminal in the unpacked folder (the one that contains install.sh).

Windows (PowerShell)

powershell -ExecutionPolicy Bypass -File install.ps1

The script makes a virtual environment (.venv) and installs both simulators. To activate the environment in a new terminal, run .venv\Scripts\Activate.ps1; if that says that running scripts is disabled, run this once and try again:

Set-ExecutionPolicy -Scope Process RemoteSigned

Ubuntu

sudo apt install python3-venv python3-tk
sh install.sh

The script makes a virtual environment (.venv) and installs both simulators. To activate it in a new terminal, run source .venv/bin/activate.

By hand, in an active virtual environment, the same is one line: pip install "./fixed_base[anim]" "./floating_base[anim]".

macOS (Apple Silicon, coming soon)

The macOS download is not available yet; these are the steps for when it is.

sh install.sh

The script makes a virtual environment (.venv) and installs both simulators. To activate it in a new terminal, run source .venv/bin/activate. Python 3.10 or newer is needed; if python3 --version is older or missing, install it from python.org.

Installing takes a few minutes. The word (.venv) appears at the start of your terminal line when the environment is active. Every time you open a new terminal, activate the environment again (the activation commands above) before using redysim.

1.2 Check that it works

redysim --version
redysim --list

The first command prints the version. The second prints the list of ready-made robots.

Then run the automatic check, which tries every part of the program and opens no window:

redysim --selftest

It prints a line starting with ok for each check and ends with All checks passed. The core is already compiled, so there is no wait on the first run. If a line says FAILED, copy the whole output when you ask for help.

1.3 Run an example

The simplest way is the Runner (described at the end of this section). Its Help button opens the fixed-base manual on the website. Pick a model, for example three_link, and press Run:

redysim --runner

The same run from the command line:

redysim fordyn three_link

The plots (joint motion, torques and energy, each in its own window) and an animation of a three-link arm falling under gravity open. Close the windows to finish.

The plots and the animation are separate: add --anim-only to see only the animation, or --plots-only to see only the plots (see the options below).

There are two kinds of simulation:

command question it answers
redysim fordyn <robot> Given the joint torques, how does the robot move? (forward dynamics)
redysim invdyn <robot> Given the motion, what torques are needed? (inverse dynamics)

Try a few more:

redysim invdyn kuka
redysim fordyn fourbar
redysim fordyn spatial_biped

Useful options

option effect
--no-show do not open windows
--anim-only show only the animation, no plot windows
--plots-only show only the plots, no animation (--no-anim does the same)
--save-plots save the plots as PNG files
--save-anim FILE save the animation as a .gif (e.g. --save-anim arm.gif)
--runner open the Runner (see The Runner, in 1.3) instead of running from the command line
--trace draw the path of the tip of each end link (the end effector, the fingers, the platform) in the animation, from the start up to the time shown
--out DIR write results to DIR instead of output
-q print only warnings and errors

If your computer has no display (for example over SSH), no windows open and the plots are saved as plot1.png, plot2.png, and so on.

What the animation shows

The animation is a stick figure of the robot, redrawn at every saved time step from the joint values in the results. It is not a picture of the real shape of the links.

  • Each link is drawn as a line from the origin of its frame (its joint) to the joint of each link attached to it. A link with several children, such as the first link of the gripper, gets one line for each.
  • A link with nothing attached to it, such as the last link of an arm, has no next joint to end at. It is drawn to a tip point. Unless you set one, the tip is twice the distance from the link's frame origin to its centre of mass, which is right only when the centre of mass is at the middle of the link. Otherwise the last link looks too long or too short. You can give the point yourself with tip: [x, y, z] in that last link (section 2.3), for example the tool point of a robot arm.
  • The ground is drawn in gray when two or more links are attached to it by turning joints: as a bar between their pivots (a four-bar) or as a triangle (a three-legged parallel robot).
  • A link that has two or more cut points of a closed loop (the platform of a parallel robot) is drawn as a polygon through its joint and those points, filled with a see-through copy of its colour; see section 2.8. If the platform has no link attached to it, it is not also drawn as a rod to its tip: the polygon is the link, and its tip is marked by a teal dot (put tip: at the centre of the platform to mark the centre).
  • Joints are marked with dots. With --trace (or trace=True in a script, result.animate(trace=True)) a teal line follows the tip of each end link, from the start up to the time shown.
  • The plot is fitted to the motion. If the robot moves in one plane it is drawn in 2-D in that plane (usually x-y); otherwise it is drawn in 3-D, and you can rotate the view with the mouse. The axes are sized to hold the whole motion.
  • The animation only plays the saved results back. It does not change the calculation, and --plots-only skips it.

The animation is also a quick check on your own model. If a link points the wrong way or the robot starts in a pose you did not expect, the modified DH parameters or the start angles are wrong (section 2.4). In a closed loop, the links must stay connected at the cut.

The Runner

If you would rather click than type, open the Runner:

redysim --runner

The Runner showing the animation of a three-link arm

The Runner uses the same colours as the ReDySim GUI. From top to bottom:

  • Header: the name, and the Dark mode / Light mode button (see below).
  • Model: pick one of the bundled models from the list, or press Open example… to open your own .yaml file. Choose Forward dynamics or Inverse dynamics, then press Run. The line under the buttons says how many joints and steps the run has. A model file that has no section for the chosen kind shows an error message.
  • Example scripts: the Runner also lists the Python examples of Part 3 (in the Example script box at the bottom of the side bar). Pick jaw_gripper_grasp and press Run script: the script starts in its own process, an Example tab shows what it does and its printed output, and its figures and animation open in their own windows when it has computed. The scripts you run here are the ones installed with the package; to edit them, make your own copy with redysim --copy-examples my_examples. Choosing a model removes the tab and brings back the choice of Forward dynamics, Inverse dynamics and Run: they are for models, and are greyed out while a script is chosen.
  • Show (left): tick which tabs you want. There is one tab for the animation and one for each plot (the plots have the usual zoom and pan buttons). Trace the tip draws the path of the end links in the animation.
  • Animation: it starts by itself. Pause holds it where it is and Play goes on; the slider jumps to any time. When it reaches the end the button reads Replay.
  • Save animation… writes a .gif or .mp4, and Save plots… writes the plots as PNG files into a folder you choose.

Dark mode / Light mode switches the colours of the window and of the plots, and keeps the tab, the frame and the plots you ticked. The Runner starts in light mode. The files you save are always on a white background, so they suit a report in either mode.

The same window in dark mode, showing the energy balance

Example scripts. The box at the bottom of the side bar offers the jaw gripper grasp of the examples/ folder (the Kinova pick-and-lift runs from the command line, as Part 3 explains). Choosing it fills the window with an Example tab: what the script does, what opens, the files you can change and things to try, and under it the output of the script as it runs. Run script starts it in its own process: it computes first, and then its figures and an animation open in their own windows. Forward dynamics, Inverse dynamics and Run belong to the models and are greyed out while a script is chosen; choosing a model brings the tabs of the last run back.

The Example tab: the text of a script and its output

The Runner only runs and shows a model; to edit a robot, change the .yaml file (see Chapter 2). It is not the separately licensed ReDySim GUI, which has a model editor.

1.4 Where the results go

Each run writes its files to output/<fordyn or invdyn>/<robot name>/:

file contents written by
timevar.dat the times both
statevar.dat joint positions, then joint velocities (fordyn adds the actuator energy at the end; invdyn adds the joint accelerations) both
envar.dat potential, kinetic, actuator and total energy fordyn
tor.dat joint torques, one column per joint invdyn
tip.dat the position of the end effector: the x, y, z of the tip of each last link (a link that no other link is attached to), in the ground frame, three columns for each both
plot1.png, ... the plots, when saved both

They are plain text, with one row per time step. You can open them in Excel or MATLAB, or plot them with any tool.

1.5 The ready-made robots

Run redysim --list to see them all. Not every robot supports both kinds of simulation.

name robot
two_link, three_link arms that swing in a plane
two_axis_pendulum pendulum that swings in two directions (two perpendicular joints)
large_dof_chain chain of 20 links
kuka KUKA KR5, a 6-axis arm
kuka_tool KUKA arm whose tool follows a path (invdyn; fordyn follows it with computed torque)
kinova_gen3lite Kinova Gen3 Lite, a light 6-axis arm (fordyn follows the cycloidal path with computed torque; invdyn computes the torques for it)
rp, pppr arms with sliding (prismatic) joints
pr cart-pole: a cart sliding on a rail with a pole on it (balancing task of redysim_rl)
robotic_gripper gripper with branching fingers
spatial_biped walking biped (in invdyn gravity is -x, as in fordyn; the MATLAB inverse-dynamics input has +x, which points up)
spatial_biped_step the same biped, one step moved on a quintic (a model file)
fourbar, hoken_fourbar, slider_crank closed-loop mechanisms
three_rrr parallel robot
robotic_leg walking leg linkage
stewart Stewart platform: a spatial parallel robot with six prismatic legs

1.6 Things to try

  • Run redysim fordyn two_link and redysim invdyn two_link and compare the plots.
  • Run redysim fordyn fourbar --save-anim fourbar.gif and open the GIF.
  • Open output/fordyn/three_link/statevar.dat in a spreadsheet and find the joint angles at the last time step.

When you are comfortable with this, move on to Part 2.