File size: 52,074 Bytes
33956db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
import numpy as np
import pinocchio as pin

from .utils import RobotLoader


class HumanLoader(RobotLoader):
    path = "human_description"
    urdf_filename = "human.urdf"
    free_flyer = True
    ref_posture = "anatomical"
    # Enforced, unchangeable free-flyer orientation (90° about X, and Y↔Z swap)
    freeflyer_ori: np.ndarray = np.array(
        [
            [1, 0, 0],
            [0, 0, -1],
            [0, 1, 0],
        ]
    )

    def __init__(
        self,
        height: float | None = None,
        weight: float | None = None,
        gender: str = "m",
        verbose: bool = False,
    ):
        """
        Initialize the robot loader with optional scaling and configuration parameters. The scaling of the model is based on Dumas 2007, except for the
        abdomen and thorax segments, which are scaled based de Leva 1996.
        Parameters:
            height (float, optional): The height to scale the robot model to. If None, uses the default height in the urdf of 1.80m.
            weight (float, optional): The weight to scale the robot model to. If None, uses the default weight in the urdf 75kg.
            gender (str, optional): The gender specification for scaling, default is 'm'.
            verbose (bool, optional): If True, enables verbose output. Default is False.
        Behavior:
            - Calls the base loader's initializer.
            - If height or weight is provided, scales the robot model accordingly.
            - The free-flyer is present, it enforces its orientation and reapplies joint limits.
        """

        # call base loader
        super().__init__(verbose=verbose)

        if height is not None or weight is not None:
            self._scale_pin_model(
                self.robot.model, self.robot.visual_model, height, weight, gender
            )

        # automatically apply the enforced free-flyer orientation
        if self.free_flyer:
            # get joint index
            j_id = self.robot.model.getJointId("root_joint")
            # assign enforced rotation
            self.robot.model.jointPlacements[j_id].rotation = self.freeflyer_ori
            # re-apply limits
            self.addFreeFlyerJointLimits()

    @staticmethod
    def get_dict_inertial_param(
        height: float, weight: float, gender: str = "m"
    ) -> dict:
        inertial_segment_names = [
            "middle_pelvis",
            "left_upperleg",
            "left_lowerleg",
            "left_foot",
            "middle_abdomen",
            "middle_thorax",
            "middle_head",
            "left_upperarm",
            "left_lowerarm",
            "left_hand",
            "right_upperarm",
            "right_lowerarm",
            "right_hand",
            "right_upperleg",
            "right_lowerleg",
            "right_foot",
        ]

        sgt_lengths = {}

        dicts = []

        # Ratios from Dumas 2007 and De Leva 1996 for abdomen and thorax
        for name in inertial_segment_names:
            dict_sgmt = {}
            if name == "middle_pelvis":
                length = (0.0634 if gender == "f" else 0.0505) * height
                sgt_lengths["middle_pelvis_0"] = length
                sgt_lengths["middle_pelvis_0_width"] = (
                    0.1478 if gender == "f" else 0.1265
                ) * height
                dict_sgmt["mass"] = np.round(
                    (0.146 if gender == "f" else 0.142) * weight, 2
                )
                dict_sgmt["com"] = np.round(
                    (
                        np.array([-0.009, -0.232, 0.002])
                        if gender == "f"
                        else np.array([0.028, -0.28, -0.006])
                    )
                    * length,
                    3,
                )
                dict_sgmt["inertia"] = np.round(
                    (
                        np.array(
                            [
                                (length * 0.91) ** 2,
                                -((length * 0.34) ** 2),
                                -((length * 0.01) ** 2),
                                (length * 1) ** 2,
                                -((length * 0.01) ** 2),
                                (length * 0.79) ** 2,
                            ]
                        )
                        if gender == "f"
                        else np.array(
                            [
                                (length * 1.01) ** 2,
                                -((length * 0.25) ** 2),
                                -((length * 0.12) ** 2),
                                (length * 1.06) ** 2,
                                -((length * 0.08) ** 2),
                                (length * 0.95) ** 2,
                            ]
                        )
                    )
                    * dict_sgmt["mass"],
                    5,
                )
                dicts.append(dict_sgmt)
            elif name == "left_upperleg":
                length = (0.2354 if gender == "f" else 0.2441) * height
                sgt_lengths["left_upperleg_0"] = length
                dict_sgmt["mass"] = np.round(
                    (0.146 if gender == "f" else 0.123) * weight, 2
                )
                dict_sgmt["com"] = np.round(
                    (
                        np.array([-0.077, -0.377, 0.009])
                        if gender == "f"
                        else np.array([-0.041, -0.429, 0.033])
                    )
                    * length,
                    3,
                )
                dict_sgmt["inertia"] = np.round(
                    (
                        np.array(
                            [
                                (length * 0.31) ** 2,
                                (length * 0.07) ** 2,
                                -((length * 0.02) ** 2),
                                (length * 0.19) ** 2,
                                -((length * 0.07) ** 2),
                                (length * 0.32) ** 2,
                            ]
                        )
                        if gender == "f"
                        else np.array(
                            [
                                (length * 0.29) ** 2,
                                (length * 0.07) ** 2,
                                -((length * 0.02) ** 2),
                                (length * 0.15) ** 2,
                                -((length * 0.07) ** 2),
                                (length * 0.3) ** 2,
                            ]
                        )
                    )
                    * dict_sgmt["mass"],
                    5,
                )
                dicts.append(dict_sgmt)
            elif name == "left_lowerleg":
                length = (0.2410 if gender == "f" else 0.2446) * height
                sgt_lengths["left_lowerleg_0"] = length
                dict_sgmt["mass"] = np.round(
                    (0.045 if gender == "f" else 0.048) * weight, 2
                )
                dict_sgmt["com"] = np.round(
                    (
                        np.array([-0.049, -0.404, 0.031])
                        if gender == "f"
                        else np.array([-0.048, -0.41, 0.007])
                    )
                    * length,
                    3,
                )
                dict_sgmt["inertia"] = np.round(
                    (
                        np.array(
                            [
                                (length * 0.28) ** 2,
                                (length * 0.02) ** 2,
                                (length * 0.01) ** 2,
                                (length * 0.1) ** 2,
                                (length * 0.06) ** 2,
                                (length * 0.28) ** 2,
                            ]
                        )
                        if gender == "f"
                        else np.array(
                            [
                                (length * 0.28) ** 2,
                                (length * 0.04) ** 2,
                                (length * 0.02) ** 2,
                                (length * 0.1) ** 2,
                                (length * 0.05) ** 2,
                                (length * 0.28) ** 2,
                            ]
                        )
                    )
                    * dict_sgmt["mass"],
                    5,
                )
                dicts.append(dict_sgmt)
            elif name == "left_foot":
                length = (0.1447 if gender == "f" else 0.1497) * height
                sgt_lengths["left_foot_0"] = length
                dict_sgmt["mass"] = np.round(
                    (0.01 if gender == "f" else 0.012) * weight, 2
                )
                dict_sgmt["com"] = np.round(
                    (
                        np.array([0.27, -0.218, 0.039])
                        if gender == "f"
                        else np.array([0.382, -0.151, 0.026])
                    )
                    * length,
                    3,
                )
                dict_sgmt["inertia"] = np.round(
                    (
                        np.array(
                            [
                                (length * 0.17) ** 2,
                                -((length * 0.10) ** 2),
                                (length * 0.06) ** 2,
                                (length * 0.36) ** 2,
                                -((length * 0.04) ** 2),
                                (length * 0.35) ** 2,
                            ]
                        )
                        if gender == "f"
                        else np.array(
                            [
                                (length * 0.17) ** 2,
                                (length * 0.13) ** 2,
                                -((length * 0.08) ** 2),
                                (length * 0.37) ** 2,
                                (length * 0) ** 2,
                                (length * 0.36) ** 2,
                            ]
                        )
                    )
                    * dict_sgmt["mass"],
                    5,
                )
                dicts.append(dict_sgmt)
            elif name == "middle_abdomen":
                length = (0.1183 if gender == "f" else 0.1237) * height
                sgt_lengths["middle_abdomen_0"] = length
                dict_sgmt["mass"] = np.round(
                    (0.1465 if gender == "f" else 0.1633) * weight, 2
                )
                dict_sgmt["com"] = np.round(
                    (
                        np.array([-0.016, -0.4512, -0.006])
                        if gender == "f"
                        else np.array([-0.036, 0.4502, -0.002])
                    )
                    * length,
                    3,
                )
                dict_sgmt["inertia"] = np.round(
                    (
                        np.array(
                            [
                                (length * 0.29) ** 2,
                                (length * 0.22) ** 2,
                                (length * 0.05) ** 2,
                                (length * 0.27) ** 2,
                                -((length * 0.05) ** 2),
                                (length * 0.29) ** 2,
                            ]
                        )
                        if gender == "f"
                        else np.array(
                            [
                                (length * 0.27) ** 2,
                                (length * 0.18) ** 2,
                                -((length * 0.02) ** 2),
                                (length * 0.25) ** 2,
                                -((length * 0.04) ** 2),
                                (length * 0.28) ** 2,
                            ]
                        )
                    )
                    * dict_sgmt["mass"],
                    5,
                )
                dicts.append(dict_sgmt)
            elif name == "middle_thorax":
                length = (0.1314 if gender == "f" else 0.1390) * height
                sgt_lengths["middle_thorax_0"] = length
                dict_sgmt["mass"] = np.round(
                    (0.1545 if gender == "f" else 0.1596) * weight, 2
                )
                dict_sgmt["com"] = np.round(
                    (
                        np.array([-0.016, 0.5050, -0.006])
                        if gender == "f"
                        else np.array([-0.036, 0.5066, -0.002])
                    )
                    * length,
                    3,
                )
                dict_sgmt["inertia"] = np.round(
                    (
                        np.array(
                            [
                                (length * 0.29) ** 2,
                                (length * 0.22) ** 2,
                                (length * 0.05) ** 2,
                                (length * 0.27) ** 2,
                                -((length * 0.05) ** 2),
                                (length * 0.29) ** 2,
                            ]
                        )
                        if gender == "f"
                        else np.array(
                            [
                                (length * 0.27) ** 2,
                                (length * 0.18) ** 2,
                                -((length * 0.02) ** 2),
                                (length * 0.25) ** 2,
                                -((length * 0.04) ** 2),
                                (length * 0.28) ** 2,
                            ]
                        )
                    )
                    * dict_sgmt["mass"],
                    5,
                )
                dicts.append(dict_sgmt)
            elif name == "middle_head":
                length = (0.1308 if gender == "f" else 0.1310) * height
                sgt_lengths["middle_head_0"] = length
                dict_sgmt["mass"] = np.round(
                    0.067 * weight, 2
                )  # same for male and female
                dict_sgmt["com"] = np.round(
                    (
                        np.array([-0.07, 0.597, 0])
                        if gender == "f"
                        else np.array([-0.062, 0.555, 0.001])
                    )
                    * length,
                    3,
                )
                dict_sgmt["inertia"] = np.round(
                    (
                        np.array(
                            [
                                (length * 0.32) ** 2,
                                -((length * 0.06) ** 2),
                                (length * 0.01) ** 2,
                                (length * 0.27) ** 2,
                                -((length * 0.01) ** 2),
                                (length * 0.34) ** 2,
                            ]
                        )
                        if gender == "f"
                        else np.array(
                            [
                                (length * 0.31) ** 2,
                                -((length * 0.09) ** 2),
                                -((length * 0.02) ** 2),
                                (length * 0.25) ** 2,
                                (length * 0.03) ** 2,
                                (length * 0.33) ** 2,
                            ]
                        )
                    )
                    * dict_sgmt["mass"],
                    5,
                )
                dicts.append(dict_sgmt)
            elif name == "left_upperarm":
                length = (0.1510 if gender == "f" else 0.1531) * height
                sgt_lengths["left_upperarm_0"] = length
                dict_sgmt["mass"] = np.round(
                    (0.022 if gender == "f" else 0.024) * weight, 2
                )
                dict_sgmt["com"] = np.round(
                    (
                        np.array([-0.073, -0.454, -0.028])
                        if gender == "f"
                        else np.array([0.017, -0.452, -0.026])
                    )
                    * length,
                    3,
                )
                dict_sgmt["inertia"] = np.round(
                    (
                        np.array(
                            [
                                (length * 0.33) ** 2,
                                (length * 0.03) ** 2,
                                -((length * 0.05) ** 2),
                                (length * 0.17) ** 2,
                                -((length * 0.14) ** 2),
                                (length * 0.33) ** 2,
                            ]
                        )
                        if gender == "f"
                        else np.array(
                            [
                                (length * 0.31) ** 2,
                                (length * 0.06) ** 2,
                                (length * 0.05) ** 2,
                                (length * 0.14) ** 2,
                                (length * 0.02) ** 2,
                                (length * 0.32) ** 2,
                            ]
                        )
                    )
                    * dict_sgmt["mass"],
                    5,
                )
                dicts.append(dict_sgmt)
            elif name == "left_lowerarm":
                length = (0.1534 if gender == "f" else 0.1593) * height
                sgt_lengths["left_lowerarm_0"] = length
                dict_sgmt["mass"] = np.round(
                    (0.013 if gender == "f" else 0.017) * weight, 2
                )
                dict_sgmt["com"] = np.round(
                    (
                        np.array([0.021, -0.411, 0.019])
                        if gender == "f"
                        else np.array([0.01, -0.417, 0.014])
                    )
                    * length,
                    3,
                )
                dict_sgmt["inertia"] = np.round(
                    (
                        np.array(
                            [
                                (length * 0.26) ** 2,
                                (length * 0.1) ** 2,
                                (length * 0.04) ** 2,
                                (length * 0.14) ** 2,
                                -((length * 0.13) ** 2),
                                (length * 0.25) ** 2,
                            ]
                        )
                        if gender == "f"
                        else np.array(
                            [
                                (length * 0.28) ** 2,
                                (length * 0.03) ** 2,
                                (length * 0.02) ** 2,
                                (length * 0.11) ** 2,
                                -((length * 0.08) ** 2),
                                (length * 0.27) ** 2,
                            ]
                        )
                    )
                    * dict_sgmt["mass"],
                    5,
                )
                dicts.append(dict_sgmt)
            elif name == "left_hand":
                length = (0.0989 if gender == "f" else 0.1014) * height
                sgt_lengths["left_hand_0"] = length
                dict_sgmt["mass"] = np.round(
                    (0.005 if gender == "f" else 0.006) * weight, 2
                )
                dict_sgmt["com"] = np.round(
                    (
                        np.array([0.077, -0.768, 0.048])
                        if gender == "f"
                        else np.array([0.082, -0.839, 0.074])
                    )
                    * length,
                    3,
                )
                dict_sgmt["inertia"] = np.round(
                    (
                        np.array(
                            [
                                (length * 0.63) ** 2,
                                (length * 0.29) ** 2,
                                (length * 0.23) ** 2,
                                (length * 0.43) ** 2,
                                -((length * 0.28) ** 2),
                                (length * 0.58) ** 2,
                            ]
                        )
                        if gender == "f"
                        else np.array(
                            [
                                (length * 0.61) ** 2,
                                (length * 0.22) ** 2,
                                (length * 0.15) ** 2,
                                (length * 0.38) ** 2,
                                -((length * 0.2) ** 2),
                                (length * 0.56) ** 2,
                            ]
                        )
                    )
                    * dict_sgmt["mass"],
                    5,
                )
                dicts.append(dict_sgmt)
            elif name == "right_upperarm":
                length = (0.1510 if gender == "f" else 0.1531) * height
                sgt_lengths["right_upperarm_0"] = length
                dict_sgmt["mass"] = np.round(
                    (0.022 if gender == "f" else 0.024) * weight, 2
                )
                dict_sgmt["com"] = np.round(
                    (
                        np.array([-0.073, -0.454, -0.028])
                        if gender == "f"
                        else np.array([0.017, -0.452, -0.026])
                    )
                    * length,
                    3,
                )
                dict_sgmt["inertia"] = np.round(
                    (
                        np.array(
                            [
                                (length * 0.33) ** 2,
                                (length * 0.03) ** 2,
                                -((length * 0.05) ** 2),
                                (length * 0.17) ** 2,
                                -((length * 0.14) ** 2),
                                (length * 0.33) ** 2,
                            ]
                        )
                        if gender == "f"
                        else np.array(
                            [
                                (length * 0.31) ** 2,
                                (length * 0.06) ** 2,
                                (length * 0.05) ** 2,
                                (length * 0.14) ** 2,
                                (length * 0.02) ** 2,
                                (length * 0.32) ** 2,
                            ]
                        )
                    )
                    * dict_sgmt["mass"],
                    5,
                )
                dicts.append(dict_sgmt)
            elif name == "right_lowerarm":
                length = (0.1534 if gender == "f" else 0.1593) * height
                sgt_lengths["right_lowerarm_0"] = length
                dict_sgmt["mass"] = np.round(
                    (0.013 if gender == "f" else 0.017) * weight, 2
                )
                dict_sgmt["com"] = np.round(
                    (
                        np.array([0.021, -0.411, 0.019])
                        if gender == "f"
                        else np.array([0.01, -0.417, 0.014])
                    )
                    * length,
                    3,
                )
                dict_sgmt["inertia"] = np.round(
                    (
                        np.array(
                            [
                                (length * 0.26) ** 2,
                                (length * 0.1) ** 2,
                                (length * 0.04) ** 2,
                                (length * 0.14) ** 2,
                                -((length * 0.13) ** 2),
                                (length * 0.25) ** 2,
                            ]
                        )
                        if gender == "f"
                        else np.array(
                            [
                                (length * 0.28) ** 2,
                                (length * 0.03) ** 2,
                                (length * 0.02) ** 2,
                                (length * 0.11) ** 2,
                                -((length * 0.08) ** 2),
                                (length * 0.27) ** 2,
                            ]
                        )
                    )
                    * dict_sgmt["mass"],
                    5,
                )
                dicts.append(dict_sgmt)
            elif name == "right_hand":
                length = (0.0989 if gender == "f" else 0.1014) * height
                sgt_lengths["right_hand_0"] = length
                dict_sgmt["mass"] = np.round(
                    (0.005 if gender == "f" else 0.006) * weight, 2
                )
                dict_sgmt["com"] = np.round(
                    (
                        np.array([0.077, -0.768, 0.048])
                        if gender == "f"
                        else np.array([0.082, -0.839, 0.074])
                    )
                    * length,
                    3,
                )
                dict_sgmt["inertia"] = np.round(
                    (
                        np.array(
                            [
                                (length * 0.63) ** 2,
                                (length * 0.29) ** 2,
                                (length * 0.23) ** 2,
                                (length * 0.43) ** 2,
                                -((length * 0.28) ** 2),
                                (length * 0.58) ** 2,
                            ]
                        )
                        if gender == "f"
                        else np.array(
                            [
                                (length * 0.61) ** 2,
                                (length * 0.22) ** 2,
                                (length * 0.15) ** 2,
                                (length * 0.38) ** 2,
                                -((length * 0.2) ** 2),
                                (length * 0.56) ** 2,
                            ]
                        )
                    )
                    * dict_sgmt["mass"],
                    5,
                )
                dicts.append(dict_sgmt)
            elif name == "right_upperleg":
                length = (0.2354 if gender == "f" else 0.2441) * height
                sgt_lengths["right_upperleg_0"] = length
                dict_sgmt["mass"] = np.round(
                    (0.146 if gender == "f" else 0.123) * weight, 2
                )
                dict_sgmt["com"] = np.round(
                    (
                        np.array([-0.077, -0.377, 0.009])
                        if gender == "f"
                        else np.array([-0.041, -0.429, 0.033])
                    )
                    * length,
                    3,
                )
                dict_sgmt["inertia"] = np.round(
                    (
                        np.array(
                            [
                                (length * 0.31) ** 2,
                                -((length * 0.07) ** 2),
                                -((length * 0.02) ** 2),
                                (length * 0.19) ** 2,
                                -((length * 0.07) ** 2),
                                (length * 0.32) ** 2,
                            ]
                        )
                        if gender == "f"
                        else np.array(
                            [
                                (length * 0.29) ** 2,
                                -((length * 0.07) ** 2),
                                -((length * 0.02) ** 2),
                                (length * 0.15) ** 2,
                                -((length * 0.07) ** 2),
                                (length * 0.3) ** 2,
                            ]
                        )
                    )
                    * dict_sgmt["mass"],
                    5,
                )
                dicts.append(dict_sgmt)
            elif name == "right_lowerleg":
                length = (0.2410 if gender == "f" else 0.2446) * height
                sgt_lengths["right_lowerleg_0"] = length
                dict_sgmt["mass"] = np.round(
                    (0.045 if gender == "f" else 0.048) * weight, 2
                )
                dict_sgmt["com"] = np.round(
                    (
                        np.array([-0.049, -0.404, 0.031])
                        if gender == "f"
                        else np.array([-0.048, -0.41, 0.007])
                    )
                    * length,
                    3,
                )
                dict_sgmt["inertia"] = np.round(
                    (
                        np.array(
                            [
                                (length * 0.28) ** 2,
                                (length * 0.02) ** 2,
                                (length * 0.01) ** 2,
                                (length * 0.1) ** 2,
                                (length * 0.06) ** 2,
                                (length * 0.28) ** 2,
                            ]
                        )
                        if gender == "f"
                        else np.array(
                            [
                                (length * 0.28) ** 2,
                                (length * 0.04) ** 2,
                                (length * 0.02) ** 2,
                                (length * 0.1) ** 2,
                                (length * 0.05) ** 2,
                                (length * 0.28) ** 2,
                            ]
                        )
                    )
                    * dict_sgmt["mass"],
                    5,
                )
                dicts.append(dict_sgmt)
            elif name == "right_foot":
                length = (0.1447 if gender == "f" else 0.1497) * height
                sgt_lengths["right_foot_0"] = length
                dict_sgmt["mass"] = np.round(
                    (0.01 if gender == "f" else 0.012) * weight, 2
                )
                dict_sgmt["com"] = np.round(
                    (
                        np.array([0.27, -0.218, 0.039])
                        if gender == "f"
                        else np.array([0.382, -0.151, 0.026])
                    )
                    * length,
                    3,
                )
                dict_sgmt["inertia"] = np.round(
                    (
                        np.array(
                            [
                                (length * 0.17) ** 2,
                                -((length * 0.10) ** 2),
                                (length * 0.06) ** 2,
                                (length * 0.36) ** 2,
                                -((length * 0.04) ** 2),
                                (length * 0.35) ** 2,
                            ]
                        )
                        if gender == "f"
                        else np.array(
                            [
                                (length * 0.17) ** 2,
                                (length * 0.13) ** 2,
                                -((length * 0.08) ** 2),
                                (length * 0.37) ** 2,
                                (length * 0) ** 2,
                                (length * 0.36) ** 2,
                            ]
                        )
                    )
                    * dict_sgmt["mass"],
                    5,
                )
                dicts.append(dict_sgmt)

        return dict(zip(inertial_segment_names, dicts)), sgt_lengths

    @staticmethod
    def get_dict_joint_placements(height: float, gender: str = "m") -> dict:
        joint_names = [
            "middle_thoracic_Z",
            "middle_cervical_Z",
            "left_clavicle_joint_X",
            "right_clavicle_joint_X",
            "left_shoulder_Z",
            "left_elbow_Z",
            "left_wrist_Z",
            "right_shoulder_Z",
            "right_elbow_Z",
            "right_wrist_Z",
            "left_hip_Z",
            "left_knee_Z",
            "left_ankle_Z",
            "right_hip_Z",
            "right_knee_Z",
            "right_ankle_Z",
        ]

        lengths_names = [
            "L_abdomen",
            "L_thorax_cerv",
            "L_thorax_supr",
            "L_upperarm",
            "L_lowerarm",
            "L_upperleg",
            "L_lowerleg",
        ]
        ratios = np.array(
            [
                0.1183
                if gender == "f"
                else 0.1237,  # L_abdomen MPT  from XYP to OMPH (De Leva 1996)
                0.1314
                if gender == "f"
                else 0.1390,  # L_thorax UPT from CERV to XYPH (De Leva 1996)
                0.0821 if gender == "f" else 0.0980,  # from SUPR to XYPH (De Leva 1996)
                0.1510 if gender == "f" else 0.1531,  # L_upperarm (Dumas 2007)
                0.1534 if gender == "f" else 0.1593,  # L_lowerarm (Dumas 2007)
                0.2354 if gender == "f" else 0.2441,  # L_upperleg (Dumas 2007)
                0.2410 if gender == "f" else 0.2446,  # L_lowerleg (Dumas 2007)
            ]
        )
        # Ratios from De Leva : HJC from Seidel
        # SJC Schnorenberg-style AC/H = 0.132 (F) or 0.0129 (M)
        SJ_thorax_X_r = 0.0043 if gender == "f" else 0.0046
        SJ_thorax_Y_r = -0.0449 if gender == "f" else -0.0416
        SJ_thorax_Z_r = 0.1108 if gender == "f" else 0.1164
        HJ_pelvis_X_r = 0.0138 if gender == "f" else 0.0126
        HJ_pelvis_Y_r = -0.0570 if gender == "f" else -0.0558
        HJ_pelvis_Z_r = 0.0548 if gender == "f" else 0.0457

        lengths = np.round(ratios * height, 3)  # mm accuracy
        dict_lengths = dict(zip(lengths_names, lengths))

        joint_placements = []
        for j in joint_names:
            if j == "middle_thoracic_Z":
                joint_placements.append(np.array([0, dict_lengths["L_abdomen"], 0]))
            elif j == "middle_cervical_Z":
                joint_placements.append(np.array([0, dict_lengths["L_thorax_cerv"], 0]))
            elif j == "left_clavicle_joint_X":
                joint_placements.append(np.array([0, dict_lengths["L_thorax_supr"], 0]))
            elif j == "right_clavicle_joint_X":
                joint_placements.append(np.array([0, dict_lengths["L_thorax_supr"], 0]))
            elif j == "left_shoulder_Z":
                joint_placements.append(
                    np.round(
                        height
                        * np.array([SJ_thorax_X_r, SJ_thorax_Y_r, -SJ_thorax_Z_r]),
                        3,
                    )
                )
            elif j == "left_elbow_Z":
                joint_placements.append(np.array([0, -dict_lengths["L_upperarm"], 0]))
            elif j == "left_wrist_Z":
                joint_placements.append(np.array([0, -dict_lengths["L_lowerarm"], 0]))
            elif j == "right_shoulder_Z":
                joint_placements.append(
                    np.round(
                        height
                        * np.array([SJ_thorax_X_r, SJ_thorax_Y_r, SJ_thorax_Z_r]),
                        3,
                    )
                )
            elif j == "right_elbow_Z":
                joint_placements.append(np.array([0, -dict_lengths["L_upperarm"], 0]))
            elif j == "right_wrist_Z":
                joint_placements.append(np.array([0, -dict_lengths["L_lowerarm"], 0]))
            elif j == "left_hip_Z":
                joint_placements.append(
                    np.round(
                        height
                        * np.array([HJ_pelvis_X_r, HJ_pelvis_Y_r, -HJ_pelvis_Z_r]),
                        3,
                    )
                )
            elif j == "left_knee_Z":
                joint_placements.append(np.array([0, -dict_lengths["L_upperleg"], 0]))
            elif j == "left_ankle_Z":
                joint_placements.append(np.array([0, -dict_lengths["L_lowerleg"], 0]))
            elif j == "right_hip_Z":
                joint_placements.append(
                    np.round(
                        height
                        * np.array([HJ_pelvis_X_r, HJ_pelvis_Y_r, HJ_pelvis_Z_r]),
                        3,
                    )
                )
            elif j == "right_knee_Z":
                joint_placements.append(np.array([0, -dict_lengths["L_upperleg"], 0]))
            elif j == "right_ankle_Z":
                joint_placements.append(np.array([0, -dict_lengths["L_lowerleg"], 0]))

        return dict(zip(joint_names, joint_placements))

    @staticmethod
    def get_dict_meshes_scale(
        height: float, sgt_lengths: dict, gender: str = "m"
    ) -> dict:
        meshes_names = [
            "middle_pelvis_0",
            "left_upperleg_0",
            "left_lowerleg_0",
            "left_lowerleg_1",
            "left_foot_0",
            "middle_abdomen_0",
            "middle_thorax_0",
            "middle_head_0",
            "middle_head_1",
            "left_upperarm_0",
            "left_upperarm_1",
            "left_lowerarm_0",
            "left_lowerarm_1",
            "left_hand_0",
            "right_upperarm_0",
            "right_upperarm_1",
            "right_lowerarm_0",
            "right_lowerarm_1",
            "right_hand_0",
            "right_upperleg_0",
            "right_lowerleg_0",
            "right_lowerleg_1",
            "right_foot_0",
        ]

        scales = []

        for name in meshes_names:
            if (
                name == "middle_pelvis_0"
            ):  # pelvis mesh size is : X = 37.050m, Y = 32.551m, Z = 39.252m
                scale = np.round(
                    np.array(
                        [
                            1.09 * sgt_lengths["middle_pelvis_0_width"] / 39.252,
                            sgt_lengths["middle_pelvis_0_width"] / 39.252,
                            sgt_lengths["middle_pelvis_0_width"] / 39.252,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif (
                name == "left_upperleg_0"
            ):  # upperleg mesh size is : X = 20.977m, Y = 68.524m, Z = 20.977m
                scale = np.round(
                    np.array(
                        [
                            0.96 * sgt_lengths["left_upperleg_0"] / 68.524,
                            sgt_lengths["left_upperleg_0"] / 68.524,
                            1.08 * sgt_lengths["left_upperleg_0"] / 68.524,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif (
                name == "left_lowerleg_0"
            ):  # lowerleg mesh size is : X = 17.986m, Y = 67m, Z = 17.977m
                scale = np.round(
                    np.array(
                        [
                            0.96 * sgt_lengths["left_lowerleg_0"] / 67,
                            sgt_lengths["left_lowerleg_0"] / 67,
                            1.07 * sgt_lengths["left_lowerleg_0"] / 67,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif name == "left_lowerleg_1":  # knee mesh is a sphere of 12.5m
                scale = np.round(
                    np.array(
                        [
                            0.7
                            * (0.053 * height if gender == "f" else 0.056 * height)
                            / 12.5,
                            0.7
                            * (0.053 * height if gender == "f" else 0.056 * height)
                            / 12.5,
                            0.7
                            * (0.053 * height if gender == "f" else 0.056 * height)
                            / 12.5,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif (
                name == "left_foot_0"
            ):  # foot mesh size is : X = 40.5m, Y = 16.5m, Z = 17.999m
                scale = np.round(
                    np.array(
                        [
                            sgt_lengths["left_foot_0"] / 40.5,
                            sgt_lengths["left_foot_0"] / 40.5,
                            sgt_lengths["left_foot_0"] / 40.5,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif name == "middle_abdomen_0":  # abdomen meshis a sphere of radius 30 m
                scale = np.round(
                    np.array(
                        [
                            sgt_lengths["middle_abdomen_0"] / 30,
                            sgt_lengths["middle_abdomen_0"] / 30,
                            sgt_lengths["middle_abdomen_0"] / 30,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif (
                name == "middle_thorax_0"
            ):  # torso mesh size is : X = 36.991m, Y = 35m, Z = 40.029m
                scale = np.round(
                    np.array(
                        [
                            sgt_lengths["middle_thorax_0"] / 35,
                            sgt_lengths["middle_thorax_0"] / 35,
                            sgt_lengths["middle_thorax_0"] / 35,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif (
                name == "middle_head_0"
            ):  # head mesh size is : X = 32.049m, Y = 42m, Z = 32.049m
                scale = np.round(
                    np.array(
                        [
                            sgt_lengths["middle_head_0"] / 42,
                            sgt_lengths["middle_head_0"] / 42,
                            sgt_lengths["middle_head_0"] / 42,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif name == "middle_head_1":  # neck mesh
                scale = np.round(
                    np.array(
                        [
                            (0.078 * height if gender == "f" else 0.086 * height)
                            / 31.0,
                            (0.078 * height if gender == "f" else 0.086 * height)
                            / 31.0,
                            (0.078 * height if gender == "f" else 0.086 * height)
                            / 31.0,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif name == "left_upperarm_0":  # shoulder mesh is a shpere of radius 17.5
                scale = np.round(
                    np.array(
                        [
                            (0.037 * height if gender == "f" else 0.038 * height)
                            / 17.5,
                            (0.037 * height if gender == "f" else 0.038 * height)
                            / 17.5,
                            (0.037 * height if gender == "f" else 0.038 * height)
                            / 17.5,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif (
                name == "left_upperarm_1"
            ):  # upperarm mesh is of size : X = 17.158m, Y = 46m, Z = 17.183m
                scale = np.round(
                    np.array(
                        [
                            1.05 * sgt_lengths["left_upperarm_0"] / 46,
                            sgt_lengths["left_upperarm_0"] / 46,
                            1.16 * sgt_lengths["left_upperarm_0"] / 46,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif (
                name == "left_lowerarm_0"
            ):  # lowerarm mesh is of size : X = 15.547m, Y = 45m, Z = 15.541m
                scale = np.round(
                    np.array(
                        [
                            sgt_lengths["left_lowerarm_0"] / 45,
                            sgt_lengths["left_lowerarm_0"] / 45,
                            sgt_lengths["left_lowerarm_0"] / 45,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif name == "left_lowerarm_1":  # elbow mesh is a sphere of radius 12.5
                scale = np.round(
                    np.array(
                        [
                            (0.037 * height if gender == "f" else 0.038 * height)
                            / 12.5,
                            (0.037 * height if gender == "f" else 0.038 * height)
                            / 12.5,
                            (0.037 * height if gender == "f" else 0.038 * height)
                            / 12.5,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif (
                name == "left_hand_0"
            ):  # hand mesh is of size : X = 12.055m, Y = 30m, Z = 16.646m
                scale = np.round(
                    np.array(
                        [
                            sgt_lengths["left_hand_0"] / 30,
                            sgt_lengths["left_hand_0"] / 30,
                            sgt_lengths["left_hand_0"] / 30,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif name == "right_upperarm_0":  # shoulder mesh
                scale = np.round(
                    np.array(
                        [
                            (0.037 * height if gender == "f" else 0.038 * height)
                            / 17.5,
                            (0.037 * height if gender == "f" else 0.038 * height)
                            / 17.5,
                            (0.037 * height if gender == "f" else 0.038 * height)
                            / 17.5,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif name == "right_upperarm_1":  # upperarm mesh
                scale = np.round(
                    np.array(
                        [
                            1.05 * sgt_lengths["right_upperarm_0"] / 46,
                            sgt_lengths["right_upperarm_0"] / 46,
                            1.16 * sgt_lengths["right_upperarm_0"] / 46,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif name == "right_lowerarm_0":  # lowerarm mesh
                scale = np.round(
                    np.array(
                        [
                            sgt_lengths["right_lowerarm_0"] / 45,
                            sgt_lengths["right_lowerarm_0"] / 45,
                            sgt_lengths["right_lowerarm_0"] / 45,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif name == "right_lowerarm_1":  # elbow mesh
                scale = np.round(
                    np.array(
                        [
                            (0.037 * height if gender == "f" else 0.038 * height)
                            / 12.5,
                            (0.037 * height if gender == "f" else 0.038 * height)
                            / 12.5,
                            (0.037 * height if gender == "f" else 0.038 * height)
                            / 12.5,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif name == "right_hand_0":  # hand mesh
                scale = np.round(
                    np.array(
                        [
                            sgt_lengths["right_hand_0"] / 30,
                            sgt_lengths["right_hand_0"] / 30,
                            sgt_lengths["right_hand_0"] / 30,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif name == "right_upperleg_0":  # upperleg mesh
                scale = np.round(
                    np.array(
                        [
                            0.96 * sgt_lengths["right_upperleg_0"] / 68.524,
                            sgt_lengths["right_upperleg_0"] / 68.524,
                            1.08 * sgt_lengths["right_upperleg_0"] / 68.524,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif name == "right_lowerleg_0":  # lowerleg mesh
                scale = np.round(
                    np.array(
                        [
                            0.96 * sgt_lengths["right_lowerleg_0"] / 67,
                            sgt_lengths["right_lowerleg_0"] / 67,
                            1.07 * sgt_lengths["right_lowerleg_0"] / 67,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif name == "right_lowerleg_1":  # knee mesh
                scale = np.round(
                    np.array(
                        [
                            0.7
                            * (0.053 * height if gender == "f" else 0.056 * height)
                            / 12.5,
                            0.7
                            * (0.053 * height if gender == "f" else 0.056 * height)
                            / 12.5,
                            0.7
                            * (0.053 * height if gender == "f" else 0.056 * height)
                            / 12.5,
                        ]
                    ),
                    4,
                )
                scales.append(scale)
            elif name == "right_foot_0":  # foot mesh
                scale = np.round(
                    np.array(
                        [
                            sgt_lengths["right_foot_0"] / 40.5,
                            sgt_lengths["right_foot_0"] / 40.5,
                            sgt_lengths["right_foot_0"] / 40.5,
                        ]
                    ),
                    4,
                )
                scales.append(scale)

        return dict(zip(meshes_names, scales))

    def _scale_pin_model(
        self,
        model: pin.Model,
        visual_model: pin.GeometryModel,
        height: float,
        weight: float,
        gender: str = "m",
    ) -> None:
        """
        Overwrite model.inertias, model.jointPlacements, and model.geometryObjects.meshScale
        based on anthropometry.
        """
        # compute parameters
        joints = self.get_dict_joint_placements(height, gender)
        inert, sgt_lengths = self.get_dict_inertial_param(height, weight, gender)
        scales = self.get_dict_meshes_scale(height, sgt_lengths, gender)

        # apply inertias
        for seg, P in inert.items():
            b_id = model.frames[model.getFrameId(seg)].parentJoint

            Ixx, Ixy, Ixz, Iyy, Iyz, Izz = P["inertia"]
            I_mat = np.array([[Ixx, Ixy, Ixz], [Ixy, Iyy, Iyz], [Ixz, Iyz, Izz]])
            model.inertias[b_id] = pin.Inertia(P["mass"], P["com"], I_mat)

        # apply joint placements
        for j, pos in joints.items():
            j_id = model.getJointId(j)
            M = model.jointPlacements[j_id]
            M.translation = pos
            model.jointPlacements[j_id] = M

        # scale visuals
        assert len(visual_model.geometryObjects.tolist()) == len(scales)
        for geom_obj in visual_model.geometryObjects:
            geom_obj.meshScale = scales[geom_obj.name]