Skip to content

Commit 9069b62

Browse files
Add joint velocity filter integration and profiling to balancing torque control
1 parent f07bfd7 commit 9069b62

6 files changed

Lines changed: 39 additions & 0 deletions

File tree

utilities/balancing-torque-control/config/robots/lowerbodyqdd/blf-balancing-torque-control-options.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ left_contact_frame l_sole
1414
right_contact_frame r_sole
1515

1616
[include TSID "./blf_balancing_torque_control/tsid.ini"]
17+
[include JOINT_VELOCITY_FILTER "./blf_balancing_torque_control/joint_velocity_filter.ini"]
1718
[include ROBOT_CONTROL "./blf_balancing_torque_control/robot_control.ini"]
1819
[include SENSOR_BRIDGE "./blf_balancing_torque_control/sensor_bridge.ini"]
1920
[include DATA_LOGGING "./blf_balancing_torque_control/data_logging.ini"]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sampling_time 0.001
2+
cutoff_frequency 20.0
3+
order 2

utilities/balancing-torque-control/config/robots/lowerbodyqdd/blf_balancing_torque_control/tasks/base_dynamics.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ priority 0
55

66
robot_acceleration_variable_name "robot_acceleration"
77
max_number_of_contacts 2
8+
consider_only_gravitational_term true
89

910
[CONTACT_0]
1011
variable_name "lf_wrench"

utilities/balancing-torque-control/config/robots/lowerbodyqdd/blf_balancing_torque_control/tasks/joint_dynamics.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ priority 0
55
robot_acceleration_variable_name "robot_acceleration"
66
joint_torques_variable_name "joint_torques"
77
max_number_of_contacts 2
8+
consider_only_gravitational_term true
89

910
[CONTACT_0]
1011
variable_name "lf_wrench"

utilities/balancing-torque-control/config/robots/lowerbodyqdd/blf_balancing_torque_control/tsid.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ number_of_slices 2
6868
static_friction_coefficient 0.3
6969
foot_limits_x (-0.1, 0.1)
7070
foot_limits_y (-0.05, 0.05)
71+
max_admissible_normal_force 1000.0
7172

7273
[RF_WRENCH_TASK]
7374
name "rf_feasibility_wrench_task"
@@ -80,6 +81,7 @@ number_of_slices 2
8081
static_friction_coefficient 0.3
8182
foot_limits_x (-0.1, 0.1)
8283
foot_limits_y (-0.05, 0.05)
84+
max_admissible_normal_force 1000.0
8385

8486
[include BASE_DYNAMICS_TASK ./tasks/base_dynamics.ini]
8587
[include JOINT_DYNAMICS_TASK ./tasks/joint_dynamics.ini]

utilities/balancing-torque-control/script/blf-balancing-torque-control.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,15 @@ def __init__(self, config_file: str):
213213
self.index = 0
214214
self.knot_index = 1
215215

216+
self.joint_velocity_filter = blf.continuous_dynamical_system.ButterworthFilter()
217+
if not self.joint_velocity_filter.initialize(
218+
param_handler.get_group("JOINT_VELOCITY_FILTER")
219+
):
220+
raise RuntimeError("Unable to initialize the joint velocity filter.")
221+
222+
# reset the filter with zero velocity
223+
self.joint_velocity_filter.reset(np.zeros(len(self.joint_positions)))
224+
216225
self.vectors_collection_server = blf.yarp_utilities.VectorsCollectionServer()
217226
if not self.vectors_collection_server.initialize(
218227
param_handler.get_group("DATA_LOGGING")
@@ -320,6 +329,17 @@ def advance(self):
320329
blf.log().error("Impossible to get the joint velocities.")
321330
return False
322331

332+
# filter the joint velocities
333+
if not self.joint_velocity_filter.set_input(self.joint_velocities):
334+
blf.log().error("Impossible to set the input of the joint velocity filter.")
335+
return False
336+
337+
if not self.joint_velocity_filter.advance():
338+
blf.log().error("Impossible to advance the joint velocity filter.")
339+
return False
340+
341+
self.joint_velocities = self.joint_velocity_filter.get_output()
342+
323343
if not self.kindyn.setRobotState(
324344
self.frame_T_link,
325345
self.desired_joint_positions,
@@ -469,11 +489,22 @@ def main():
469489

470490
application = Application(config_file="blf-balancing-torque-control-options.ini")
471491

492+
profiler = blf.system.TimeProfiler()
493+
profiler.set_period(10 / application.dt.total_seconds())
494+
profiler.add_timer("Loop")
495+
496+
blf.log().info("Press enter to start the balancing torque control.")
497+
input()
498+
472499
while True:
473500
tic = blf.clock().now()
474501

502+
profiler.setInitTime("Loop")
475503
if not application.advance():
476504
return False
505+
profiler.setFinalTime("Loop")
506+
507+
profiler.profile()
477508

478509
toc = blf.clock().now()
479510
delta_time = toc - tic

0 commit comments

Comments
 (0)