Skip to content

Commit 20a8d5c

Browse files
committed
add camera launch
1 parent 9ece684 commit 20a8d5c

File tree

3 files changed

+108
-0
lines changed

3 files changed

+108
-0
lines changed

src/stingray_core_sensors/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,9 @@ if(BUILD_TESTING)
2222
ament_lint_auto_find_test_dependencies()
2323
endif()
2424

25+
install(
26+
DIRECTORY launch
27+
DESTINATION share/${PROJECT_NAME}
28+
)
29+
2530
ament_package()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
image_width: 640
2+
image_height: 480
3+
camera_name: front_camera
4+
camera_matrix:
5+
rows: 3
6+
cols: 3
7+
data: [447.3296, 0.000000, 326.9216, 0.000000, 600.2483, 259.8586, 0.000000, 0.000000, 1.000000]
8+
distortion_model: radtan
9+
distortion_coefficients:
10+
rows: 1
11+
cols: 5
12+
data: [-0.36871094084873407, 0.13770812146992423, -0.002057012920641659, 0.0022137169808520724, 0.000000]
13+
rectification_matrix:
14+
rows: 3
15+
cols: 3
16+
data: [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
17+
projection_matrix:
18+
rows: 3
19+
cols: 4
20+
data: [447.3296, 0.000000, 326.9216, 0.000000, 0.000000, 600.2483, 259.8586, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000]
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
from pathlib import Path
2+
3+
from ament_index_python import get_package_share_directory
4+
5+
from launch import LaunchDescription
6+
from launch.actions import DeclareLaunchArgument
7+
from launch.substitutions import LaunchConfiguration
8+
from launch_ros.actions import Node
9+
10+
def generate_launch_description():
11+
12+
try:
13+
calibration_config_dir = Path(get_package_share_directory('stingray_core_sensors')) / "configs"
14+
camera_calibration_path = calibration_config_dir / "camera.yaml"
15+
except Exception:
16+
camera_calibration_path = ""
17+
18+
camera_topic_arg_1 = DeclareLaunchArgument(
19+
"camera_topic_1",
20+
default_value='/stingray_core/topics/camera_1'
21+
)
22+
camera_topic_arg_2 = DeclareLaunchArgument(
23+
"camera_topic_2",
24+
default_value='/stingray_core/topics/camera_2'
25+
)
26+
camera_path_arg_1 = DeclareLaunchArgument(
27+
"camera_path_1",
28+
default_value='/dev/video0'
29+
)
30+
camera_path_arg_2 = DeclareLaunchArgument(
31+
"camera_path_2",
32+
default_value='/dev/video2'
33+
)
34+
35+
36+
37+
camera_calibration_path_arg = DeclareLaunchArgument(
38+
"camera_calibration_path", default_value=str(camera_calibration_path)
39+
)
40+
41+
42+
camera_1_node = Node(
43+
package='usb_cam',
44+
executable='usb_cam_node_exe',
45+
name='video_display_node_1',
46+
output='screen',
47+
remappings=[
48+
('/image_raw', LaunchConfiguration("camera_topic_1")),
49+
],
50+
parameters=[
51+
{'video_device': LaunchConfiguration("camera_path_1")},
52+
{'params-file': LaunchConfiguration("camera_calibration_path")},
53+
],
54+
respawn=True,
55+
respawn_delay=1,
56+
)
57+
58+
camera_2_node = Node(
59+
package='usb_cam',
60+
executable='usb_cam_node_exe',
61+
name='video_display_node_2',
62+
output='screen',
63+
remappings=[
64+
('/image_raw', LaunchConfiguration("camera_topic_2")),
65+
],
66+
parameters=[
67+
{'video_device': LaunchConfiguration("camera_path_2")},
68+
{'params-file': LaunchConfiguration("camera_calibration_path")},
69+
],
70+
respawn=True,
71+
respawn_delay=1,
72+
)
73+
74+
75+
return LaunchDescription([
76+
camera_topic_arg_1,
77+
camera_topic_arg_2,
78+
camera_path_arg_1,
79+
camera_path_arg_2,
80+
camera_calibration_path_arg,
81+
camera_1_node,
82+
camera_2_node,
83+
])

0 commit comments

Comments
 (0)