From eedb38c2ffd49de17b5b231333de4591ee951e1f Mon Sep 17 00:00:00 2001 From: Ronan Date: Sat, 28 Sep 2024 23:04:51 +0000 Subject: [PATCH 1/8] simu: Init robot description package --- src/robot_description/CMakeLists.txt | 12 ++++++++++++ src/robot_description/package.xml | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/robot_description/CMakeLists.txt create mode 100644 src/robot_description/package.xml diff --git a/src/robot_description/CMakeLists.txt b/src/robot_description/CMakeLists.txt new file mode 100644 index 0000000..5b5033e --- /dev/null +++ b/src/robot_description/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.5) +project(robot_description) + +find_package(ament_cmake REQUIRED) +find_package(urdf REQUIRED) + +install( + DIRECTORY launch urdf rviz + DESTINATION share/${PROJECT_NAME} +) + +ament_package() \ No newline at end of file diff --git a/src/robot_description/package.xml b/src/robot_description/package.xml new file mode 100644 index 0000000..bf98fc7 --- /dev/null +++ b/src/robot_description/package.xml @@ -0,0 +1,19 @@ + + + + robot_description + 0.0.0 + INSA Toulouse Description Package + Ronan Bonnet + Apache 2.0 + https://github.com/ClubRobotInsat/Info2025 + https://github.com/ClubRobotInsat/Info2025/issues + ament_cmake + joint_state_publisher + robot_state_publisher + rviz2 + xacro + + ament_cmake + + \ No newline at end of file From cdd807082e4beae421f2b70dae7c738404515db5 Mon Sep 17 00:00:00 2001 From: Ronan Date: Sat, 28 Sep 2024 23:05:25 +0000 Subject: [PATCH 2/8] simu: Make rectangle base for 2WD Inertial macros are added to simplify calculations --- .../urdf/inertial_macros.xacro | 40 +++++++++++++++++ .../urdf/parts/base/base.gazebo.xacro | 28 ++++++++++++ .../urdf/parts/base/base.urdf.xacro | 43 +++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 src/robot_description/urdf/inertial_macros.xacro create mode 100644 src/robot_description/urdf/parts/base/base.gazebo.xacro create mode 100644 src/robot_description/urdf/parts/base/base.urdf.xacro diff --git a/src/robot_description/urdf/inertial_macros.xacro b/src/robot_description/urdf/inertial_macros.xacro new file mode 100644 index 0000000..488de03 --- /dev/null +++ b/src/robot_description/urdf/inertial_macros.xacro @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/robot_description/urdf/parts/base/base.gazebo.xacro b/src/robot_description/urdf/parts/base/base.gazebo.xacro new file mode 100644 index 0000000..3875f27 --- /dev/null +++ b/src/robot_description/urdf/parts/base/base.gazebo.xacro @@ -0,0 +1,28 @@ + + + + + + + + 0.8392 0.6314 0.0 1.0 + + + 0.8392 0.6314 0.0 1.0 + + + 0.99 0.99 0.99 1.0 + + + 0.0 0.0 0.0 0.0 + + + + + false + + + + + + \ No newline at end of file diff --git a/src/robot_description/urdf/parts/base/base.urdf.xacro b/src/robot_description/urdf/parts/base/base.urdf.xacro new file mode 100644 index 0000000..0d1d1e8 --- /dev/null +++ b/src/robot_description/urdf/parts/base/base.urdf.xacro @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From c85226325e47a2bd13a1152f4677c3b1b0b162d2 Mon Sep 17 00:00:00 2001 From: Ronan Date: Sat, 28 Sep 2024 23:06:38 +0000 Subject: [PATCH 3/8] simu: Initialize 2WD model --- .../urdf/2wd.properties.xacro | 25 +++++++++++++++++++ .../urdf/robots/2wd.urdf.xacro | 15 +++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/robot_description/urdf/2wd.properties.xacro create mode 100644 src/robot_description/urdf/robots/2wd.urdf.xacro diff --git a/src/robot_description/urdf/2wd.properties.xacro b/src/robot_description/urdf/2wd.properties.xacro new file mode 100644 index 0000000..d84df2e --- /dev/null +++ b/src/robot_description/urdf/2wd.properties.xacro @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/robot_description/urdf/robots/2wd.urdf.xacro b/src/robot_description/urdf/robots/2wd.urdf.xacro new file mode 100644 index 0000000..b75b74b --- /dev/null +++ b/src/robot_description/urdf/robots/2wd.urdf.xacro @@ -0,0 +1,15 @@ + + + + + + + + \ No newline at end of file From 3b6221a66a8e5afbcb53a31e4971230fd976ac70 Mon Sep 17 00:00:00 2001 From: Ronan Date: Sat, 28 Sep 2024 23:07:06 +0000 Subject: [PATCH 4/8] simu: Make launch file The type of robot will be chosen by an environment variable. Do not forget to set it to change robots. --- .../launch/description.launch.py | 79 ++++++++++ src/robot_description/rviz/description.rviz | 142 ++++++++++++++++++ 2 files changed, 221 insertions(+) create mode 100644 src/robot_description/launch/description.launch.py create mode 100644 src/robot_description/rviz/description.rviz diff --git a/src/robot_description/launch/description.launch.py b/src/robot_description/launch/description.launch.py new file mode 100644 index 0000000..5cdde4c --- /dev/null +++ b/src/robot_description/launch/description.launch.py @@ -0,0 +1,79 @@ +import os +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration, Command, PathJoinSubstitution, EnvironmentVariable +from launch.conditions import IfCondition +from launch_ros.actions import Node +from launch_ros.substitutions import FindPackageShare +from launch_ros.parameter_descriptions import ParameterValue + +def generate_launch_description(): + robot_base = os.getenv('ROBOT_BASE', '2wd') + + urdf_path = PathJoinSubstitution( + [FindPackageShare('robot_description'), 'urdf/robots', f"{robot_base}.urdf.xacro"] + ) + + rviz_config_path = PathJoinSubstitution( + [FindPackageShare('robot_description'), 'rviz', 'description.rviz'] + ) + + return LaunchDescription([ + # Arguments + DeclareLaunchArgument( + name='urdf', + default_value=urdf_path, + description='URDF path', + ), + + DeclareLaunchArgument( + name='publish_joints', + default_value='true', + description='Launch joint_state_publisher', + ), + + DeclareLaunchArgument( + name='rviz', + default_value='false', + description='Launch rviz', + ), + + DeclareLaunchArgument( + name="use_sim_time", + default_value="false", + description="Use simulation (Gazebo) clock if true", + ), + + # Nodes + Node( + package='joint_state_publisher', + executable='joint_state_publisher', + name='joint_state_publisher', + condition=IfCondition(LaunchConfiguration('publish_joints')), + parameters=[{ + 'use_sim_time': LaunchConfiguration('use_sim_time') + }], + ), + + Node( + package='robot_state_publisher', + executable='robot_state_publisher', + name='robot_state_publisher', + output='screen', + parameters=[{ + 'use_sim_time': LaunchConfiguration('use_sim_time'), + 'robot_description': ParameterValue(Command(['xacro ', LaunchConfiguration('urdf')])) + }], + ), + + Node( + package='rviz2', + executable='rviz2', + name='rviz2', + condition=IfCondition(LaunchConfiguration('rviz')), + arguments=['-d', rviz_config_path], + parameters=[{ + 'use_sim_time': LaunchConfiguration('use_sim_time') + }], + ) + ]) diff --git a/src/robot_description/rviz/description.rviz b/src/robot_description/rviz/description.rviz new file mode 100644 index 0000000..a1ff5ae --- /dev/null +++ b/src/robot_description/rviz/description.rviz @@ -0,0 +1,142 @@ +Panels: + - Class: rviz_common/Displays + Help Height: 78 + Name: Displays + Property Tree Widget: + Expanded: ~ + Splitter Ratio: 0.5 + Tree Height: 793 +Visualization Manager: + Class: "" + Displays: + - Alpha: 0.5 + Cell Size: 1 + Class: rviz_default_plugins/Grid + Color: 160; 160; 164 + Enabled: true + Line Style: + Line Width: 0.029999999329447746 + Value: Lines + Name: Grid + Normal Cell Count: 0 + Offset: + X: 0 + Y: 0 + Z: 0 + Plane: XY + Plane Cell Count: 10 + Reference Frame: + Value: true + - Alpha: 0.8999999761581421 + Class: rviz_default_plugins/RobotModel + Collision Enabled: false + Description File: "" + Description Source: Topic + Description Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /robot_description + Enabled: true + Links: + All Links Enabled: true + Expand Joint Details: false + Expand Link Details: false + Expand Tree: false + Link Tree Style: Links in Alphabetic Order + base_footprint: + Alpha: 1 + Show Axes: false + Show Trail: false + base_link: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + Mass Properties: + Inertia: false + Mass: false + Name: RobotModel + TF Prefix: "" + Update Interval: 0 + Value: true + Visual Enabled: true + - Class: rviz_default_plugins/TF + Enabled: true + Frame Timeout: 15 + Frames: + All Enabled: true + base_footprint: + Value: true + base_link: + Value: true + Marker Scale: 0.10000000149011612 + Name: TF + Show Arrows: true + Show Axes: true + Show Names: true + Tree: + base_footprint: + base_link: + {} + Update Interval: 0 + Value: true + - Class: rviz_default_plugins/Axes + Enabled: true + Length: 1 + Name: Axes + Radius: 0.0010000000474974513 + Reference Frame: + Value: true + Enabled: true + Global Options: + Background Color: 238; 238; 236 + Fixed Frame: base_footprint + Frame Rate: 30 + Name: root + Tools: + - Class: rviz_default_plugins/Interact + Hide Inactive Objects: true + - Class: rviz_default_plugins/MoveCamera + - Class: rviz_default_plugins/Select + - Class: rviz_default_plugins/FocusCamera + - Class: rviz_default_plugins/Measure + Line color: 128; 128; 0 + Transformation: + Current: + Class: rviz_default_plugins/TF + Value: true + Views: + Current: + Class: rviz_default_plugins/Orbit + Distance: 0.5964717268943787 + Enable Stereo Rendering: + Stereo Eye Separation: 0.05999999865889549 + Stereo Focal Distance: 1 + Swap Stereo Eyes: false + Value: false + Focal Point: + X: 0 + Y: 0 + Z: 0 + Focal Shape Fixed Size: true + Focal Shape Size: 0.05000000074505806 + Invert Z Axis: false + Name: Current View + Near Clip Distance: 0.009999999776482582 + Pitch: 0.5003980398178101 + Target Frame: + Value: Orbit (rviz) + Yaw: 6.013586521148682 + Saved: ~ +Window Geometry: + Displays: + collapsed: false + Height: 1016 + Hide Left Dock: false + Hide Right Dock: false + QMainWindow State: 000000ff00000000fd000000010000000000000156000003a2fc0200000001fb000000100044006900730070006c006100790073010000003b000003a2000000c700ffffff00000624000003a200000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + Width: 1920 + X: 0 + Y: 27 From 54bb32a16095537c39bee0237c020c4b764b1181 Mon Sep 17 00:00:00 2001 From: Ronan Date: Sun, 29 Sep 2024 19:30:37 +0000 Subject: [PATCH 5/8] simu: Add wheels descriptions There are 3 types of wheels: caster, mecanum, normal. The difference between mecanum and normal is mainly the friction coefficient. --- .../parts/wheels/caster_wheel.gazebo.xacro | 9 ++++ .../urdf/parts/wheels/caster_wheel.urdf.xacro | 47 +++++++++++++++++++ .../parts/wheels/mecanum_wheel.gazebo.xacro | 17 +++++++ .../parts/wheels/mecanum_wheel.urdf.xacro | 40 ++++++++++++++++ .../urdf/parts/wheels/wheel.gazebo.xacro | 15 ++++++ .../urdf/parts/wheels/wheel.urdf.xacro | 40 ++++++++++++++++ 6 files changed, 168 insertions(+) create mode 100644 src/robot_description/urdf/parts/wheels/caster_wheel.gazebo.xacro create mode 100644 src/robot_description/urdf/parts/wheels/caster_wheel.urdf.xacro create mode 100644 src/robot_description/urdf/parts/wheels/mecanum_wheel.gazebo.xacro create mode 100644 src/robot_description/urdf/parts/wheels/mecanum_wheel.urdf.xacro create mode 100644 src/robot_description/urdf/parts/wheels/wheel.gazebo.xacro create mode 100644 src/robot_description/urdf/parts/wheels/wheel.urdf.xacro diff --git a/src/robot_description/urdf/parts/wheels/caster_wheel.gazebo.xacro b/src/robot_description/urdf/parts/wheels/caster_wheel.gazebo.xacro new file mode 100644 index 0000000..7b1f644 --- /dev/null +++ b/src/robot_description/urdf/parts/wheels/caster_wheel.gazebo.xacro @@ -0,0 +1,9 @@ + + + + + 0.01 + 0.01 + + + \ No newline at end of file diff --git a/src/robot_description/urdf/parts/wheels/caster_wheel.urdf.xacro b/src/robot_description/urdf/parts/wheels/caster_wheel.urdf.xacro new file mode 100644 index 0000000..bfb4f0a --- /dev/null +++ b/src/robot_description/urdf/parts/wheels/caster_wheel.urdf.xacro @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/robot_description/urdf/parts/wheels/mecanum_wheel.gazebo.xacro b/src/robot_description/urdf/parts/wheels/mecanum_wheel.gazebo.xacro new file mode 100644 index 0000000..a0f9d2a --- /dev/null +++ b/src/robot_description/urdf/parts/wheels/mecanum_wheel.gazebo.xacro @@ -0,0 +1,17 @@ + + + + + + + 0.1764 0.4588 0.8509 1.0 + 0.1764 0.4588 0.8509 1.0 + 0.1764 0.4588 0.8509 1.0 + 0.0 0.0 0.0 0.0 + + + 0.01 + 0.01 + + + \ No newline at end of file diff --git a/src/robot_description/urdf/parts/wheels/mecanum_wheel.urdf.xacro b/src/robot_description/urdf/parts/wheels/mecanum_wheel.urdf.xacro new file mode 100644 index 0000000..e2cf417 --- /dev/null +++ b/src/robot_description/urdf/parts/wheels/mecanum_wheel.urdf.xacro @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/robot_description/urdf/parts/wheels/wheel.gazebo.xacro b/src/robot_description/urdf/parts/wheels/wheel.gazebo.xacro new file mode 100644 index 0000000..7cb34df --- /dev/null +++ b/src/robot_description/urdf/parts/wheels/wheel.gazebo.xacro @@ -0,0 +1,15 @@ + + + + + + + 0.1764 0.4588 0.8509 1.0 + 0.1764 0.4588 0.8509 1.0 + 0.1764 0.4588 0.8509 1.0 + 0.0 0.0 0.0 0.0 + + + + + \ No newline at end of file diff --git a/src/robot_description/urdf/parts/wheels/wheel.urdf.xacro b/src/robot_description/urdf/parts/wheels/wheel.urdf.xacro new file mode 100644 index 0000000..4d01274 --- /dev/null +++ b/src/robot_description/urdf/parts/wheels/wheel.urdf.xacro @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 0cc09f4342d33789812b3ee91f32e1ee6a7d369e Mon Sep 17 00:00:00 2001 From: Ronan Date: Sun, 29 Sep 2024 19:39:10 +0000 Subject: [PATCH 6/8] simu: Add wheels to 2WD robot --- .../urdf/robots/2wd.urdf.xacro | 64 +++++++++++++++---- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/src/robot_description/urdf/robots/2wd.urdf.xacro b/src/robot_description/urdf/robots/2wd.urdf.xacro index b75b74b..c20ad70 100644 --- a/src/robot_description/urdf/robots/2wd.urdf.xacro +++ b/src/robot_description/urdf/robots/2wd.urdf.xacro @@ -1,15 +1,57 @@ - - - - + + + + + + + + + + + + + + + + + + \ No newline at end of file From 4255827948bf2b4bae937bc77203a322901e21dc Mon Sep 17 00:00:00 2001 From: Ronan Date: Sun, 29 Sep 2024 19:53:41 +0000 Subject: [PATCH 7/8] simu: Add sensors IMU, Depth Sensor, Lidar Have not tried yet if these work correctly, these files mostly come from linorobot2. --- .../urdf/sensors/depth_sensor.urdf.xacro | 102 ++++++++++++++++++ .../urdf/sensors/generic_laser.urdf.xacro | 35 ++++++ .../urdf/sensors/imu.gazebo.xacro | 28 +++++ .../urdf/sensors/imu.urdf.xacro | 14 +++ .../urdf/sensors/laser.urdf.xacro | 82 ++++++++++++++ 5 files changed, 261 insertions(+) create mode 100644 src/robot_description/urdf/sensors/depth_sensor.urdf.xacro create mode 100644 src/robot_description/urdf/sensors/generic_laser.urdf.xacro create mode 100644 src/robot_description/urdf/sensors/imu.gazebo.xacro create mode 100644 src/robot_description/urdf/sensors/imu.urdf.xacro create mode 100644 src/robot_description/urdf/sensors/laser.urdf.xacro diff --git a/src/robot_description/urdf/sensors/depth_sensor.urdf.xacro b/src/robot_description/urdf/sensors/depth_sensor.urdf.xacro new file mode 100644 index 0000000..19619fd --- /dev/null +++ b/src/robot_description/urdf/sensors/depth_sensor.urdf.xacro @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.416 0.051 0.047 1.0 + 0.416 0.051 0.047 1.0 + 0.416 0.051 0.047 1.0 + 0.416 0.051 0.047 1.0 + + + + rgb(213,28,40) + + + + + + + + + + + + + + + + + + true + 30.0 + + 1.50098 + + 640 + 480 + R8G8B8 + + + + + /camera/camera_info:=/camera/color/camera_info + /camera/image_raw:=/camera/color/image_raw + /camera/points:=/camera/depth/color/points + /camera/depth/image_raw:=/camera/depth/image_rect_raw + + + + best_effort + + + + + 0.015 + 3.0 + 0.07 + camera_depth_link + 0.00000001 + 0.00000001 + 0.00000001 + 0.00000001 + 0.00000001 + + + + + + \ No newline at end of file diff --git a/src/robot_description/urdf/sensors/generic_laser.urdf.xacro b/src/robot_description/urdf/sensors/generic_laser.urdf.xacro new file mode 100644 index 0000000..f691c9b --- /dev/null +++ b/src/robot_description/urdf/sensors/generic_laser.urdf.xacro @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/robot_description/urdf/sensors/imu.gazebo.xacro b/src/robot_description/urdf/sensors/imu.gazebo.xacro new file mode 100644 index 0000000..db15d5f --- /dev/null +++ b/src/robot_description/urdf/sensors/imu.gazebo.xacro @@ -0,0 +1,28 @@ + + + + + true + + true + 20 + true + __default_topic__ + + + ~/out:=imu/data + + imu/data + imu_link + 10.0 + 0.0 + 0 0 0 + 0 0 0 + imu_link + false + + 0 0 0 0 0 0 + + + + \ No newline at end of file diff --git a/src/robot_description/urdf/sensors/imu.urdf.xacro b/src/robot_description/urdf/sensors/imu.urdf.xacro new file mode 100644 index 0000000..3efb3ed --- /dev/null +++ b/src/robot_description/urdf/sensors/imu.urdf.xacro @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/robot_description/urdf/sensors/laser.urdf.xacro b/src/robot_description/urdf/sensors/laser.urdf.xacro new file mode 100644 index 0000000..ad12f98 --- /dev/null +++ b/src/robot_description/urdf/sensors/laser.urdf.xacro @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.003 0.639 0.223 1.0 + 0.003 0.639 0.223 1.0 + 0.003 0.639 0.223 1.0 + 0.0 0.0 0.0 0.0 + + + + + + + + + + + + + true + ${update_rate} + 0 0 0 0 0 0 + false + + + + ${ray_count} + 1 + ${min_angle} + ${max_angle} + + + + ${min_range} + ${max_range} + 0.01 + + + + + ~/out:=${topic_name} + + sensor_msgs/LaserScan + true + ${update_rate} + ${topic_name} + ${frame_id} + sensor_msgs/LaserScan + + + + + \ No newline at end of file From da03aabc8e6f5819f0cf0dc897f7193109e64233 Mon Sep 17 00:00:00 2001 From: Ronan Date: Sun, 29 Sep 2024 19:55:45 +0000 Subject: [PATCH 8/8] simu: Add sensors to 2WD robot --- src/robot_description/urdf/robots/2wd.urdf.xacro | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/robot_description/urdf/robots/2wd.urdf.xacro b/src/robot_description/urdf/robots/2wd.urdf.xacro index c20ad70..c4786dd 100644 --- a/src/robot_description/urdf/robots/2wd.urdf.xacro +++ b/src/robot_description/urdf/robots/2wd.urdf.xacro @@ -6,6 +6,10 @@ + + + + + + + + + + + + + + \ No newline at end of file