Skip to content

Commit

Permalink
Updated the urdf launch files (luxonis#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
saching13 authored Dec 16, 2021
1 parent fcb76b4 commit beea719
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 44 deletions.
2 changes: 1 addition & 1 deletion depthai_bridge/launch/urdf.launch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<arg name="camera_name" default="oak" />

<arg name="base_frame" default="oak-d_frame" />
<arg name="parent_frame" default="base_link" />
<arg name="parent_frame" default="oak-d-base-frame" />

<arg name="cam_pos_x" default="0.0" /> <!-- Position respect to base frame (i.e. "base_link) -->
<arg name="cam_pos_y" default="0.0" /> <!-- Position respect to base frame (i.e. "base_link) -->
Expand Down
160 changes: 121 additions & 39 deletions depthai_bridge/launch/urdf_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,82 +11,162 @@ def generate_launch_description():
# urdf = open(urdf_path).read()
# doc = xacro.process_file(urdf_path, mappings={'simulate_obstacles' : 'false'})
print(xacro_path)
camera_name = LaunchConfiguration('camera_name')
camera_model = LaunchConfiguration('camera_model')
base_frame = LaunchConfiguration('base_frame')
cam_pos_x = LaunchConfiguration('cam_pos_x')
cam_pos_y = LaunchConfiguration('cam_pos_y')
cam_pos_z = LaunchConfiguration('cam_pos_z')
cam_roll = LaunchConfiguration('cam_roll')
cam_pitch = LaunchConfiguration('cam_pitch')
cam_yaw = LaunchConfiguration('cam_yaw')
camera_model = LaunchConfiguration('camera_model', default = 'OAK-D')
camera_name = LaunchConfiguration('camera_name', default = 'oak')
base_frame = LaunchConfiguration('base_frame', default = 'oak-d_frame')
parent_frame = LaunchConfiguration('parent_frame', default = 'oak-d-base-frame')
cam_pos_x = LaunchConfiguration('cam_pos_x', default = '0.0')
cam_pos_y = LaunchConfiguration('cam_pos_y', default = '0.0')
cam_pos_z = LaunchConfiguration('cam_pos_z', default = '0.0')
cam_roll = LaunchConfiguration('cam_roll', default = '0.0')
cam_pitch = LaunchConfiguration('cam_pitch', default = '0.0')
cam_yaw = LaunchConfiguration('cam_yaw', default = '0.0')

declare_camera_model_cmd = DeclareLaunchArgument(
'camera_model',
default_value=camera_model,
description='The model of the camera. Using a wrong camera model can disable camera features. Valid models: `OAK-D, OAK-D-LITE`.')

declare_camera_name_cmd = DeclareLaunchArgument(
'camera_name',
default_value='oak-d',
default_value=camera_name,
description='The name of the camera. It can be different from the camera model and it will be used as node `namespace`.')

declare_camera_model_cmd = DeclareLaunchArgument(
'camera_model',
default_value='OAK-D',
description='The model of the camera. Using a wrong camera model can disable camera features. Valid models: `BW1098OAK`.')
declare_base_frame_cmd = DeclareLaunchArgument(
'base_frame',
default_value=base_frame,
description='Name of the base link.')

declare_parent_frame_cmd = DeclareLaunchArgument(
'parent_frame',
default_value=parent_frame,
description='Name of the parent link from other a robot TF for example that can be connected to the base of the OAK.')

declare_pos_x_cmd = DeclareLaunchArgument(
'cam_pos_x',
default_value=cam_pos_x,
description='Position X of the camera with respect to the base frame.')

declare_pos_y_cmd = DeclareLaunchArgument(
'cam_pos_y',
default_value=cam_pos_y,
description='Position Y of the camera with respect to the base frame.')

declare_pos_z_cmd = DeclareLaunchArgument(
'cam_pos_z',
default_value=cam_pos_z,
description='Position Z of the camera with respect to the base frame.')

declare_roll_cmd = DeclareLaunchArgument(
'cam_roll',
default_value=cam_roll,
description='Roll orientation of the camera with respect to the base frame.')

declare_pitch_cmd = DeclareLaunchArgument(
'cam_pitch',
default_value=cam_pitch,
description='Pitch orientation of the camera with respect to the base frame.')

declare_yaw_cmd = DeclareLaunchArgument(
'cam_yaw',
default_value=cam_yaw,
description='Yaw orientation of the camera with respect to the base frame.')

rsp_node = Node(
package='robot_state_publisher',
executable='robot_state_publisher',
name='oak_state_publisher',
parameters=[{'robot_description': Command(
[
'xacro', ' ', xacro_path, ' ',
'camera_name:=', camera_name, ' ',
'camera_model:=', camera_model, ' ',
'base_frame:=', base_frame, ' ',
'parent_frame:=', parent_frame, ' ',
'cam_pos_x:=', cam_pos_x, ' ',
'cam_pos_y:=', cam_pos_y, ' ',
'cam_pos_z:=', cam_pos_z, ' ',
'cam_roll:=', cam_roll, ' ',
'cam_pitch:=', cam_pitch, ' ',
'cam_yaw:=', cam_yaw
])}]
)

ld = LaunchDescription()

# declare_config_common_path_cmd = DeclareLaunchArgument(
# 'config_common_path',
# default_value=default_config_common,
# description='Path to the `common.yaml` file.')
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch_ros.actions import Node
from launch.substitutions import LaunchConfiguration, Command
from ament_index_python.packages import get_package_share_directory
import os

# declare_config_camera_path_cmd = DeclareLaunchArgument(
# 'config_camera_path',
# description='Path to the `<camera_model>.yaml` file.')
def generate_launch_description():
bringup_dir = get_package_share_directory('depthai_bridge')
xacro_path = os.path.join(bringup_dir, 'urdf', 'depthai_descr.urdf.xacro')
# urdf = open(urdf_path).read()
# doc = xacro.process_file(urdf_path, mappings={'simulate_obstacles' : 'false'})
print(xacro_path)
camera_model = LaunchConfiguration('camera_model', default = 'OAK-D')
camera_name = LaunchConfiguration('camera_name', default = 'oak')
base_frame = LaunchConfiguration('base_frame', default = 'oak-d_frame')
parent_frame = LaunchConfiguration('parent_frame', default = 'oak-d-base-frame')
cam_pos_x = LaunchConfiguration('cam_pos_x', default = '0.0')
cam_pos_y = LaunchConfiguration('cam_pos_y', default = '0.0')
cam_pos_z = LaunchConfiguration('cam_pos_z', default = '0.0')
cam_roll = LaunchConfiguration('cam_roll', default = '1.5708')
cam_pitch = LaunchConfiguration('cam_pitch', default = '0.0')
cam_yaw = LaunchConfiguration('cam_yaw', default = '1.5708')

# declare_publish_urdf_cmd = DeclareLaunchArgument(
# 'publish_urdf',
# default_value='true',
# description='Enable URDF processing and starts Robot State Published to propagate static TF.')

# declare_xacro_path_cmd = DeclareLaunchArgument(
# 'xacro_path',
# description='Path to the camera URDF file as a xacro file.')
declare_camera_model_cmd = DeclareLaunchArgument(
'camera_model',
default_value=camera_model,
description='The model of the camera. Using a wrong camera model can disable camera features. Valid models: `OAK-D, OAK-D-LITE`.')

# declare_svo_path_cmd = DeclareLaunchArgument(
# 'svo_path',
# default_value='',
# description='Path to an input SVO file. Note: overrides the parameter `general.svo_file` in `common.yaml`.')
declare_camera_name_cmd = DeclareLaunchArgument(
'camera_name',
default_value=camera_name,
description='The name of the camera. It can be different from the camera model and it will be used as node `namespace`.')

declare_base_frame_cmd = DeclareLaunchArgument(
'base_frame',
default_value='oak-d_frame',
default_value=base_frame,
description='Name of the base link.')

declare_parent_frame_cmd = DeclareLaunchArgument(
'parent_frame',
default_value=parent_frame,
description='Name of the parent link from other a robot TF for example that can be connected to the base of the OAK.')

declare_pos_x_cmd = DeclareLaunchArgument(
'cam_pos_x',
default_value='0.0',
default_value=cam_pos_x,
description='Position X of the camera with respect to the base frame.')

declare_pos_y_cmd = DeclareLaunchArgument(
'cam_pos_y',
default_value='0.0',
default_value=cam_pos_y,
description='Position Y of the camera with respect to the base frame.')

declare_pos_z_cmd = DeclareLaunchArgument(
'cam_pos_z',
default_value='0.0',
default_value=cam_pos_z,
description='Position Z of the camera with respect to the base frame.')

declare_roll_cmd = DeclareLaunchArgument(
'cam_roll',
default_value='1.5708',
default_value=cam_roll,
description='Roll orientation of the camera with respect to the base frame.')

declare_pitch_cmd = DeclareLaunchArgument(
'cam_pitch',
default_value='0.0',
default_value=cam_pitch,
description='Pitch orientation of the camera with respect to the base frame.')

declare_yaw_cmd = DeclareLaunchArgument(
'cam_yaw',
default_value='1.5708',
default_value=cam_yaw,
description='Yaw orientation of the camera with respect to the base frame.')

rsp_node = Node(
Expand All @@ -99,6 +179,7 @@ def generate_launch_description():
'camera_name:=', camera_name, ' ',
'camera_model:=', camera_model, ' ',
'base_frame:=', base_frame, ' ',
'parent_frame:=', parent_frame, ' ',
'cam_pos_x:=', cam_pos_x, ' ',
'cam_pos_y:=', cam_pos_y, ' ',
'cam_pos_z:=', cam_pos_z, ' ',
Expand All @@ -112,6 +193,7 @@ def generate_launch_description():
ld.add_action(declare_camera_name_cmd)
ld.add_action(declare_camera_model_cmd)
ld.add_action(declare_base_frame_cmd)
ld.add_action(declare_parent_frame_cmd)
ld.add_action(declare_pos_x_cmd)
ld.add_action(declare_pos_y_cmd)
ld.add_action(declare_pos_z_cmd)
Expand Down
6 changes: 3 additions & 3 deletions depthai_bridge/urdf/depthai_descr.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<robot name="depthai_camera" xmlns:xacro="http://ros.org/wiki/xacro">

<xacro:arg name="camera_name" default="oak" />
<xacro:arg name="camera_model" default="BW1098OAK" />
<xacro:arg name="base_frame" default="base_link" />
<xacro:arg name="parent_frame" default="base_link" />
<xacro:arg name="camera_model" default="OAK-D" />
<xacro:arg name="base_frame" default="oak-d_frame" />
<xacro:arg name="parent_frame" default="oak-d-base-frame" />
<xacro:arg name="cam_pos_x" default="0.0" />
<xacro:arg name="cam_pos_y" default="0.0" />
<xacro:arg name="cam_pos_z" default="0.0" />
Expand Down
2 changes: 1 addition & 1 deletion depthai_bridge/urdf/include/depthai_macro.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<!-- <xacro:if value="${model == 'BW1098OAK'}">
</xacro:if> -->
<xacro:property name="baseline" value="0.095" />
<xacro:property name="baseline" value="0.075" />

<!-- base_link of the sensor-->
<link name="${base_frame}"/>
Expand Down

0 comments on commit beea719

Please sign in to comment.