Skip to content

Commit bddc362

Browse files
authored
Merge pull request #8 from thanhndv212/devel
Logging, Pinocchio 3.x Compatibility & Trajectory Framework Refactoring
2 parents d6fca29 + e444ef1 commit bddc362

19 files changed

+1101
-804
lines changed

src/figaroh/calibration/base_calibration.py

Lines changed: 81 additions & 82 deletions
Large diffs are not rendered by default.

src/figaroh/calibration/calibration_tools.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@
2323
- Data loading and processing utilities
2424
"""
2525

26+
import logging
2627
import numpy as np
2728
import pinocchio as pin
2829

30+
# Setup logger for this module
31+
logger = logging.getLogger(__name__)
32+
logger.addHandler(logging.NullHandler())
33+
2934
from ..tools.regressor import eliminate_non_dynaffect
3035
from ..tools.qrdecomposition import (
3136
get_baseParams,
@@ -361,7 +366,7 @@ def update_forward_kinematics(model, data, var, q, calib_config, verbose=0):
361366
for axis_id, axis in enumerate(axis_tpl):
362367
if axis in key:
363368
if verbose == 1:
364-
print(
369+
logger.debug(
365370
"Updating [{}] joint placement at axis {} with [{}]".format(
366371
j_name, axis, key
367372
)
@@ -381,7 +386,7 @@ def update_forward_kinematics(model, data, var, q, calib_config, verbose=0):
381386
for axis_pee_id, axis_pee in enumerate(EE_TPL):
382387
if axis_pee in key:
383388
if verbose == 1:
384-
print(
389+
logger.debug(
385390
"Updating [{}_{}] joint placement at axis {} with [{}]".format(
386391
ee_name, str(marker_idx), axis_pee, key
387392
)
@@ -568,7 +573,7 @@ def calc_updated_fkm(model, data, var, q, calib_config, verbose=0):
568573
for axis_pee_id, axis_pee in enumerate(EE_TPL):
569574
if axis_pee in key:
570575
if verbose == 1:
571-
print(
576+
logger.debug(
572577
"Updating [{}_{}] joint placement at axis {} with [{}]".format(
573578
ee_name, str(marker_idx), axis_pee, key
574579
)
@@ -579,7 +584,7 @@ def calc_updated_fkm(model, data, var, q, calib_config, verbose=0):
579584
eeMf = cartesian_to_SE3(pee)
580585
else:
581586
if calib_config["NbMarkers"] > 1:
582-
print("Multiple markers are not supported.")
587+
logger.warning("Multiple markers are not supported.")
583588
else:
584589
eeMf = pin.SE3.Identity()
585590

@@ -598,7 +603,7 @@ def calc_updated_fkm(model, data, var, q, calib_config, verbose=0):
598603
for axis_id, axis in enumerate(axis_tpl):
599604
if axis in key:
600605
if verbose == 1:
601-
print(
606+
logger.debug(
602607
"Updating [{}] joint placement at axis {} with [{}]".format(
603608
j_name, axis, key
604609
)

src/figaroh/calibration/config.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
- Frame and joint configuration management
2424
"""
2525

26+
import logging
27+
28+
# Setup logger for this module
29+
logger = logging.getLogger(__name__)
30+
logger.addHandler(logging.NullHandler())
31+
2632

2733
def get_sup_joints(model, start_frame, end_frame):
2834
"""Get list of supporting joints between two frames in kinematic chain.
@@ -50,8 +56,8 @@ def get_sup_joints(model, start_frame, end_frame):
5056
"""
5157
start_frameId = model.getFrameId(start_frame)
5258
end_frameId = model.getFrameId(end_frame)
53-
start_par = model.frames[start_frameId].parent
54-
end_par = model.frames[end_frameId].parent
59+
start_par = model.frames[start_frameId].parentJoint
60+
end_par = model.frames[end_frameId].parentJoint
5561
branch_s = model.supports[start_par].tolist()
5662
branch_e = model.supports[end_par].tolist()
5763
# remove 'universe' joint from branches
@@ -165,7 +171,7 @@ def get_param_from_yaml(robot, calib_data) -> dict:
165171
except KeyError:
166172
base_to_ref_frame = None
167173
ref_frame = None
168-
print("base_to_ref_frame and ref_frame are not defined.")
174+
logger.warning("base_to_ref_frame and ref_frame are not defined.")
169175

170176
# Validate base-to-ref frame if provided
171177
if base_to_ref_frame is not None:
@@ -189,7 +195,7 @@ def get_param_from_yaml(robot, calib_data) -> dict:
189195
except KeyError:
190196
base_pose = None
191197
tip_pose = None
192-
print("base_pose and tip_pose are not defined.")
198+
logger.warning("base_pose and tip_pose are not defined.")
193199

194200
calib_config["base_pose"] = base_pose
195201
calib_config["tip_pose"] = tip_pose
@@ -203,7 +209,7 @@ def get_param_from_yaml(robot, calib_data) -> dict:
203209
calib_config["IDX_TOOL"] = IDX_TOOL
204210

205211
# tool_joint: ID of the joint right before the tool's frame (parent)
206-
tool_joint = robot.model.frames[IDX_TOOL].parent
212+
tool_joint = robot.model.frames[IDX_TOOL].parentJoint
207213
calib_config["tool_joint"] = tool_joint
208214

209215
# indices of active joints: from base to tool_joint
@@ -462,7 +468,7 @@ def _extract_poses(calib_config, measurements):
462468
calib_config["tip_pose"] = tip_pose
463469

464470
if not base_pose and not tip_pose:
465-
print("Warning: base_pose and tip_pose are not defined.")
471+
logger.warning("base_pose and tip_pose are not defined.")
466472

467473

468474
def _extract_calibration_params(calib_config, robot, parameters):

src/figaroh/calibration/data_loader.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@
2424
- Configuration vector management
2525
"""
2626

27+
import logging
2728
import numpy as np
2829
import pandas as pd
2930

31+
# Setup logger for this module
32+
logger = logging.getLogger(__name__)
33+
logger.addHandler(logging.NullHandler())
34+
3035

3136
# Export public API
3237
__all__ = [
@@ -131,7 +136,7 @@ def load_data(path_to_file, model, calib_config, del_list=[]):
131136
csv_headers = list(df.columns)
132137
for header in PEE_headers + joint_headers:
133138
if header not in csv_headers:
134-
print("%s does not exist in the file." % header)
139+
logger.warning("%s does not exist in the file.", header)
135140
break
136141

137142
# Extract marker position/location

0 commit comments

Comments
 (0)