Sampling data at a lower frequency

Hello all and happy new year:)

I was recording data using the OSL running the FSM with a set frequency at 200Hz, which is also the default set within the OSL github repos. However, I noticed that the t variable I am getting from the clock is actually at a much lower frequency (~30Hz). I noticed that while running the newest version of the FSM walking controller. Using the legacy version of the FSM, I am recording data at the set frequency (200Hz), but I am not sure why the frequency is kept in one version of the code and not the other.

Am I missing something here? Any ideas or insights would be appreciated.

Hello and happy new year !

It is strange to reach this low frequency. Can you be more precise on which version of the codes you are using (referencing commit id or branches would help). Also are you using the same python environment for running both code ?

Louis

Hi Louis. I am working with virtual environments, so I have 2 separate environments.

  1. using the opensourceleg 3.4.1 version (Commit 6a8ef34, main branch)
  2. using the opensourceleg 2.3.0 version (branch: legacy-opensourceleg)

I am running Python 3.11.2 in both environments.

In both cases, the FSM code is different with respect to dependencies and packages, but effectively, it’s the same functionality. When using the most recent version of the osl (1), I am getting a data sampling frequency between 30 and 70Hz, although the set frequency in the code is 200Hz. The same happens when I set the frequency to 100Hz, I am still getting between 30-70Hz. As a sidenote, if I run the FSM code without commanding impedance, it seems like I am getting close to the 200Hz. However, once I send impedance commands to the motors (just uncommenting the section that is commented out in this code), I am getting about 70Hz. Although I would expect some delay, going from 200Hz to 70Hz or lower is drastical.

When using the legacy version, the sampling rate is consistent with the set frequency.

Hi

The flexsea python package (the package used to communicate with the dephy actuators) has some extra sleep when setting the gains: see here

The version used in the legacy version is the 8.0.1. In this version I did not see the problematic sleep but I did not went through the complete code base either.

You can modify the local code of this package (That’s what I will do to confirm that is the root of the problem). You can also change the definition of the package in the pyproject.toml(example here) to use a fixed version of the package (example here).

In any case pay attention if you need to update the package.

Regards,

Hi Louis, thanks for taking the time to look into this.

I am still unsure how to work around the sleep issue. I am using the flexsea 12.0.4 package with the opensourceleg 3.4.1. If I try to downgrade to a previous version of the flexsea package (the one I am using for the legacy version of the OSL) using the command python3 -m pip install flexsea==8.0.1 , I am not able to run the FSM code due to dependencies missing.

The way I have currently set up the leg is using the standard installation. The only pyproject.toml file that I can find within my virtual environment after installing all dependencies is under pandas and does not have the structure seen here. I am including a snapshot below just for reference. I am not sure if that is related to the way I have set up the leg, but it seems that i am not able to control the definition of the package in the pyproject.toml.I am currently looking into that.

Were you on your end able to confirm whether the extra sleep is what causes the sampling delay?

Hi @cangelid,

I would suggest you to modify directly the flexsea package:

  • Do a normal installation
  • Go inside your venv and find the flexsea package
  • Edit the device.py file
  • Remove the sleep (~ line 491 in set_gains)

Test to run the FSM with this setup.

On my own I did not test the difference with or without the sleep. I always used this setup without the sleep. I do not have access to an OSL/Dephy actuator for now so I cannot try it either.

1 Like

That worked Louis, thank you for the help!

1 Like