Skip to content

Commit 28895a4

Browse files
YusukeKatoShota Aoki
andauthored
camera_downwardがtrueのときRGBカメラが斜め下を向くように変更 (#50)
Co-authored-by: Shota Aoki <s.aoki@rt-net.jp>
1 parent 8eb245c commit 28895a4

File tree

6 files changed

+57
-5
lines changed

6 files changed

+57
-5
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ Similarly, display a RGB Camera mounted robot model with the following command:
5151
```sh
5252
ros2 launch raspimouse_description display.launch.py use_rgb_camera:=true
5353
```
54+
![](https://rt-net.github.io/images/raspberry-pi-mouse/mouse_with_rgb_camera.png)
55+
56+
RGB Camera can be pointed down with the following command:
57+
58+
```sh
59+
ros2 launch raspimouse_description display.launch.py use_rgb_camera:=true camera_downward:=true
60+
```
61+
62+
![](https://rt-net.github.io/images/raspberry-pi-mouse/mouse_with_rgb_camera_downward.png)
5463

5564
## LICENSE
5665

launch/display.launch.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,16 @@ def generate_launch_description():
4444
'use_rgb_camera',
4545
default_value='false',
4646
description='Set "true" to mount rgb camera.')
47+
declare_arg_camera_downward = DeclareLaunchArgument(
48+
'camera_downward',
49+
default_value='false',
50+
description='Set "true" to point the camera downwards.')
4751

4852
description_loader = RobotDescriptionLoader()
4953
description_loader.lidar = LaunchConfiguration('lidar')
5054
description_loader.lidar_frame = LaunchConfiguration('lidar_frame')
5155
description_loader.use_rgb_camera = LaunchConfiguration('use_rgb_camera')
56+
description_loader.camera_downward = LaunchConfiguration('camera_downward')
5257

5358
push_ns = PushRosNamespace([LaunchConfiguration('namespace')])
5459

@@ -78,6 +83,7 @@ def generate_launch_description():
7883
declare_arg_namespace,
7984
declare_arg_use_rviz,
8085
declare_arg_use_rgb_camera,
86+
declare_arg_camera_downward,
8187
push_ns,
8288
rsp,
8389
jsp,

raspimouse_description/robot_description_loader.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def __init__(self):
3636
self.lidar_frame = 'laser'
3737
self.use_gazebo = 'false'
3838
self.use_rgb_camera = 'false'
39+
self.camera_downward = 'false'
3940
self.gz_control_config_package = ''
4041
self.gz_control_config_file_path = ''
4142

@@ -47,6 +48,7 @@ def load(self):
4748
' lidar_frame:=', self.lidar_frame,
4849
' use_gazebo:=', self.use_gazebo,
4950
' use_rgb_camera:=', self.use_rgb_camera,
51+
' camera_downward:=', self.camera_downward,
5052
' gz_control_config_package:=', self.gz_control_config_package,
5153
' gz_control_config_file_path:=', self.gz_control_config_file_path
5254
])

test/test_robot_description_loader.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from raspimouse_description.robot_description_loader import RobotDescriptionLoader
2323
from launch.launch_context import LaunchContext
2424
import pytest
25+
import math
2526

2627

2728
def exec_load(loader):
@@ -108,3 +109,15 @@ def test_camera_link():
108109
rdl.gz_control_config_package = 'raspimouse_description'
109110
rdl.gz_control_config_file_path = 'test/dummy_controllers.yaml'
110111
assert 'camera_link' in exec_load(rdl)
112+
113+
114+
def test_camera_downward():
115+
# camera_downwardが変更され、カメラが斜め30度下を向くことを期待
116+
rdl = RobotDescriptionLoader()
117+
rdl.use_gazebo = 'true'
118+
rdl.use_rgb_camera = 'true'
119+
rdl.camera_downward = 'true'
120+
rdl.gz_control_config_package = 'raspimouse_description'
121+
rdl.gz_control_config_file_path = 'test/dummy_controllers.yaml'
122+
camera_angle = math.radians(30)
123+
assert '<pose>0 0 0 0 ' + str(camera_angle) + ' 0</pose>' in exec_load(rdl)

urdf/raspimouse.urdf.xacro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<xacro:arg name="sensor_namespace" default="raspimouse_on_gazebo" />
1515
<xacro:arg name="use_gazebo" default="false" />
1616
<xacro:arg name="use_rgb_camera" default="false" />
17+
<xacro:arg name="camera_downward" default="false" />
1718
<xacro:arg name="gz_control_config_package" default="" />
1819
<xacro:arg name="gz_control_config_file_path" default="" />
1920

@@ -102,7 +103,8 @@
102103
<!-- =============== Gazebo =============== -->
103104
<xacro:rgb_camera_settings
104105
use_gazebo="$(arg use_gazebo)"
105-
use_rgb_camera="$(arg use_rgb_camera)" />
106+
use_rgb_camera="$(arg use_rgb_camera)"
107+
camera_downward="$(arg camera_downward)" />
106108

107109
<xacro:if value="$(arg use_gazebo)">
108110
<xacro:gazebo_diffdrive_settings

urdf/sensors/rgb_camera.xacro

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,35 @@
33

44
<xacro:include filename="$(find raspimouse_description)/urdf/common.xacro" />
55

6+
<xacro:property name="DOWNWARD_CAMERA_ANGLE" value="${radians(30)}"/>
7+
68
<xacro:macro name="rgb_camera_settings"
79
params="use_gazebo
810
use_rgb_camera
11+
camera_downward
912
">
1013

1114
<xacro:if value="$(arg use_rgb_camera)">
1215
<xacro:include filename="$(find realsense2_description)/urdf/_d435.urdf.xacro" />
13-
<xacro:sensor_d435
16+
<xacro:if value="$(arg camera_downward)">
17+
<xacro:sensor_d435
18+
parent="base_link"
19+
use_nominal_extrinsics="false"
20+
add_plug="false"
21+
use_mesh="true">
22+
<origin xyz="0.08 0.0 0.055" rpy="0 ${DOWNWARD_CAMERA_ANGLE} 0"/>
23+
</xacro:sensor_d435>
24+
</xacro:if>
25+
26+
<xacro:unless value="$(arg camera_downward)">
27+
<xacro:sensor_d435
1428
parent="base_link"
1529
use_nominal_extrinsics="false"
1630
add_plug="false"
1731
use_mesh="true">
18-
<origin xyz="0.08 0.0 0.055" rpy="0 0 0"/>
19-
</xacro:sensor_d435>
32+
<origin xyz="0.08 0.0 0.055" rpy="0 0 0"/>
33+
</xacro:sensor_d435>
34+
</xacro:unless>
2035
</xacro:if>
2136

2237
<xacro:if value="${use_gazebo}">
@@ -31,7 +46,12 @@
3146
<update_rate>30.0</update_rate>
3247
<always_on>true</always_on>
3348
<ignition_frame_id>camera_link</ignition_frame_id>
34-
<pose>0 0 0 0 0 0</pose>
49+
<xacro:if value="${camera_downward}">
50+
<pose>0 0 0 0 ${DOWNWARD_CAMERA_ANGLE} 0</pose>
51+
</xacro:if>
52+
<xacro:unless value="${camera_downward}">
53+
<pose>0 0 0 0 0 0</pose>
54+
</xacro:unless>
3555
<topic>/camera/color/image_raw</topic>
3656
<camera name="rgb_camera">
3757
<horizontal_fov>1.20428</horizontal_fov>

0 commit comments

Comments
 (0)