# FSM Walking Controller Example - ValueError: State Machine isn't active

**URL:** <https://opensourceleg.discourse.group/t/fsm-walking-controller-example-valueerror-state-machine-isnt-active/44>\
**Category:** Software\
**Created:** [September 9, 2025, 9:15pm UTC](https://opensourceleg.discourse.group/t/fsm-walking-controller-example-valueerror-state-machine-isnt-active/44 "2025-09-09T21:15:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cangelid](https://avatars.discourse-cdn.com/v4/letter/c/5e9695/32.png) [@cangelid](https://opensourceleg.discourse.group/u/cangelid)\
**Post date:** [September 9, 2025, 9:15pm UTC](https://opensourceleg.discourse.group/t/fsm-walking-controller-example-valueerror-state-machine-isnt-active/44/1 "2025-09-09T21:15:35Z")

</div>

Greetings to the community!

I’m trying to use the [FSM walking controller example](https://neurobionics.github.io/opensourceleg/examples/fsm_walking_controller/) supplied in the latest version of OpenSourceLeg on GitHub. When I run it, I get the **ValueError: State machine isn’t active.**

 ![StateMachineNotActive](https://canada1.discourse-cdn.com/flex036/uploads/opensourceleg1/original/1X/fa10bf594acb159ec39b567d11ac9287cd6526bb.png)

From what I can see (screenshot attached), the encoder communication is trying to open `/dev/i2c-3`. However, when I check available I²C buses, I only see `i2c-1`, `i2c-20`, and `i2c-21`. In order to overcome this issue, I tried adding an overlay (i.e. dtoverlay=i2c3) to the `/boot/firmware/config.txt` file, but it didn’t change anything.

I have not been able to run the supplied tutorial to read encoder data either. Besides that all motors and connections are working fine and I could run the basic motion script without issues.  
Also, I have tried using the opensourceleg v2.3.0, in which version I can get the [FSM\_walking\_controller.py](https://github.com/neurobionics/opensourceleg/blob/legacy/examples/fsm_walking_controller.py) (found in the legacy branch of the OSL Github page) to start running without errors, however ideally I would want to continue development using the latest version of the OSL (v3.4 if I am not mistaken).

Has anyone encountered this issue before or know how to get the encoder communication to use the correct I²C bus or any suggestions for the FSM walking controller to be functional and what could be the issue?

---

<div class="post-metadata">

**Author:** ![Orkun00](https://avatars.discourse-cdn.com/v4/letter/o/a3d4f5/32.png) [@Orkun00](https://opensourceleg.discourse.group/u/Orkun00)\
**Post date:** [September 14, 2025, 1:20pm UTC](https://opensourceleg.discourse.group/t/fsm-walking-controller-example-valueerror-state-machine-isnt-active/44/2 "2025-09-14T13:20:06Z")

</div>

I wrote the explanation myself, but I used ChatGPT to help me style and polish it so it’s clearer:

The error appears because the `with osl …` block executes and tries to establish communication with hardware devices. Since the code is configured to talk to **AS5048B encoders on buses `/dev/i2c-2` and `/dev/i2c-3`** , but those buses don’t exist on your system, initialization fails. As a result, the FSM can’t start properly and you see the error **“State machine isn’t active.”**

There are two main ways to address this:

1. **Use virtual encoders**  
If you don’t have real AS5048B encoders connected, or just want to confirm that the problem is software-related, you can replace them with the `VirtualEncoder` class. This bypasses hardware I²C communication and lets you test whether the FSM logic itself runs correctly.

2. **Use the correct I²C bus for your hardware**  
If you do have AS5048B encoders, you need to tell the software which bus they’re actually on.

So in practice, you’ll want to run `i2cdetect -y <bus_number>` on each available bus until you find your encoders, and then update the `bus` parameter in the code accordingly.

Finally, it’s a good idea to go through the “common issues” steps in the encoder tutorial (permissions, group membership, I²C enabled in config, etc.) to eliminate those potential problems too.

If it still doesn’t work after correcting the bus paths, please share details of your hardware setup (which encoders are wired, to which I²C pins/buses) so we can dig deeper.

---

<div class="post-metadata">

**Author:** ![cangelid](https://avatars.discourse-cdn.com/v4/letter/c/5e9695/32.png) [@cangelid](https://opensourceleg.discourse.group/u/cangelid)\
**Post date:** [September 26, 2025, 9:51pm UTC](https://opensourceleg.discourse.group/t/fsm-walking-controller-example-valueerror-state-machine-isnt-active/44/3 "2025-09-26T21:51:43Z")

</div>

Thanks a lot for your answer!

It seems that in my setup, both encoders are actually connected to I2C bus 1, which explains why i2c-2 and i2c-3 could not be found. I tried changing the parameters accordingly in the code, but the State Machine still would not start.

Upon testing the encoders, I was able to read the ankle encoder separately on I2C bus 1, but was not able to establish a connection with the knee encoder. Eventually, I discovered that two of the knee encoder cables were disconnected.

As for the older version of the FSM, it seems that this code was using only the motor encoders (USB communication), same as the basic motion script. This explains why I was able to run these scripts and not the current FSM controller, which relies on the joint encoders rather than the motor encoders.

Appreciate your guidance — it pointed me in the right direction to debug the problem!
