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

robot_description_loaderを実装 #42

Merged
merged 21 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ec1ef9b
description_loaderを実装
YusukeKato Sep 14, 2023
c63f414
テストを作成
YusukeKato Sep 14, 2023
6b67e29
テストの設定を修正
YusukeKato Sep 14, 2023
046ffee
空行を修正
YusukeKato Sep 14, 2023
c7698fc
コミットを戻す
YusukeKato Sep 14, 2023
acb2aaa
コミットを戻す
YusukeKato Sep 14, 2023
858426d
industrial_ci.ymlを追加
YusukeKato Sep 20, 2023
50c665b
テスト実行時にraspimouse_descriptionが見つからない問題を解決
YusukeKato Sep 20, 2023
cc8bbd7
テスト実行時にlaunchが見つからない問題に対応
YusukeKato Sep 20, 2023
044ef7e
CONTRIBUTING.mdを追加
YusukeKato Sep 20, 2023
af9185b
description_loaderを使用するようにdisplay.launch.pyを変更
YusukeKato Sep 20, 2023
c975b71
CIのテストを通すためにauthorをmaintainerに変更
YusukeKato Sep 20, 2023
5e2c552
CIのテストを通すためにCONTRIBUTING.mdにLICENSE表記を追加
YusukeKato Sep 20, 2023
34a3f44
package.xmlのmaintainerのメールアドレスを更新
YusukeKato Sep 20, 2023
dac8443
maintainer, license, authorの順番になるように修正
YusukeKato Sep 20, 2023
302008f
description_loaderの引数を設定
YusukeKato Sep 20, 2023
08b8c51
maintainerのメールアドレスを元に戻す
YusukeKato Sep 20, 2023
e493267
xacroファイルに追加した引数を元に戻す
YusukeKato Sep 21, 2023
6a92b93
不要な差分を元に戻す
YusukeKato Sep 21, 2023
4610b16
引数を元に戻してlidarとlidar_frameに対応する
YusukeKato Sep 21, 2023
300a222
lidarとlidar_frameのテストを追加
YusukeKato Sep 21, 2023
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
25 changes: 25 additions & 0 deletions .github/workflows/industrial_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: industrial_ci

on:
push:
paths-ignore:
- 'docs/**'
- '**.md'
pull_request:
paths-ignore:
- 'docs/**'
- '**.md'
schedule:
- cron: "0 2 * * 0" # Weekly on Sundays at 02:00

jobs:
industrial_ci:
strategy:
matrix:
env:
- { ROS_DISTRO: humble, ROS_REPO: ros }
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: "ros-industrial/industrial_ci@master"
env: ${{ matrix.env }}
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,17 @@ install(DIRECTORY
DESTINATION share/${PROJECT_NAME}/
)

ament_python_install_package(${PROJECT_NAME})
install(PROGRAMS
${PROJECT_NAME}/robot_description_loader.py
DESTINATION lib/${PROJECT_NAME})

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()

find_package(ament_cmake_pytest REQUIRED)
ament_add_pytest_test(test_robot_description_loader test/test_robot_description_loader.py)
endif()

ament_package()
32 changes: 32 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Contribution Guide

本リポジトリへのコントリビュート方法について記載しています。

## Issues

リポジトリの品質向上にご協力頂きありがとうございます。

Issueの作成を簡単にするテンプレートを用意しているので活用してください。

## Pull Requests

Pull Requestの作成ありがとうございます。
提出したPull Request(PR)には次のルールが適用されます。

