TuragaLab / flybody

MuJoCo fruit fly body model and reinforcement learning tasks
Apache License 2.0
79 stars 4 forks source link

Controlling the fly legs using torque control #5

Open Er1ckR0mo opened 1 month ago

Er1ckR0mo commented 1 month ago

Hi! From your paper, I see the wings can be controlled by inputting torques. My question is, can I do the same with the leg joints? Also, what units should the input torque be? Thanks!

vaxenburg commented 1 month ago

Yes of course, the fly model is readily reconfigurable and you can switch to torque actuators for legs as well.

You can do it either by directly editing the fly xml file (low-level, so might be painful), of do it programmatically using PyMJCF (recommended). Here is an example of how it's done for the dm_control rodent model. It would be slightly different for the fly model, but the procedure is similar.

The MuJoCo docs on actuators could also be helpful.

Er1ckR0mo commented 1 month ago

Thank you for your reply! May I ask two more doubts: How do you select the components of the actuator, such as forcerange, etc.?

Also, how are the damping and stiffness values of the joint selected? Are these based on literature or trial and error?

Thanks!

vaxenburg commented 1 month ago

Most of these things are pretty loose for now. The actuator parameters are mostly educated guesses. For example you can use some fly walking videos to estimate the leg velocity and/or acceleration and then roughly estimate the force ballpark. Trial and error also works:)

One choice of damping could be to use critical damping (for given actuator gain), you can try calculating it with a function like this.

Getting better estimates for some of these parameters could be an interesting project.

Er1ckR0mo commented 2 days ago

Hi again!

Do you have an example where you control the wings of your fly model by using torque control?

Thanks in advance!

vaxenburg commented 2 days ago

Sure, in fact we used nothing but torque control for the wings

Er1ckR0mo commented 2 days ago

could you please refer me to it?

vaxenburg commented 2 days ago

Do you mean the flight task? It's here: https://github.com/TuragaLab/flybody/blob/main/flybody/fly_envs.py#L29 https://github.com/TuragaLab/flybody/blob/main/flybody/tasks/flight_imitation.py#L16

Er1ckR0mo commented 2 days ago

Thanks! Going to check these. I am interested in knowing how the torques are inputted to the actuators in mujoco and how these torque values are selected/updated during the task.