Skip to content

Commit

Permalink
Add canadarm_gazebo package for ignition gazebo integration
Browse files Browse the repository at this point in the history
resolves space-ros/space-ros#178

 - Add canadarm_description package
 - Move earth and iss  world models to canadarm_gazebo
  • Loading branch information
franklinselva committed Aug 15, 2024
1 parent 013df12 commit b2806a8
Show file tree
Hide file tree
Showing 10 changed files with 210 additions and 31 deletions.
3 changes: 3 additions & 0 deletions canadarm2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build/
install/
log/
31 changes: 31 additions & 0 deletions canadarm2/canadarm_gazebo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
cmake_minimum_required(VERSION 3.8)
project(canadarm_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(canadarm_description REQUIRED)

install(DIRECTORY
launch
models
worlds
DESTINATION share/${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()
118 changes: 118 additions & 0 deletions canadarm2/canadarm_gazebo/launch/canadarm.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
"""Canadarm2 Gazebo launch file."""

import os
from launch import LaunchDescription # type: ignore
from launch.actions import ExecuteProcess, RegisterEventHandler # type: ignore
from launch.event_handlers import OnProcessExit # type: ignore
from launch_ros.actions import Node # type: ignore

from ament_index_python.packages import get_package_share_directory # type: ignore

import xacro # type: ignore


def generate_launch_description():
"""Generate launch description with multiple components."""

canadarm_gazebo_path = get_package_share_directory("canadarm_gazebo")
simulation_models_path = get_package_share_directory("canadarm_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=""),
canadarm_gazebo_path + "/models",
]
),
}

urdf_model_path = os.path.join(
simulation_models_path,
"models",
"urdf",
"SSRMS_Canadarm2.urdf.xacro",
)
leo_model = os.path.join(canadarm_gazebo_path, "worlds", "simple.world")

doc = xacro.process_file(
urdf_model_path, mappings={"xyz": "1.0 0.0 1.5", "rpy": "3.1416 0.0 0.0"}
)
robot_description = {"robot_description": doc.toxml()}

start_world = ExecuteProcess(
cmd=["ign gazebo", leo_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],
)

spawn = Node(
package="ros_ign_gazebo",
executable="create",
arguments=[
"-name",
"canadarm",
"-topic",
robot_description,
],
output="screen",
)

# Control
load_joint_state_broadcaster = ExecuteProcess(
cmd=[
"ros2",
"control",
"load_controller",
"--set-state",
"active",
"joint_state_broadcaster",
],
output="screen",
)

load_canadarm_joint_controller = ExecuteProcess(
cmd=[
"ros2",
"control",
"load_controller",
"--set-state",
"active",
"canadarm_joint_trajectory_controller",
],
output="screen",
)

return LaunchDescription(
[
start_world,
robot_state_publisher,
spawn,
RegisterEventHandler(
OnProcessExit(
target_action=spawn,
on_exit=[load_joint_state_broadcaster],
)
),
RegisterEventHandler(
OnProcessExit(
target_action=load_joint_state_broadcaster,
on_exit=[load_canadarm_joint_controller],
)
),
]
)
27 changes: 27 additions & 0 deletions canadarm2/canadarm_gazebo/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>canadarm_gazebo</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="franklinselva10@gmail.com">franklinselva</maintainer>
<license>TODO: License declaration</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<depend>canadarm_description</depend>
<depend>ros_gz</depend>

<exec_depend>ign_ros2_control</exec_depend>
<exec_depend>ros2_control</exec_depend>
<exec_depend>ros2_controllers</exec_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,36 @@
<gravity>0 0 0</gravity>

<model name="earth">
<pose>170 0 -50 0 0 -1.5708</pose>
<static>1</static>
<link name='link'>
<inertial>
<mass>0.25</mass>
<inertia>
<ixx>1</ixx>
<ixy>0.000</ixy>
<ixz>0.000</ixz>
<iyy>1</iyy>
<iyz>0.000</iyz>
<izz>1</izz>
</inertia>
</inertial>
<visual name='visual'>
<geometry>
<mesh>
<uri>model://canadarm/meshes/earth.dae</uri>
<scale>3 3 3</scale>
</mesh>
</geometry>
</visual>
<velocity_decay>
<linear>0.000000</linear>
<angular>0.000000</angular>
</velocity_decay>
<self_collide>0</self_collide>
<kinematic>0</kinematic>
<gravity>0</gravity>
</link>
<pose>170 0 -50 0 0 -1.5708</pose>
<static>1</static>
<link name='link'>
<inertial>
<mass>0.25</mass>
<inertia>
<ixx>1</ixx>
<ixy>0.000</ixy>
<ixz>0.000</ixz>
<iyy>1</iyy>
<iyz>0.000</iyz>
<izz>1</izz>
</inertia>
</inertial>
<visual name='visual'>
<geometry>
<mesh>
<uri>model://canadarm/meshes/earth.dae</uri>
<scale>3 3 3</scale>
</mesh>
</geometry>
</visual>
<velocity_decay>
<linear>0.000000</linear>
<angular>0.000000</angular>
</velocity_decay>
<self_collide>0</self_collide>
<kinematic>0</kinematic>
<gravity>0</gravity>
</link>
</model>

<model name="iss">
Expand Down Expand Up @@ -88,7 +88,7 @@
</velocity_decay>
<self_collide>0</self_collide>
<kinematic>0</kinematic>
<gravity>0</gravity>
<gravity>0</gravity>
</link>
</model>
</world>
Expand Down

0 comments on commit b2806a8

Please sign in to comment.