forked from space-ros/demos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add curiosity_gazebo package for ignition gazebo integration
resolves space-ros/space-ros#178 - Fix control parameters for curiosity_description - Move curiosity_path world to curiosity_gazebo - Add launch file for spinning of gazebo world
- Loading branch information
1 parent
688c0b4
commit 195cbd9
Showing
12 changed files
with
518 additions
and
25 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(curiosity_gazebo) | ||
|
||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-Wall -Wextra -Wpedantic) | ||
endif() | ||
|
||
# find dependencies | ||
find_package(ament_cmake REQUIRED) | ||
find_package(ament_cmake_python REQUIRED) | ||
find_package(control_msgs REQUIRED) | ||
find_package(curiosity_description REQUIRED) | ||
find_package(rclcpp REQUIRED) | ||
find_package(ament_cmake REQUIRED) | ||
|
||
install(DIRECTORY | ||
config | ||
launch | ||
models | ||
worlds | ||
DESTINATION share/${PROJECT_NAME} | ||
) | ||
|
||
ament_python_install_package(${PROJECT_NAME}) | ||
|
||
install(PROGRAMS | ||
nodes/odom_tf_publisher | ||
DESTINATION lib/${PROJECT_NAME} | ||
) | ||
|
||
if(BUILD_TESTING) | ||
find_package(ament_lint_auto REQUIRED) | ||
# the following line skips the linter which checks for copyrights | ||
# comment the line when a copyright and license is added to all source files | ||
set(ament_cmake_copyright_FOUND TRUE) | ||
# the following line skips cpplint (only works in a git repo) | ||
# comment the line when this package is in a git repo and when | ||
# a copyright and license is added to all source files | ||
set(ament_cmake_cpplint_FOUND TRUE) | ||
ament_lint_auto_find_test_dependencies() | ||
endif() | ||
|
||
ament_package() |
File renamed without changes.
Empty file.
240 changes: 240 additions & 0 deletions
240
curiosity_rover/curiosity_gazebo/launch/curiosity_gazebo.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,240 @@ | ||
"""Mars Rover Demo Launch File.""" | ||
|
||
import os | ||
|
||
from http.server import executable | ||
from launch import LaunchDescription | ||
from launch.actions import ( | ||
DeclareLaunchArgument, | ||
ExecuteProcess, | ||
RegisterEventHandler, | ||
IncludeLaunchDescription, | ||
) | ||
from launch.substitutions import ( | ||
TextSubstitution, | ||
PathJoinSubstitution, | ||
LaunchConfiguration, | ||
Command, | ||
) | ||
from launch_ros.actions import Node, SetParameter | ||
from launch_ros.substitutions import FindPackageShare | ||
from launch.launch_description_sources import PythonLaunchDescriptionSource | ||
from launch.event_handlers import OnProcessExit, OnExecutionComplete | ||
|
||
from ament_index_python.packages import get_package_share_directory | ||
|
||
import xacro | ||
|
||
|
||
def generate_launch_description(): | ||
"""Launch the mars rover demo.""" | ||
|
||
curiosity_gazebo_path = get_package_share_directory("curiosity_gazebo") | ||
curiosity_rover_models_path = get_package_share_directory("curiosity_description") | ||
|
||
env = { | ||
"IGN_GAZEBO_SYSTEM_PLUGIN_PATH": ":".join( | ||
[ | ||
os.environ.get("IGN_GAZEBO_SYSTEM_PLUGIN_PATH", default=""), | ||
os.environ.get("LD_LIBRARY_PATH", default=""), | ||
] | ||
), | ||
"IGN_GAZEBO_RESOURCE_PATH": ":".join( | ||
[ | ||
os.environ.get("IGN_GAZEBO_RESOURCE_PATH", default=""), | ||
curiosity_gazebo_path + "/models", | ||
curiosity_rover_models_path, | ||
] | ||
), | ||
} | ||
|
||
urdf_model_path = os.path.join( | ||
curiosity_rover_models_path, | ||
"models", | ||
"urdf", | ||
"curiosity_mars_rover.xacro", | ||
) | ||
mars_world_model = os.path.join( | ||
curiosity_gazebo_path, "worlds", "mars_curiosity.world" | ||
) | ||
|
||
doc = xacro.process_file(urdf_model_path) | ||
robot_description = {"robot_description": doc.toxml()} | ||
|
||
odom_node = Node( | ||
package="curiosity_gazebo", | ||
executable="odom_tf_publisher", | ||
name="odom_tf_publisher", | ||
output="screen", | ||
) | ||
|
||
start_world = ExecuteProcess( | ||
cmd=["ign gazebo", mars_world_model, "-r"], | ||
output="screen", | ||
additional_env=env, | ||
shell=True, | ||
) | ||
|
||
robot_state_publisher = Node( | ||
package="robot_state_publisher", | ||
executable="robot_state_publisher", | ||
name="robot_state_publisher", | ||
output="screen", | ||
parameters=[robot_description], | ||
) | ||
|
||
ros_gz_bridge = Node( | ||
package="ros_gz_bridge", | ||
executable="parameter_bridge", | ||
arguments=[ | ||
"/clock@rosgraph_msgs/msg/Clock[ignition.msgs.Clock", | ||
"/model/curiosity_mars_rover/odometry@nav_msgs/msg/Odometry@ignition.msgs.Odometry", | ||
"/scan@sensor_msgs/msg/LaserScan@ignition.msgs.LaserScan", | ||
], | ||
output="screen", | ||
) | ||
|
||
image_bridge = Node( | ||
package="ros_gz_image", | ||
executable="image_bridge", | ||
arguments=["/image_raw", "/image_raw"], | ||
output="screen", | ||
) | ||
|
||
spawn = Node( | ||
package="ros_ign_gazebo", | ||
executable="create", | ||
arguments=[ | ||
"-name", | ||
"curiosity_mars_rover", | ||
"-topic", | ||
robot_description, | ||
"-z", | ||
"-7.5", | ||
], | ||
output="screen", | ||
) | ||
|
||
## Control Components | ||
|
||
component_state_msg = '{name: "IgnitionSystem", target_state: {id: 3, label: ""}}' | ||
|
||
## a hack to resolve current bug | ||
set_hardware_interface_active = ExecuteProcess( | ||
cmd=[ | ||
"ros2", | ||
"service", | ||
"call", | ||
"controller_manager/set_hardware_component_state", | ||
"controller_manager_msgs/srv/SetHardwareComponentState", | ||
component_state_msg, | ||
] | ||
) | ||
|
||
load_joint_state_broadcaster = ExecuteProcess( | ||
cmd=[ | ||
"ros2", | ||
"control", | ||
"load_controller", | ||
"--set-state", | ||
"active", | ||
"joint_state_broadcaster", | ||
], | ||
output="screen", | ||
) | ||
|
||
load_arm_joint_traj_controller = ExecuteProcess( | ||
cmd=[ | ||
"ros2", | ||
"control", | ||
"load_controller", | ||
"--set-state", | ||
"active", | ||
"arm_joint_trajectory_controller", | ||
], | ||
output="screen", | ||
) | ||
|
||
load_mast_joint_traj_controller = ExecuteProcess( | ||
cmd=[ | ||
"ros2", | ||
"control", | ||
"load_controller", | ||
"--set-state", | ||
"active", | ||
"mast_joint_trajectory_controller", | ||
], | ||
output="screen", | ||
) | ||
|
||
load_wheel_joint_traj_controller = ExecuteProcess( | ||
cmd=[ | ||
"ros2", | ||
"control", | ||
"load_controller", | ||
"--set-state", | ||
"active", | ||
"wheel_velocity_controller", | ||
], | ||
output="screen", | ||
) | ||
|
||
load_steer_joint_traj_controller = ExecuteProcess( | ||
cmd=[ | ||
"ros2", | ||
"control", | ||
"load_controller", | ||
"--set-state", | ||
"active", | ||
"steer_position_controller", | ||
], | ||
output="screen", | ||
) | ||
|
||
load_suspension_joint_traj_controller = ExecuteProcess( | ||
cmd=[ | ||
"ros2", | ||
"control", | ||
"load_controller", | ||
"--set-state", | ||
"active", | ||
"wheel_tree_position_controller", | ||
], | ||
output="screen", | ||
) | ||
|
||
return LaunchDescription( | ||
[ | ||
SetParameter(name="use_sim_time", value=True), | ||
start_world, | ||
robot_state_publisher, | ||
spawn, | ||
odom_node, | ||
ros_gz_bridge, | ||
image_bridge, | ||
RegisterEventHandler( | ||
OnProcessExit( | ||
target_action=spawn, | ||
on_exit=[set_hardware_interface_active], | ||
) | ||
), | ||
RegisterEventHandler( | ||
OnProcessExit( | ||
target_action=set_hardware_interface_active, | ||
on_exit=[load_joint_state_broadcaster], | ||
) | ||
), | ||
RegisterEventHandler( | ||
OnProcessExit( | ||
target_action=load_joint_state_broadcaster, | ||
on_exit=[ | ||
load_arm_joint_traj_controller, | ||
load_mast_joint_traj_controller, | ||
load_wheel_joint_traj_controller, | ||
load_steer_joint_traj_controller, | ||
load_suspension_joint_traj_controller, | ||
], | ||
) | ||
), | ||
] | ||
) |
Binary file added
BIN
+19.1 MB
curiosity_rover/curiosity_gazebo/models/curiosity_path/meshes/curiosity_path.stl
Binary file not shown.
99 changes: 99 additions & 0 deletions
99
curiosity_rover/curiosity_gazebo/models/curiosity_path/meshes/mars_path_simple1.dae
Large diffs are not rendered by default.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
curiosity_rover/curiosity_gazebo/models/curiosity_path/model.config
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,13 @@ | ||
<?xml version="1.0"?> | ||
<model> | ||
<name>curiosity_path</name> | ||
<version>0.1.0</version> | ||
<author> | ||
<name>Miguel Angel Rodriguez</name> | ||
<email>duckfrost@theconstructsim.com</email> | ||
</author> | ||
<sdf version="1.9">model.sdf</sdf> | ||
<description> | ||
NASA's most advanced Mars rover Curiosity has landed on the Red Planet.Source 3D Models: https://nasa3d.arc.nasa.gov/detail/curiosity-path | ||
</description> | ||
</model> |
66 changes: 66 additions & 0 deletions
66
curiosity_rover/curiosity_gazebo/models/curiosity_path/model.sdf
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,66 @@ | ||
<?xml version="1.0" ?> | ||
<sdf version='1.9'> | ||
<model name="curiosity_path"> | ||
<static>1</static> | ||
<link name="link"> | ||
<inertial> | ||
<mass>0.25</mass> | ||
<inertia> | ||
<ixx>0.00015</ixx> | ||
<ixy>0.000000</ixy> | ||
<ixz>0.000000</ixz> | ||
<iyy>0.00015</iyy> | ||
<iyz>0.000000</iyz> | ||
<izz>0.00015</izz> | ||
</inertia> | ||
</inertial> | ||
<collision name="collision"> | ||
<geometry> | ||
<mesh> | ||
<uri>model://curiosity_path/meshes/curiosity_path.stl</uri> | ||
<scale>1 1 1</scale> | ||
</mesh> | ||
</geometry> | ||
<surface> | ||
<friction> | ||
<ode> | ||
<mu>30.0</mu> | ||
<mu2>30.0</mu2> | ||
</ode> | ||
</friction> | ||
<contact> | ||
<ode> | ||
<kp>1000000.0</kp> | ||
<kd>100.0</kd> | ||
<max_vel>1.0</max_vel> | ||
<min_depth>0.002</min_depth> | ||
</ode> | ||
</contact> | ||
</surface> | ||
</collision> | ||
<visual name="visual"> | ||
<geometry> | ||
<mesh> | ||
<uri>model://curiosity_path/meshes/mars_path_simple1.dae</uri> | ||
<scale>1 1 1</scale> | ||
</mesh> | ||
</geometry> | ||
<!-- | ||
<material> | ||
<script> | ||
<uri>file://media/materials/scripts/gazebo.material</uri> | ||
<name>Gazebo/Grey</name> | ||
</script> | ||
</material> | ||
--> | ||
</visual> | ||
<velocity_decay> | ||
<linear>0.000000</linear> | ||
<angular>0.000000</angular> | ||
</velocity_decay> | ||
<self_collide>0</self_collide> | ||
<kinematic>0</kinematic> | ||
<gravity>1</gravity> | ||
</link> | ||
</model> | ||
</sdf> |
Oops, something went wrong.