Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Current set to zero after switching the control mode to current #554

Open
GiulioRomualdi opened this issue Jan 13, 2025 · 13 comments
Open
Assignees

Comments

@GiulioRomualdi
Copy link
Member

I’m currently working on the current control mode and noticed an issue. When switching the control mode from position to current, the setpoint is set to 0.

However, when switching from position to torque, the setpoint in torque is set to match the estimated value.

After discussing this with @valegagge, it seems this might be a bug in the 2foc implementation, where the setpoint in the current mode is not being set correctly.

Here, it's a video showing the behaviour

Screencast.from.01-13-2025.04_55_50.PM.webm
@GiulioRomualdi
Copy link
Member Author

To provide a high-level perspective: The problem with this behavior is that when we switch to current mode while the robot is on the ground, the desired current is momentarily set to zero. Although this happens for a very short time, it is sufficient for the robot to collapse under its own weight.

@GiulioRomualdi
Copy link
Member Author

@Nicogene
Copy link
Member

Ccing @ale-git that maybe knows what is happening

@valegagge
Copy link
Member

It seems that the 2foc after receiving the set control mode command it reset the IqRef. In addition on EMs side, it sends the current reference received. Probably if it still receives nothing it sends 0.

See here and here.

For sure @ale-git can analyze the issue better than me.

@valegagge
Copy link
Member

I provided the ems fw here attached to @GiulioRomualdi to test on the robot.
Currently, the fw contains only a debug message to understand in detail what happening in the current control mode switching.

Image

Please note the the fw I provided is based on the current version on the robot (3.95) and not on the top of the devel branch.

Thanks @GiulioRomualdi for the tests!

ems_x_giulio_v_3_195.zip

@GiulioRomualdi
Copy link
Member Author

GiulioRomualdi commented Jan 16, 2025

Thank you @valegagge! 🎉 I'm currently testing the firmware on ergoCubSN002. I flashed the board 10.0.1.6 the right upper leg

Image

Here the output of the interface
interface_current.txt

This is the video of the experiment

20250116_162539.mp4

@valegagge
Copy link
Member

Hi @GiulioRomualdi ,
is it clear from your test that the references provided to the pid are 0 as we supposed before.

Now the solution is to provide the current value of current, but... we need to filter it in some way, because its values change a lot!

@GiulioRomualdi
Copy link
Member Author

Now the solution is to provide the current value of current, but... we need to filter it in some way, because its values change a lot!

A possibility is to to use the same filter @ale-git implemented back in time (an average between n samples discarding the max / min values)

@valegagge
Copy link
Member

Now the solution is to provide the current value of current, but... we need to filter it in some way, because its values change a lot!

A possibility is to to use the same filter @ale-git implemented back in time (an average between n samples discarding the max / min values)

yep!
I'm checking exactly that!

@ale-git
Copy link
Contributor

ale-git commented Jan 17, 2025

Since the 2FOC can run in three different control modes (pwm, current, velocity), we decided for the clean transition mode that resets the references until a new reference value is received. We can use instead the smooth transition mode, that uses the present feedback as new reference. Thus, 1) moving from current or pwm mode to velocity, we can set the measured velocity as reference, 2) moving from current or velocity to pwm, we can set the present pwm as reference, 3) moving from velocity or pwm to current, we can use the present current feedback (filtered) as input.

@valegagge
Copy link
Member

Hi @ale-git ,
I'm implementing the point 3. as soon as I complete it I'll ask you to review.

In addition, we need to remember that the fw of 2foc 3.3.38 already provides a filtered current.

@ale-git
Copy link
Contributor

ale-git commented Jan 17, 2025

Ok. Just for clarity, my proposal is to implement all points 1, 2 and 3.

@valegagge
Copy link
Member

Ok. Just for clarity, my proposal is to implement all points 1, 2 and 3.

sure! I see that in some cases there are some smooth transitions, but I need to go in detail with all of them.

In order to fix this issue I started from the point 3.

@valegagge valegagge self-assigned this Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants