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

add caster models #104

Closed
wants to merge 5 commits into from
Closed
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
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