A mainstream 2-DOF humanoid ankle simulation in Webots. This implementation includes forward and inverse kinematics for a closed-loop ankle, enabling torque mapping between the two motors and the ankle joints. Only for ankle like this:
- Ubuntu24.04
- WebotsR2023b
- Eigen
- ros2_plot
- Webots
git clone https://github.com/HuNingHe/closed_loop_ankle.git
cd closed_loop_ankle/contrers/my_contrer && mkdir build
cd build && cmake ../
make -j4
cd ros2_plot_ws && source install/setup.bash
ros2 run ros2_plot ros2_plot # run ros2_plot first!!!!
ros2 run plotjuggler plotjuggler
# Open webots and run ankle.wbt
If you are not using ros2, you can remove all shared memory related code and recompile, you can run still without data visualization.
set test_kinematics
in my_contrer.cpp
(line 352) to false, then you can test torque mapping between motors and ankle joint.
suggest to use plot.xml of ros2_plot in plotjuggler.
You can find the formula below in the code:
where ankle_ik
, and all subscripts with '1' denote the left motor of ankle, while subscripts with '2' denote the right motor. The subscript 'p' represents the ankle pitch, and 'r' represents the ankle roll.
Definitions for the remaining terms 'd', 'L1', 'h1', and 'h2' are link lengths can be found in the two figures below
where computeTmLtY
, computeTmLtX
, computeTmRtY
, computeTmRtX
,or general case
where calculateTx
where calculateTxML
, calculateTxMR
according to the principle of virtual work, we have:
Both of 2 motors and 2 joints of the ankle follow the right-hand rule: rotation around the Y-axis in the counterclockwise direction is considered positive, with the X-axis pointing forward and the Z-axis pointing vertically.
Some notations: