Skip to content

Commit

Permalink
add GNSS type; improve error handling; fix velodyne sensor names
Browse files Browse the repository at this point in the history
Signed-off-by: YuxuanLiuTier4Desktop <619684051@qq.com>
  • Loading branch information
Owen-Liuyuxuan committed Dec 23, 2024
1 parent fa928b0 commit 877c9f5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
35 changes: 26 additions & 9 deletions aip_urdf_compiler/scripts/compile_xacro.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,21 @@ def load_yaml(file_path: str) -> Dict:
Returns:
Dict: Parsed YAML content or None if parsing fails
"""
with open(file_path, "r") as stream:
try:
return yaml.safe_load(stream)
except yaml.YAMLError as exc:
print(exc)
return None
try:
with open(file_path, "r") as stream:
content = yaml.safe_load(stream)
if content is None:
raise ValueError(f"YAML file is empty or invalid: {file_path}")
if not isinstance(content, dict):
raise ValueError(f"YAML file must contain a dictionary: {file_path}")
return content

except FileNotFoundError:
raise FileNotFoundError(f"YAML file not found: {file_path}")
except yaml.YAMLError as exc:
raise yaml.YAMLError(f"Failed to parse YAML file {file_path}: {str(exc)}")
except Exception as e: # Add general exception handling
raise RuntimeError(f"Unexpected error reading YAML file {file_path}: {str(e)}")


class Transformation:
Expand Down Expand Up @@ -177,9 +186,10 @@ class LinkType(enum.Enum):
PANDAR_XT32 = "pandar_xt32"
PANDAR_QT = "pandar_qt"
PANDAR_QT128 = "pandar_qt128"
VELODYNE16 = "VLP-16.urdf"
VLS128 = "VLS-128.urdf"
VELODYNE16 = "velodyne_16"
VLS128 = "velodyne_128"
RADAR = "radar"
GNSS = "gnss"
JOINT_UNITS = "units"


Expand All @@ -202,9 +212,12 @@ def determine_link_type(link_name: str) -> LinkType:
if "cam" in link_name:
return LinkType.CAMERA

if "imu" in link_name or "gnss" in link_name:
if "imu" in link_name:
return LinkType.IMU

if "gnss" in link_name:
return LinkType.GNSS

if "livox" in link_name:
return LinkType.LIVOX

Expand Down Expand Up @@ -330,6 +343,10 @@ def VLS128_func(transform: Transformation) -> str:
"including_file": "$(find imu_description)/urdf/imu.xacro",
"string_api": functools.partial(base_string_func, "imu_macro"),
},
LinkType.GNSS: { # for now, GNSS will also use the imu xacro files.
"including_file": "$(find imu_description)/urdf/imu.xacro",
"string_api": functools.partial(base_string_func, "imu_macro"),
},
LinkType.VELODYNE16: {
"including_file": "$(find velodyne_description)/urdf/VLP-16.urdf.xacro",
"string_api": VLP16_func,
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions aip_xx1_description/config/sensor_kit_calibration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,31 +70,31 @@ sensor_kit_base_link:
roll: 0.0
pitch: 0.0
yaw: 1.575
type: VLS-128.urdf
type: velodyne_128
velodyne_left_base_link:
x: 0.0
y: 0.56362
z: -0.30555
roll: -0.02
pitch: 0.71
yaw: 1.575
type: VLP-16.urdf
type: velodyne_16
velodyne_right_base_link:
x: 0.0
y: -0.56362
z: -0.30555
roll: -0.01
pitch: 0.71
yaw: -1.580
type: VLP-16.urdf
type: velodyne_16
gnss_link:
x: -0.1
y: 0.0
z: -0.2
roll: 0.0
pitch: 0.0
yaw: 0.0
type: imu
type: gnss
frame_id: gnss
tamagawa/imu_link:
x: 0.0
Expand Down
2 changes: 1 addition & 1 deletion aip_xx1_description/config/sensors_calibration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ base_link:
roll: -0.02
pitch: 0.7281317
yaw: 3.141592
type: VLP-16.urdf
type: velodyne_16
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ sensor_kit_base_link:
roll: 0.0 # Design Value
pitch: 0.0 # Design Value
yaw: 0.0 # Design Value
type: imu
type: gnss
frame_id: gnss
tamagawa/imu_link:
x: -0.129 # Design Value
Expand Down

0 comments on commit 877c9f5

Please sign in to comment.