Skip to content

Commit c300368

Browse files
committed
Add option to constrain max total mass
1 parent 1327dd8 commit c300368

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

robot_payload_id/optimization/inertial_param_sdp.py

+8
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def solve_inertial_param_sdp(
6868
identify_viscous_friction: bool = True,
6969
identify_dynamic_dry_friction: bool = True,
7070
payload_only=False,
71+
known_max_mass: Optional[float] = None,
7172
solver_kPrintToConsole: bool = False,
7273
) -> Tuple[
7374
MathematicalProgram, MathematicalProgramResult, np.ndarray, np.ndarray, np.ndarray
@@ -102,6 +103,8 @@ def solve_inertial_param_sdp(
102103
payload_only (bool, optional): Whether to only include the 10 inertial
103104
parameters of the last link. These are the parameters that we care about
104105
for payload identification.
106+
known_max_mass (float, optional): The known maximum mass of the robot. This is
107+
used as an upper bound on the sum of the identified masses.
105108
solver_kPrintToConsole (bool, optional): Whether to print solver output.
106109
107110
Returns:
@@ -291,6 +294,11 @@ def solve_inertial_param_sdp(
291294
for dynamic_dry_friction in dynamic_dry_frictions:
292295
prog.AddConstraint(dynamic_dry_friction >= 0)
293296

297+
# Maximum total mass constraint
298+
if known_max_mass is not None:
299+
masses = np.array([var.m for var in variables])
300+
prog.AddConstraint(masses.sum() <= known_max_mass)
301+
294302
options = None
295303
if solver_kPrintToConsole:
296304
options = SolverOptions()

scripts/solve_inertial_param_sdp.py

+8
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,12 @@ def main():
361361
+ "idea if the initial parameters contain random values which can occur when "
362362
+ "some of the parameters are unidentifiable.",
363363
)
364+
parser.add_argument(
365+
"--known_max_mass",
366+
type=float,
367+
help="The known maximum mass of the robot. This is used to set the upper bound "
368+
+ "for the combined mass parameters.",
369+
)
364370
parser.add_argument(
365371
"--process_joint_data",
366372
action="store_true",
@@ -481,6 +487,7 @@ def main():
481487
initial_param_path = args.initial_param_path
482488
output_param_path = args.output_param_path
483489
use_initial_params_for_regularization = args.use_initial_params_for_regularization
490+
known_max_mass = args.known_max_mass
484491
do_process_joint_data = args.process_joint_data
485492
num_endpoints_to_remove = args.num_endpoints_to_remove
486493
compute_velocities = not args.not_compute_velocities
@@ -775,6 +782,7 @@ def main():
775782
identify_viscous_friction=identify_viscous_friction,
776783
identify_dynamic_dry_friction=identify_dynamic_dry_friction,
777784
payload_only=payload_only,
785+
known_max_mass=known_max_mass,
778786
solver_kPrintToConsole=args.kPrintToConsole,
779787
)
780788
if result.is_success():

0 commit comments

Comments
 (0)