Multi-Legged Machine Design & Simulation
Design · Simulate · Build
This is a tool for simulating and designing hexapods, octopods, or any pod you can imagine (as long as it is using limbs with three degrees of freedom and the inverse kinematics equations have a solution)
Any leg orientations is ok, any number of legs is ok, any combination of coxa, femur and tibia lenghts is ok. You can even mix and match with different style legs and leg anchor points and orientations on the same pod, since the kinematics equations are generic.
Hexapods can use tripod, ripple and wave gait. Pods with a different number of limbs are so far limited to wave gait. Gait transitions are smooth, and happen mid-stride while the pod walks.
I decided to make this tool to be able to iterate faster when designing my own hexapods.
No promises though. There will be bugs.
It has so far been tested on Mac and Windows
| Document | About |
|---|---|
| Using the simulator | The views, the example pods and all shell commands |
| The browser version | The simulator in a web browser: using it, running it locally and publishing it |
| Designing a pod | Body, legs, segment lengths, joint angles and stance, with examples |
| Pod designer | Plan for the interactive pod designer |
| Centipede | Segmented bodies: the centipede, its two joint legs and the metachronal gait |
| The gait engine | How walking, gait transitions and the body pose work |
| Motion scripts | Chaining walks, turns, gait changes and poses in a script |
| Servos | Servo mapping, servo models and Dynamixel hardware |
| CAD export | Exporting a pod as a STEP assembly with printable brackets |
| Joints in Fusion 360 | Moving the joints of an export in Fusion 360 |
| Servo models | Servo geometry and vendor models for the CAD export |
| Kinematics | Forward and inverse kinematics, and gait patterns |
| Design notes | Motion chaining and the Overlord robot controller (plans) |
The code is servo agnostic: servo ids, orientation and range are defined in the servo mapping. The target robot controller is the Raspberry Pi CM5 based Overlord board. What's next is in the roadmap, known bugs in BUGS.md.
The simulator is written in Go. If you don't have Go installed on your machine, you can download it from here. Some platforms need extra packages for Ebitengine, the 2D engine used for the views.
Navigate to the goik/goik folder and type:
>go buildThis will create an executable called "mechanica.exe" on Windows or "mechanica" on Mac and Linux. Run it from the goik/goik
folder, since it looks for scripts, pods and cad relative to the current folder.
The goik/goik folder has a Makefile with shortcuts. Make is optional: every target is a single command that can also be typed directly.
| Target | Command | Does |
|---|---|---|
make build |
go build |
Build the simulator |
make test |
go test ./... |
Run the tests |
make run |
go run . |
Build and start the simulator |
make web |
go run ./cmd/web |
Build the browser version and serve it on http://localhost:8080 |
make cad-setup |
python cad/tools.py setup |
Install CadQuery in cad/.venv, needed for the CAD export (Python 3.9 - 3.12) |
make cad-vendor |
python cad/tools.py vendor |
Download the vendor servo models that can be downloaded, and explain the others |
make cad-check |
python cad/tools.py check |
Show what is installed, downloaded and measured for the CAD export |
Use another Python for the CAD targets with make cad-setup PYTHON=python3. See the
CAD export documentation.
Installing make:
- Windows:
winget install ezwinports.make(open a new terminal afterwards, so the updated PATH is picked up) - Mac:
xcode-select --install(the Xcode command line tools include make) - Linux: usually installed already, otherwise install the
makepackage (for examplesudo apt install make)
Stride Mechanica opens a command shell and a graphical XZ/XY and isometric view along with a visualization of the current gait pattern
Type help in the command shell to get a list of commands, or help <section> (design, walk, pose, scripts, servos) for a part of it. There are 10 different preloaded models (reset 0 to reset 9: an insect with twisted joints is 8, a centipede 9) that can be played with to get a feel for the simulator. See Using the simulator for all commands, and Designing a pod for designing your own pod (body, legs and stance), with examples.
- Select preloaded model #1
- Change the length of the coxa segment of two of the legs to 100mm
- Change their rest coxa angles
- Run the simulation in real time
- Walk forward in ripple gait, at 30 mm/s for 4 gait cycles. The pod steps back into its neutral stance afterwards
- Tilt the body and raise it while walking in an arc, then stop and level the body again
>reset 1
>set_coxa_length 4 100
>set_coxa_length 5 100
>set_coxa_angle 4 -30
>set_coxa_angle 5 30
>gait ripple
>walk 0 30 0 cycles 4
>walk 0 50 15
>pitch 10
>up 15
>halt
>levelThe walk command drives a phase based gait engine. Velocity, direction, gait and body pose (pitch, roll, yaw,
up, down, shift, level) can be changed at any time, and the pod transitions smoothly
(see the gait engine). halt steps back into the neutral stance:
>reset 1
>walk 0 80 0
>gait wave
>walk 0 50 15
>haltThe pod can also be driven with an Xbox controller (or any gamepad with the standard layout): the left stick walks, the right stick turns and pitches, the triggers roll, and the buttons select the gait and top speed. See Gamepad for the whole mapping.
Sequences of motions can be written as scripts in the goik/scripts folder and played
with run <name> (scripts lists them, abort stops the running script). See demo.goik:
gait tripod
walk 0 80 0 for 3 # forward, 80 mm/s for 3 seconds
walk 0 0 20 for 3 # turn on the spot
repeat 2 # run the block above twice
gait wave
walk 0 40 0 for 5
halt # step back into the neutral stanceServo ids, orientation, offsets, soft limits and the servo model (AX-12A, STS3215, XL-320) are part of the pod
definition and are saved with save. Use servos to show the mapping, and servo / servo_model to change it.
The mapping is used by the CAD export (servo ids and orientation), and will be used by the robot controller. See Servos.
export_cad <name> exports the pod in its rest pose as a STEP assembly: a servo at every joint in the right place
and orientation, connected by printable brackets, plus one STL per printable part. Open it in Fusion 360 or any other
CAD program, and move its joints in Fusion with the GOIK_Joints script. Example pods 6
and 7 (reset 6, reset 7) are designed around AX-12A and STS3215 servos. The STEP file is built with CadQuery
(make cad-setup installs it). See CAD export for the details, and
Servo models for where to download the vendor servo models.
Pod definitions can be saved and loaded with save and load.