Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gazebo上で画像トピックを配信できるように変更 #46

Merged
merged 6 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test/test_robot_description_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,13 @@ def test_use_rgb_camera():
rdl.gz_control_config_package = 'raspimouse_description'
rdl.gz_control_config_file_path = 'test/dummy_controllers.yaml'
assert 'realsense2_description/meshes/d435.dae' in exec_load(rdl)


def test_camera_link():
# use_gazeboとuse_rgb_cameraが変更され、xacroにcamera linkがセットされることを期待
rdl = RobotDescriptionLoader()
rdl.use_gazebo = 'true'
rdl.use_rgb_camera = 'true'
rdl.gz_control_config_package = 'raspimouse_description'
rdl.gz_control_config_file_path = 'test/dummy_controllers.yaml'
assert 'camera_link' in exec_load(rdl)
16 changes: 4 additions & 12 deletions urdf/raspimouse.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<xacro:include filename="$(find raspimouse_description)/urdf/wheel/diffdrive.gazebo_ros2_control.xacro" />
<xacro:include filename="$(find raspimouse_description)/urdf/sensors/lightsens.urdf.xacro" />
<xacro:include filename="$(find raspimouse_description)/urdf/sensors/lidar.urdf.xacro" />
<xacro:include filename="$(find raspimouse_description)/urdf/sensors/rgb_camera.xacro" />

<!-- =============== Link & Joint =============== -->
<!-- Base -->
Expand Down Expand Up @@ -98,19 +99,10 @@
</xacro:lidar_rp_sensor>
</xacro:if>

<!-- RGB Camera -->
<xacro:if value="$(arg use_rgb_camera)">
<xacro:include filename="$(find realsense2_description)/urdf/_d435.urdf.xacro" />
<xacro:sensor_d435
parent="base_link"
use_nominal_extrinsics="false"
add_plug="false"
use_mesh="true">
<origin xyz="0.08 0.0 0.055" rpy="0 0 0"/>
</xacro:sensor_d435>
</xacro:if>

<!-- =============== Gazebo =============== -->
<xacro:rgb_camera_settings
use_gazebo="$(arg use_gazebo)"
use_rgb_camera="$(arg use_rgb_camera)" />

<xacro:if value="$(arg use_gazebo)">
<xacro:gazebo_diffdrive_settings
Expand Down
53 changes: 53 additions & 0 deletions urdf/sensors/rgb_camera.xacro
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0"?>
<robot name="rgb_camera" xmlns:xacro="http://ros.org/wiki/xacro">

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

<xacro:macro name="rgb_camera_settings"
params="use_gazebo
use_rgb_camera
">

<xacro:if value="$(arg use_rgb_camera)">
<xacro:include filename="$(find realsense2_description)/urdf/_d435.urdf.xacro" />
<xacro:sensor_d435
parent="base_link"
use_nominal_extrinsics="false"
add_plug="false"
use_mesh="true">
<origin xyz="0.08 0.0 0.055" rpy="0 0 0"/>
</xacro:sensor_d435>
</xacro:if>

<xacro:if value="${use_gazebo}">
<gazebo>
<plugin filename="ignition-gazebo-sensors-system" name="ignition::gazebo::systems::Sensors">
<render_engine>ogre2</render_engine>
</plugin>
</gazebo>

<gazebo reference="camera_link">
<sensor name="camera_link" type="camera">
<update_rate>30.0</update_rate>
<always_on>true</always_on>
<ignition_frame_id>camera_link</ignition_frame_id>
<pose>0 0 0 0 0 0</pose>
<topic>/camera/color/image_raw</topic>
<camera name="rgb_camera">
<horizontal_fov>1.20428</horizontal_fov>
<image>
<width>1920</width>
<height>1080</height>
<format>R8G8B8</format>
</image>
<clip>
<near>0.02</near>
<far>300</far>
</clip>
</camera>
</sensor>
</gazebo>
</xacro:if>
</xacro:macro>

</robot>
1 change: 1 addition & 0 deletions urdf/wheel/diffdrive.gazebo.xacro
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

カメラはdiff driveに関係しないので、urdf/sensorsに設定ファイル(rgb_camera.xacro)を作成してください。

#45
で追加したrealsenseの読み込みも移植してください。

rgb_camera.xacro

<realsenseの読み込み />

<xacro:if value="${use_gazebo}">
  <センサプラグインの読み込み />
  <カメラ設定の読み込み />
</xacro:if>

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</plugin>
</xacro:if>
</gazebo>

</xacro:macro>

</robot>