You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/examples/fsm_walking_ankle_controller.md
+35-7Lines changed: 35 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,13 @@
4
4
5
5
This example demonstrates how to use a finite state machine (FSM) to control the OSL ankle joint with impedance control. The FSM uses load cell feedback and the motor encoder (or optionally the joint encoder) to transition between states, applying different impedance parameters for each phase of the gait cycle. This script is intended for testing and development with the OSL hardware.
6
6
7
+
The FSM implements four distinct gait phases:
8
+
9
+
1.**Early Stance**: Initial foot contact with moderate stiffness for shock absorption
10
+
2.**Late Stance**: High stiffness for push-off power generation during heel rise
11
+
3.**Early Swing**: Low stiffness allowing rapid dorsiflexion for ground clearance
12
+
4.**Late Swing**: Maintains dorsiflexion position preparing for next heel strike
13
+
7
14
The figure below shows the basic execution of the controller:
8
15
9
16

@@ -19,42 +26,55 @@ The implementation is entirely in Python and uses the `StateMachine` class from
19
26
First, perform the necessary imports and define the hardware and control parameters:
> These parameters were roughly tuned for a moderately paced walking gait. You may want to tune them to better suit your intended use case.
32
39
33
40
### FSM Definition
34
41
42
+
The FSM consists of four states representing the phases of the gait cycle, each with specific impedance parameters. We first define the transition criteria functions that determine when to switch between states based on sensor feedback:
43
+
44
+
#### Transition Functions
45
+
46
+
The transition criteria are implemented as functions that take the OSL object and return a boolean indicating whether the transition should occur:
47
+
48
+
-**Early Stance → Late Stance**: Triggered when load cell force exceeds threshold AND ankle position is dorsiflexed enough
49
+
-**Late Stance → Early Swing**: Triggered when load cell force drops below threshold (heel off)
50
+
-**Early Swing → Late Swing**: Triggered when ankle reaches target dorsiflexion AND velocity decreases
51
+
-**Late Swing → Early Stance**: Triggered when load cell force increases (heel strike) OR ankle plantarflexes sufficiently
52
+
53
+
#### State Machine Creation
54
+
35
55
Next, we create a function that returns an instance of the `StateMachine` class. Create the FSM by defining the states, their impedance parameters, and the transition criteria functions. Each transition is based on sensor feedback or joint state:
> If instantiating the OSL hardware and sensors is unfamiliar, check out the [the tutorials pages](../tutorials/actuators/getting_started.md).
43
63
44
64
### Hardware Initialization
45
65
46
-
Initialize the actuators, sensors, logger, and realtime loop:
66
+
Initialize the required hardware components including the Dephy actuator, load cell sensor, data logger, and real-time control loop. The system uses a 200Hz control frequency for responsive control:
Home the OSL, set the ankle to impedance mode, and start the main control loop. In each iteration, update the hardware, FSM, and log the relevant data:
74
+
The main control loop homes the OSL, sets the ankle to impedance mode, and runs the control algorithm. In each iteration, the system updates hardware sensors, evaluates FSM transitions, applies impedance control, and logs relevant data:
0 commit comments