Skip to content

Commit a759ff5

Browse files
authored
augmenting calibration positions to include moving along width of the board (#191)
1 parent c5d505c commit a759ff5

2 files changed

Lines changed: 27 additions & 7 deletions

File tree

spot_wrapper/calibration/calibrate_spot_hand_camera_cli.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ def spot_main() -> None:
7373
images, poses = get_multiple_perspective_camera_calibration_dataset(
7474
auto_cam_cal_robot=in_hand_bot,
7575
max_num_images=args.max_num_images,
76-
distances=np.arange(*args.dist_from_board_viewpoint_range),
76+
distances_z=np.arange(*args.dist_from_board_viewpoint_range),
77+
distances_x=np.arange(*args.dist_along_board_width),
7778
x_axis_rots=np.arange(*args.x_axis_rot_viewpoint_range),
7879
y_axis_rots=np.arange(*args.y_axis_rot_viewpoint_range),
7980
z_axis_rots=np.arange(*args.z_axis_rot_viewpoint_range),
@@ -131,6 +132,19 @@ def calibrate_robot_cli(parser: argparse.ArgumentParser = None) -> argparse.Argu
131132
"These are used to sample viewpoints for automatic collection. "
132133
),
133134
)
135+
parser.add_argument(
136+
"--dist_along_board_width",
137+
"-dabw",
138+
nargs="+",
139+
type=float,
140+
dest="dist_along_board_width",
141+
default=[-0.3, 0.4, 0.2],
142+
help=(
143+
"What distances to conduct calibrations at relative to the board. (along the board width) "
144+
"Three value array arg defines the [Start, Stop), step. for the viewpoint sweep. "
145+
"These are used to sample viewpoints for automatic collection. "
146+
),
147+
)
134148
group = parser.add_mutually_exclusive_group()
135149
group.add_argument(
136150
"--degrees",

spot_wrapper/calibration/calibration_util.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ def create_charuco_board(
104104
def get_multiple_perspective_camera_calibration_dataset(
105105
auto_cam_cal_robot: AutomaticCameraCalibrationRobot,
106106
max_num_images: int = 10000,
107-
distances: Optional[np.ndarray] = None,
107+
distances_x: Optional[np.ndarray] = None,
108+
distances_z: Optional[np.ndarray] = None,
108109
x_axis_rots: Optional[np.ndarray] = None,
109110
y_axis_rots: Optional[np.ndarray] = None,
110111
z_axis_rots: Optional[np.ndarray] = None,
@@ -161,7 +162,8 @@ def get_multiple_perspective_camera_calibration_dataset(
161162
viewpoints = get_relative_viewpoints_from_board_pose_and_param(
162163
R_vision_to_target,
163164
tvec_vision_to_target,
164-
distances=distances,
165+
distances_x=distances_x,
166+
distances_z=distances_z,
165167
x_axis_rots=x_axis_rots,
166168
y_axis_rots=y_axis_rots,
167169
z_axis_rots=z_axis_rots,
@@ -883,7 +885,8 @@ def convert_camera_t_viewpoint_to_origin_t_planning_frame(
883885
def get_relative_viewpoints_from_board_pose_and_param(
884886
R_board: np.ndarray,
885887
tvec: np.ndarray,
886-
distances: Optional[np.ndarray] = None,
888+
distances_x: Optional[np.ndarray] = None,
889+
distances_z: Optional[np.ndarray] = None,
887890
x_axis_rots: Optional[np.ndarray] = None,
888891
y_axis_rots: Optional[np.ndarray] = None,
889892
z_axis_rots: Optional[np.ndarray] = None,
@@ -936,8 +939,10 @@ def get_relative_viewpoints_from_board_pose_and_param(
936939
List[np.ndarray]: a list of 4x4 homogenous transforms to visit in the "principal" cameras
937940
frame
938941
"""
939-
if distances is None:
940-
distances = np.arange(0.5, 0.7, 0.1)
942+
if distances_x is None:
943+
distances_x = np.arange(0.3, 0.7, 0.1)
944+
if distances_z is None:
945+
distances_z = np.arange(-0.2, 0.3, 0.1)
941946
if x_axis_rots is None:
942947
x_axis_rots = np.arange(-20, 21, 5)
943948
if y_axis_rots is None:
@@ -951,7 +956,8 @@ def get_relative_viewpoints_from_board_pose_and_param(
951956
x_axis_rots = [radians(deg) for deg in x_axis_rots]
952957
y_axis_rots = [radians(deg) for deg in y_axis_rots]
953958
z_axis_rots = [radians(deg) for deg in z_axis_rots]
954-
translations = [tvec + R_board[:, 2] * dist for dist in distances]
959+
960+
translations = [(tvec + R_board[:, 2] * dist + R_board[:, 0] * d2) for dist in distances_z for d2 in distances_x]
955961
R_base = R_board @ R_align_board_frame_with_camera
956962

957963
def euler_to_rotation_matrix(roll: float, pitch: float, yaw: float) -> np.ndarray:

0 commit comments

Comments
 (0)