Skip to content

Commit 1327dd8

Browse files
committed
Print payload parameters when identifying payload
1 parent aa76ae5 commit 1327dd8

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

scripts/solve_inertial_param_sdp.py

+60
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,66 @@ def main():
805805
var_sol_dict=var_sol_dict,
806806
)
807807

808+
if initial_param_path is not None and payload_only:
809+
# Compute the difference in the last link's parameters. This corresponds
810+
# to the payload parameters if `initial_param_path` are the parameters
811+
# without payload.
812+
inital_last_link_params = get_plant_joint_params(
813+
arm_plant_components.plant,
814+
arm_plant_components.plant_context,
815+
add_rotor_inertia=identify_rotor_inertia,
816+
add_reflected_inertia=identify_reflected_inertia,
817+
add_viscous_friction=identify_viscous_friction,
818+
add_dynamic_dry_friction=identify_dynamic_dry_friction,
819+
payload_only=payload_only,
820+
)[-1]
821+
# We can subtract the lumped parameters as they are all in the last
822+
# link's frame.
823+
last_link_idx = num_joints - 1
824+
payload_mass = (
825+
var_sol_dict[f"m{last_link_idx}(0)"] - inital_last_link_params.m
826+
)
827+
payload_hcom = (
828+
np.array(
829+
[
830+
var_sol_dict[f"hx{last_link_idx}(0)"],
831+
var_sol_dict[f"hy{last_link_idx}(0)"],
832+
var_sol_dict[f"hz{last_link_idx}(0)"],
833+
]
834+
)
835+
- inital_last_link_params.m * inital_last_link_params.get_com()
836+
)
837+
payload_com = payload_hcom / payload_mass
838+
payload_rot_inertia = (
839+
np.array(
840+
[
841+
[
842+
var_sol_dict[f"Ixx{last_link_idx}(0)"],
843+
var_sol_dict[f"Ixy{last_link_idx}(0)"],
844+
var_sol_dict[f"Ixz{last_link_idx}(0)"],
845+
],
846+
[
847+
var_sol_dict[f"Ixy{last_link_idx}(0)"],
848+
var_sol_dict[f"Iyy{last_link_idx}(0)"],
849+
var_sol_dict[f"Iyz{last_link_idx}(0)"],
850+
],
851+
[
852+
var_sol_dict[f"Ixz{last_link_idx}(0)"],
853+
var_sol_dict[f"Iyz{last_link_idx}(0)"],
854+
var_sol_dict[f"Izz{last_link_idx}(0)"],
855+
],
856+
]
857+
)
858+
- inital_last_link_params.get_inertia_matrix()
859+
)
860+
logging.info(
861+
"Difference in the last link's parameters (payload parameters). "
862+
+ "Note that these are in the last link's frame:"
863+
)
864+
logging.info(f"Payload mass: {payload_mass}")
865+
logging.info(f"Payload CoM: {payload_com}")
866+
logging.info(f"Payload inertia:\n{payload_rot_inertia}")
867+
808868
if output_param_path is not None:
809869
logging.info(f"Saving parameters to {output_param_path}")
810870
directory: Path = output_param_path.parent

0 commit comments

Comments
 (0)