- PRの内容には本リポジトリのライセンス([LICENSE](./LICENSE)と[README.md](./README.md)に記載されています)が適用されます
- PRは`rt-net`のメンバーによるレビューを経てからマージされます
- すべてのPRがマージされるわけではなく、希望に添えない場合もありますのでご容赦ください
- リポジトリにテストが設定されている場合はできるだけテストを通してください
- 何かしらの理由(テストに間違いがある場合など)でテストを通さずPRを出す場合はその旨をPRに記載してください
- マージする際にはPR内の全コミットが1つのコミットに`squash`されます
- [コミットをスカッシュしてマージする | GitHub Docs](https://docs.github.com/ja/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/about-pull-request-merges#squash-and-merge-your-commits)
- 1つのPRでリクエストする変更はできるだけシンプルにしてください
- 異なる内容の変更を含む場合はPRを分割してください
- 例えば、複数の機能追加したり、機能追加とリファクタリングを同時にする場合はそれぞれ別々のPRとしてください
- squashマージしても履歴を辿りやすくするためです

## LICENSE

Any contribution that you make to this repository will
be under the MIT license, as dictated by that
[license](https://opensource.org/licenses/MIT).
75 changes: 50 additions & 25 deletions launch/display.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,52 +12,73 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os

from ament_index_python.packages import get_package_share_directory
from raspimouse_description.robot_description_loader import RobotDescriptionLoader
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.conditions import IfCondition
from launch_ros.actions import Node
from launch_ros.actions import PushRosNamespace
from launch.substitutions import Command
from launch.substitutions import LaunchConfiguration


def generate_launch_description():
declare_arg_lidar = DeclareLaunchArgument(
'lidar',
default_value='none',
description='Set "none", "urg", "lds", or "rplidar".')
declare_arg_lidar_frame = DeclareLaunchArgument(
'lidar_frame',
default_value='laser',
description='Set lidar link name.')
declare_use_rgb_camera = DeclareLaunchArgument(
'use_rgb_camera',
default_value='false',
description='Set true to attach the rgb camera model.'
)
declare_use_line_sensor = DeclareLaunchArgument(
'use_line_sensor',
default_value='false',
description='Set true to attach the line sensor model.'
)
declare_use_lidar_urg = DeclareLaunchArgument(
'use_lidar_urg',
default_value='false',
description='Set true to attach the URG-04LX-UG01 model.'
)
declare_use_lidar_lds = DeclareLaunchArgument(
'use_lidar_lds',
default_value='false',
description='Set true to attach the LDS-01 model.'
)
declare_use_lidar_rplidar = DeclareLaunchArgument(
'use_lidar_rplidar',
default_value='false',
description='Set true to attach the RPLiDAR A1 model.'
)
declare_use_imu = DeclareLaunchArgument(
'use_imu',
default_value='false',
description='Set true to attach the IMU model.'
)
declare_arg_namespace = DeclareLaunchArgument(
'namespace',
default_value='',
description='Set namespace for tf tree.')
description='Set namespace for tf tree.'
)
declare_arg_use_rviz = DeclareLaunchArgument(
'use_rviz',
default_value='true',
description='Set "true" to launch rviz.')
description='Set "true" to launch rviz.'
)

xacro_file = os.path.join(
get_package_share_directory('raspimouse_description'),
'urdf',
'raspimouse.urdf.xacro')
params = {'robot_description': Command(['xacro ', xacro_file,
' lidar:=', LaunchConfiguration('lidar'),
' lidar_frame:=', LaunchConfiguration('lidar_frame'),
]),
'frame_prefix': [LaunchConfiguration('namespace'), '/']}
description_loader = RobotDescriptionLoader()
description_loader.use_rgb_camera = LaunchConfiguration('use_rgb_camera')
description_loader.use_line_sensor = LaunchConfiguration('use_line_sensor')
description_loader.use_lidar_urg = LaunchConfiguration('use_lidar_urg')
description_loader.use_lidar_lds = LaunchConfiguration('use_lidar_lds')
description_loader.use_lidar_rplidar = LaunchConfiguration('use_lidar_rplidar')
description_loader.use_imu = LaunchConfiguration('use_imu')

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

rsp = Node(package='robot_state_publisher',
executable='robot_state_publisher',
output='both',
parameters=[params])
parameters=[{'robot_description': description_loader.load()}])

jsp = Node(
package='joint_state_publisher_gui',
Expand All @@ -75,12 +96,16 @@ def generate_launch_description():
condition=IfCondition(LaunchConfiguration('use_rviz')))

return LaunchDescription([
declare_arg_lidar,
declare_arg_lidar_frame,
declare_use_rgb_camera,
declare_use_line_sensor,
declare_use_lidar_urg,
declare_use_lidar_lds,
declare_use_lidar_rplidar,
declare_use_imu,
declare_arg_namespace,
declare_arg_use_rviz,
push_ns,
rsp,
jsp,
rviz_node,
])
])
7 changes: 5 additions & 2 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
<version>1.0.1</version>
<description>The raspimouse_description package</description>
<maintainer email="shop@rt-net.jp">RT Corporation</maintainer>
YusukeKato marked this conversation as resolved.
Show resolved Hide resolved
<author email="daisuke.sato@rt-net.jp">Daisuke Sato</author>
<author email="s.aoki@rt-net.jp">Daisuke Sato</author>

<license>MIT</license>

<author email="daisuke.sato@rt-net.jp">Daisuke Sato</author>
<author email="s.aoki@rt-net.jp">Shota Aoki</author>
<author email="yusuke.kato@rt-net.jp">Yusuke Kato</author>

<buildtool_depend>ament_cmake</buildtool_depend>

