-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d917392
commit 8450971
Showing
11 changed files
with
298 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
devel/ | ||
bin/ | ||
build/ | ||
install/ | ||
log/ | ||
msg_gen/ | ||
srv_gen/ | ||
msg/*Action.msg | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
uwrt_mars_rover_drivetrain/uwrt_mars_rover_drivetrain_description/launch/gazebo2.launch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import os | ||
from ament_index_python import get_package_share_path | ||
from ament_index_python.packages import get_package_share_directory | ||
from launch import LaunchDescription | ||
from launch.actions import ExecuteProcess, IncludeLaunchDescription, RegisterEventHandler,TimerAction,DeclareLaunchArgument | ||
from launch.launch_description_sources import PythonLaunchDescriptionSource | ||
from launch.event_handlers import OnProcessExit, OnExecutionComplete | ||
from launch.substitutions import LaunchConfiguration, Command | ||
|
||
|
||
from launch_ros.actions import Node | ||
import xacro | ||
|
||
|
||
def generate_launch_description(): | ||
# Specify the name of the package and path to xacro file within the package | ||
pkg_name = 'uwrt_mars_rover_drivetrain_description' | ||
file_subpath = 'urdf/drivetrain.urdf.xacro' | ||
controllers_config_path = get_package_share_path( | ||
'uwrt_mars_rover_drivetrain_hw') / 'config' / 'drivetrain_controllers.yaml' | ||
|
||
sim_status = LaunchConfiguration('use_sim') | ||
|
||
|
||
# Use xacro to process the file | ||
xacro_file = os.path.join(get_package_share_directory(pkg_name),file_subpath) | ||
|
||
robot_description_config = Command(['xacro ', xacro_file,' sim:=', 'true']) | ||
|
||
|
||
# Configure the node | ||
params={'robot_description': robot_description_config} | ||
node_robot_state_publisher = Node( | ||
package='robot_state_publisher', | ||
executable='robot_state_publisher', | ||
name='robot_state_publisher', | ||
output='screen', | ||
parameters=[params] # add other parameters here if required | ||
) | ||
|
||
|
||
gazebo = IncludeLaunchDescription( | ||
PythonLaunchDescriptionSource([os.path.join( | ||
get_package_share_directory('gazebo_ros'), 'launch'), '/gazebo.launch.py']), | ||
) | ||
|
||
|
||
spawn_entity = Node(package='gazebo_ros', executable='spawn_entity.py', | ||
arguments=['-topic', 'robot_description', | ||
'-entity', 'my_bot'], | ||
output='screen') | ||
|
||
|
||
differential_drivetrain_controller = ExecuteProcess( | ||
cmd=['ros2', 'control', 'load_controller', '--set-state', 'start', | ||
'differential_drivetrain_controller'], | ||
output='screen' | ||
) | ||
|
||
joint_state_broadcaster_controller = ExecuteProcess( | ||
cmd=['ros2', 'control', 'load_controller', '--set-state', 'start', | ||
'joint_state_broadcaster'], | ||
output='screen' | ||
) | ||
|
||
|
||
# Run the node | ||
return LaunchDescription([ | ||
|
||
DeclareLaunchArgument( | ||
'use_sim', | ||
default_value='true', | ||
description='Use ros2_control if true'), | ||
RegisterEventHandler( | ||
OnExecutionComplete( | ||
target_action=spawn_entity, | ||
on_completion=[ | ||
TimerAction( | ||
period=5.0, | ||
actions=[joint_state_broadcaster_controller], | ||
) | ||
] | ||
) | ||
), | ||
RegisterEventHandler( | ||
event_handler=OnProcessExit( | ||
target_action=joint_state_broadcaster_controller, | ||
on_exit=[differential_drivetrain_controller], | ||
) | ||
), | ||
gazebo, | ||
spawn_entity, | ||
node_robot_state_publisher | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...drivetrain/uwrt_mars_rover_drivetrain_description/urdf/drivetrain.ros2controlgazebo.xacro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0"?> | ||
<robot xmlns:xacro="http://www.ros.org/wiki/xacro"> | ||
|
||
<!-- import macros file --> | ||
<xacro:include filename="$(find uwrt_mars_rover_drivetrain_description)/urdf/drivetrain.macro.xacro"/> | ||
|
||
<xacro:macro name="uwrt_drivetrain_ros2_controls_gazebo"> | ||
<ros2_control name="gazebo_wheel_actuator" type="system"> | ||
<hardware> | ||
<plugin>gazebo_ros2_control/GazeboSystem</plugin> | ||
</hardware> | ||
|
||
<xacro:drivetrain_actuator_gazebo prefix="right" suffix="front" /> | ||
<xacro:drivetrain_actuator_gazebo prefix="right" suffix="middle" /> | ||
<xacro:drivetrain_actuator_gazebo prefix="right" suffix="back" /> | ||
<xacro:drivetrain_actuator_gazebo prefix="left" suffix="front" /> | ||
<xacro:drivetrain_actuator_gazebo prefix="left" suffix="middle" /> | ||
<xacro:drivetrain_actuator_gazebo prefix="left" suffix="back" /> | ||
<!-- --> | ||
</ros2_control> | ||
<!-- controller manager --> | ||
<gazebo> | ||
<plugin filename="libgazebo_ros2_control.so" name="gazebo_ros2_control"> | ||
<parameters>$(find uwrt_mars_rover_drivetrain_hw)/config/drivetrain_controllers.yaml</parameters> | ||
<robot_param_node>/robot_state_publisher </robot_param_node> | ||
</plugin> | ||
</gazebo> | ||
|
||
|
||
</xacro:macro> | ||
|
||
|
||
</robot> | ||
|
Oops, something went wrong.