Skip to content

Commit

Permalink
add caster models
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuohayashibara committed Sep 1, 2024
1 parent 2f5e4bb commit 982262e
Show file tree
Hide file tree
Showing 14 changed files with 2,697 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import os.path as osp
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import (
DeclareLaunchArgument, IncludeLaunchDescription, ExecuteProcess
)
from launch.substitutions import LaunchConfiguration
from launch.launch_description_sources import PythonLaunchDescriptionSource
from ament_index_python.packages import get_package_share_directory


def generate_launch_description():
VEHICLE_NAME = "ai_car_active_caster"
launch_args = (
DeclareLaunchArgument(
"world_name",
default_value="shihou_course",
description="World Name",
),
DeclareLaunchArgument(
"vehicle_name",
default_value="ai_car_active_caster",
description="Vehicle Name",
),
DeclareLaunchArgument(
"world_path",
default_value=[
osp.join(get_package_share_directory("simulator"), "worlds", ""),
LaunchConfiguration("world_name"), "/",
LaunchConfiguration("vehicle_name"), ".model"
],
description="Path to world file.",
),
DeclareLaunchArgument(
"use_sim_time",
default_value="true",
description="If true, use simulation (Gazebo) clock",
),
)

tf_static_publisher = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
osp.join(get_package_share_directory("vehicle"),
"launch/extrinsic_tfstatic_broadcaster_no_namespace.launch.py"),
),
launch_arguments={
"vehicle_name": VEHICLE_NAME,
"use_sim_time": LaunchConfiguration("use_sim_time"),
}.items(),
)
# ExecuteProcess(
# cmd=["export", "GAZEBO_MODEL_PATH=$(ros2 pkg prefix vehicle)/share/vehicle/xacro"],
# shell=True),
gzserver = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
osp.join(get_package_share_directory("gazebo_ros"),
"launch/gzserver.launch.py"),
),
launch_arguments={
"world": LaunchConfiguration("world_path"),
"world_name": LaunchConfiguration("world_name"),
}.items(),
)
gzclient = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
osp.join(get_package_share_directory("gazebo_ros"),
"launch/gzclient.launch.py"),
),
)
set_use_sim_time = ExecuteProcess(
cmd=['ros2', 'param', 'set', '/gazebo',
'use_sim_time', LaunchConfiguration("use_sim_time")],
output='screen'
)

return LaunchDescription([
*launch_args,
tf_static_publisher,
gzserver,
gzclient,
set_use_sim_time,
Node(
package='controller_manager',
executable='spawner.py',
arguments=['position_controller'],
output='screen'
)
])
81 changes: 81 additions & 0 deletions simulator/simulator/launch/gazebo_simulator_caster_trail.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import os.path as osp
from launch import LaunchDescription
from launch.actions import (
DeclareLaunchArgument, IncludeLaunchDescription, ExecuteProcess
)
from launch.substitutions import LaunchConfiguration
from launch.launch_description_sources import PythonLaunchDescriptionSource
from ament_index_python.packages import get_package_share_directory


def generate_launch_description():
VEHICLE_NAME = "ai_car_caster_trail"
launch_args = (
DeclareLaunchArgument(
"world_name",
default_value="shihou_course",
description="World Name",
),
DeclareLaunchArgument(
"vehicle_name",
default_value="ai_car_caster_trail",
description="Vehicle Name",
),
DeclareLaunchArgument(
"world_path",
default_value=[
osp.join(get_package_share_directory("simulator"), "worlds", ""),
LaunchConfiguration("world_name"), "/",
LaunchConfiguration("vehicle_name"), ".model"
],
description="Path to world file.",
),
DeclareLaunchArgument(
"use_sim_time",
default_value="true",
description="If true, use simulation (Gazebo) clock",
),
)

tf_static_publisher = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
osp.join(get_package_share_directory("vehicle"),
"launch/extrinsic_tfstatic_broadcaster_no_namespace.launch.py"),
),
launch_arguments={
"vehicle_name": VEHICLE_NAME,
"use_sim_time": LaunchConfiguration("use_sim_time"),
}.items(),
)
# ExecuteProcess(
# cmd=["export", "GAZEBO_MODEL_PATH=$(ros2 pkg prefix vehicle)/share/vehicle/xacro"],
# shell=True),
gzserver = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
osp.join(get_package_share_directory("gazebo_ros"),
"launch/gzserver.launch.py"),
),
launch_arguments={
"world": LaunchConfiguration("world_path"),
"world_name": LaunchConfiguration("world_name"),
}.items(),
)
gzclient = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
osp.join(get_package_share_directory("gazebo_ros"),
"launch/gzclient.launch.py"),
),
)
set_use_sim_time = ExecuteProcess(
cmd=['ros2', 'param', 'set', '/gazebo',
'use_sim_time', LaunchConfiguration("use_sim_time")],
output='screen'
)

return LaunchDescription([
*launch_args,
tf_static_publisher,
gzserver,
gzclient,
set_use_sim_time,
])
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
controller_manager:
ros__parameters:
update_rate: 30 # Hz

position_controller:
type: position_controllers/JointGroupPositionController

position_controller:
ros__parameters:
joints:
- caster_back_steering_joint
16 changes: 16 additions & 0 deletions simulator/simulator/models/ai_car_active_caster/model.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>

<model>
<name>ai_car_active_caster</name>
<version>2.0</version>
<sdf version="1.5">model.sdf</sdf>

<author>
<name>Masaya Okada</name>
<email>[email protected]</email>
</author>

<description>
ai_car_active_caster
</description>
</model>
Loading

0 comments on commit 982262e

Please sign in to comment.