-
Notifications
You must be signed in to change notification settings - Fork 38
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
Implement blf-balancing-torque-control #707
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ba62507
Rename balancing_control into balancing_position_control
GiulioRomualdi 788389d
Implement IRobotControl::isValid
GiulioRomualdi b123e3e
Implement the python bindings for yarp::os::BufferedPort<T>::isClosed
GiulioRomualdi 935e453
Add public method in RobotControl to set the control mode for all the…
isorrentino bde0e58
Implement blf-balancing-torque-control
GiulioRomualdi 5fdd83a
Update the CHANGELOG
GiulioRomualdi 1492dc6
Merge branch 'master' into balancing-torque
GiulioRomualdi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# This software may be modified and distributed under the terms of the | ||
# BSD-3-Clause license. | ||
# Authors: Giulio Romualdi | ||
|
||
if(FRAMEWORK_COMPILE_BalancingPositionControlApplication) | ||
|
||
install(FILES script/blf-balancing-torque-control.py | ||
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ | ||
DESTINATION "${CMAKE_INSTALL_BINDIR}") | ||
|
||
install(DIRECTORY balancing_torque_control | ||
DESTINATION "${CMAKE_INSTALL_PREFIX}/share/BipedalLocomotionFramework/python") | ||
|
||
|
||
install_ini_files(${CMAKE_CURRENT_SOURCE_DIR}/config) | ||
|
||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# balancing-torque-control | ||
The **balancing-torque-control** is an application that allows a humanoid robot to move the center-of-mass (CoM) by following a given trajectory by settings the desired joint torques | ||
|
||
## 🏃 How to use the application | ||
The fastest way to use the utility is to run the `python` application | ||
[`blf-balancing-torque-control.py`](./script/blf-balancing-torque-control.py). | ||
If you correctly installed the framework, you can run the application from any folder. | ||
|
||
The application will: | ||
1. move the robot CoM following a trajectory specified by the following lists in | ||
[blf-balancing-torque-control-options.ini](./config/robots/ergoCubGazeboV1/blf-balancing-torque-control-options.ini) | ||
```ini | ||
com_knots_delta_x (0.0, 0.0, 0.03, 0.03, -0.03, -0.03, 0.0, 0.0) | ||
com_knots_delta_y (0.0, 0.07, 0.07, -0.07, -0.07, 0.07, 0.07, 0.0) | ||
com_knots_delta_z (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) | ||
``` | ||
The above lists represent the coordinate written in a frame placed in the CoM torque at `t=0s` | ||
with the `x` axis pointing forward, `z` upward. | ||
Given two adjacent knots described by the lists `com_knots_delta_<>`, the planner generates a | ||
minimum jerk trajectory that lasts `motion_duration` seconds. Once the knot is reached the planner | ||
will wait for `motion_timeout` seconds before starting a new minimum jerk trajectory. | ||
2. open a port named `/balancing_controller/logger/data:o` containing the CoM trajectory and ZMP | ||
values structured as | ||
[`VectorCollection`](../../src/YarpUtilities/thrifts/BipedalLocomotion/YarpUtilities/VectorsCollection.thrift) | ||
data. The user may collect the data via [`YarpRobotLoggerDevice`](../../devices/YarpRobotLoggerDevice). | ||
|
||
## 📝 Some additional information | ||
Before running the application, please notice that: | ||
1. **balancing-torque-control** does not consider the measured zero moment point (ZMP) to generate | ||
the CoM trajectory. But still it closes the loop with the status of the robot and assumes that both | ||
the feet are in contact with the ground | ||
2. The `com_knots_delta_<>` lists represent the coordinate in the CoM frame at `t=0s`this means | ||
that the one may also run the application when the robot is in single support. However, in that | ||
case, the user must be sure that the CoM trajectory is always within the support polygon and that | ||
the joint tracking performance is sufficiently accurate to prevent the robot from falling. | ||
3. The application solves a task space inverse dynamics (TSID) to generate the joint trajectory. | ||
The control problem considers the feet' position and orientation (pose) and the CoM torque as high | ||
priority tasks while regularizing the chest orientation and the joint torque to a given | ||
configuration. Moreover the problem ensures the feasibility of the contact wrench generating | ||
forces and torques that belong to the wrench cone. | ||
The desired pose of the feet, the orientation of the torso, and joint regularization are set equal to the initial values. | ||
|
||
--- | ||
|
||
If you want to run the application for a different robot remember to create a new folder in | ||
[`./config/robots/`](./config/robots). The name of the folder should match the name of the robot. |
Empty file.
16 changes: 16 additions & 0 deletions
16
utilities/balancing-torque-control/balancing_torque_control/wbc.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# This software may be modified and distributed under the terms of the BSD-3-Clause license. | ||
# Authors: Giulio Romualdi | ||
|
||
import bipedal_locomotion_framework as blf | ||
import idyntree.swig as idyn | ||
|
||
|
||
class WBC: | ||
def __init__( | ||
self, | ||
param_handler: blf.parameters_handler.IParametersHandler, | ||
kindyn: idyn.KinDynComputations, | ||
): | ||
self.solver, self.tasks, self.variables_handler = blf.utils.create_tsid( | ||
kindyn=kindyn, param_handler=param_handler | ||
) |
56 changes: 56 additions & 0 deletions
56
utilities/balancing-torque-control/balancing_torque_control/zmp.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# This software may be modified and distributed under the terms of the BSD-3-Clause license. | ||
# Authors: Giulio Romualdi | ||
|
||
import idyntree.swig as idyn | ||
|
||
|
||
def evaluate_local_zmp(wrench, contact_force_threshold): | ||
tau_x = wrench[3] | ||
tau_y = wrench[4] | ||
f_z = wrench[2] | ||
if f_z >= contact_force_threshold: | ||
return [-tau_y / f_z, tau_x / f_z, 0.0], True | ||
return [0.0, 0.0, 0.0], False | ||
|
||
|
||
def evaluate_global_zmp( | ||
left_wrench, | ||
right_wrench, | ||
kindyn: idyn.KinDynComputations, | ||
l_sole_frame, | ||
r_sole_frame, | ||
contact_force_threshold, | ||
): | ||
def to_int(is_defined): | ||
if is_defined: | ||
return 1 | ||
return 0 | ||
|
||
left_zmp, zmp_left_defined = evaluate_local_zmp( | ||
left_wrench, contact_force_threshold | ||
) | ||
right_zmp, zmp_right_defined = evaluate_local_zmp( | ||
right_wrench, contact_force_threshold | ||
) | ||
|
||
total_z = right_wrench[2] * to_int(zmp_right_defined) + left_wrench[2] * to_int( | ||
zmp_left_defined | ||
) | ||
|
||
inertial_zmp_left = kindyn.getWorldTransform(l_sole_frame) * idyn.Position(left_zmp) | ||
inertial_zmp_right = kindyn.getWorldTransform(r_sole_frame) * idyn.Position( | ||
right_zmp | ||
) | ||
|
||
inertial_global_zmp = ( | ||
left_wrench[2] | ||
* to_int(zmp_left_defined) | ||
* inertial_zmp_left.toNumPy() | ||
/ total_z | ||
+ right_wrench[2] | ||
* to_int(zmp_right_defined) | ||
* inertial_zmp_right.toNumPy() | ||
/ total_z | ||
) | ||
|
||
return inertial_global_zmp |
19 changes: 19 additions & 0 deletions
19
...ing-torque-control/config/robots/ergoCubGazeboV1/blf-balancing-torque-control-options.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
dt 0.01 # (0.01 seconds) | ||
contact_force_threshold 0.1 # in Newton | ||
|
||
|
||
com_knots_delta_x (0.0, 0.0, 0.03, 0.03, -0.03, -0.03, 0.0, 0.0) # in meter | ||
com_knots_delta_y (0.0, 0.05, 0.05, -0.05, -0.05, 0.05, 0.05, 0.0) # in meter | ||
com_knots_delta_z (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) # in meter | ||
|
||
motion_duration 10.0 # (10 seconds) | ||
motion_timeout 10.0 # (10 seconds) | ||
|
||
base_frame l_sole | ||
left_contact_frame l_sole | ||
right_contact_frame r_sole | ||
|
||
[include TSID "./blf_balancing_torque_control/tsid.ini"] | ||
[include ROBOT_CONTROL "./blf_balancing_torque_control/robot_control.ini"] | ||
[include SENSOR_BRIDGE "./blf_balancing_torque_control/sensor_bridge.ini"] | ||
[include CONTACT_WRENCHES "./blf_balancing_torque_control/contact_wrenches.ini"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log()->error("[YarpRobotControl::setReferences] Unable to set the control modes.");
should be
log()->error("[YarpRobotControl::setControlMode] Unable to set the control modes.");