Expand All @@ -18,6 +20,7 @@
<depend>rviz2</depend>
<depend>urdf</depend>
<depend>xacro</depend>
<depend>launch</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
Expand Down
Empty file.
58 changes: 58 additions & 0 deletions raspimouse_description/robot_description_loader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# The MIT License (MIT)
#
# Copyright 2023 RT Corporation <support@rt-net.jp>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import os

from ament_index_python.packages import get_package_share_directory
from launch.substitutions import Command


class RobotDescriptionLoader():

def __init__(self):
self.robot_description_path = os.path.join(
get_package_share_directory('raspimouse_description'),
'urdf',
'raspimouse.urdf.xacro')
self.use_gazebo = 'false'
Copy link

Choose a reason for hiding this comment

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

display.launch.pyでも使用されている引数、lidarlidar_frameに対応してください。

self.use_rgb_camera = 'false'
self.use_line_sensor = 'false'
self.use_lidar_urg = 'false'
self.use_lidar_lds = 'false'
self.use_lidar_rplidar = 'false'
self.use_imu = 'false'
self.gz_control_config_package = ''
self.gz_control_config_file_path = ''
Copy link

Choose a reason for hiding this comment

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

これらの引数は今回の変更で使用されていないので削除お願いします。


def load(self):
return Command([
'xacro ',
self.robot_description_path,
' use_gazebo:=', self.use_gazebo,
' use_rgb_camera:=', self.use_rgb_camera,
' use_line_sensor:=', self.use_line_sensor,
' use_lidar_urg:=', self.use_lidar_urg,
' use_lidar_lds:=', self.use_lidar_lds,
' use_lidar_rplidar:=', self.use_lidar_rplidar,
' use_lidar_imu:=', self.use_imu,
' gz_control_config_package:=', self.gz_control_config_package,
' gz_control_config_file_path:=', self.gz_control_config_file_path
])
46 changes: 46 additions & 0 deletions test/test_robot_description_loader.py
Copy link

Choose a reason for hiding this comment

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

引数、lidarとlidar_frameのテストを追加してください。

引数lidarについては、"none", "urg", "lds", or "rplidar" が正しく反映されることを検証してください

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# The MIT License (MIT)
#
# Copyright 2023 RT Corporation <support@rt-net.jp>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

from raspimouse_description.robot_description_loader import RobotDescriptionLoader
from launch.launch_context import LaunchContext
import pytest


def exec_load(loader):
# Command substitutionの実行方法はCommandのテストを参考にした
# https://github.com/ros2/launch/blob/074cd2903ddccd61bce8f40a0f58da0b7c200481/launch/test/launch/substitutions/test_command.py#L47
context = LaunchContext()
return loader.load().perform(context)


def test_load_description():
# xacroの読み込みが成功することを期待
rdl = RobotDescriptionLoader()
assert exec_load(rdl)


def test_change_description_path():
# xacroのファイルパスを変更し、読み込みが失敗することを期待
rdl = RobotDescriptionLoader()
rdl.robot_description_path = 'hoge'
with pytest.raises(Exception) as e:
exec_load(rdl)
assert e.value
11 changes: 10 additions & 1 deletion urdf/raspimouse.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
<xacro:arg name="robot_namespace" default="/" />
<xacro:arg name="diffdrive_namespace" default="/" />
<xacro:arg name="sensor_namespace" default="raspimouse_on_gazebo" />
<xacro:arg name="use_gazebo" default="false" />
<xacro:arg name="use_rgb_camera" default="false" />
<xacro:arg name="use_line_sensor" default="false" />
<xacro:arg name="use_lidar_urg" default="false" />
<xacro:arg name="use_lidar_lds" default="false" />
<xacro:arg name="use_lidar_rplidar" default="false" />
<xacro:arg name="use_imu" default="false" />
<xacro:arg name="gz_control_config_package" default="" />
<xacro:arg name="gz_control_config_file_path" default="" />
Copy link

Choose a reason for hiding this comment

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

今回の変更でこれらの引数は使用されていません。
機能追加時に引数を追加してください。

Suggested change
<xacro:arg name="use_gazebo" default="false" />
<xacro:arg name="use_rgb_camera" default="false" />
<xacro:arg name="use_line_sensor" default="false" />
<xacro:arg name="use_lidar_urg" default="false" />
<xacro:arg name="use_lidar_lds" default="false" />
<xacro:arg name="use_lidar_rplidar" default="false" />
<xacro:arg name="use_imu" default="false" />
<xacro:arg name="gz_control_config_package" default="" />
<xacro:arg name="gz_control_config_file_path" default="" />


<material name="black">
<color rgba="0.2 0.2 0.2 1.0"/>
Expand Down Expand Up @@ -139,4 +148,4 @@
</xacro:if>

<raspimouse_on_gazebo/>
</robot>
</robot>