Skip to content

Commit

Permalink
Update canadarm_demo to the changes
Browse files Browse the repository at this point in the history
related to space-ros/space-ros#178
 - Cleaned up canadarm launch file for the demo
 - Updated comments for demo node
 - Strip Moveit Redundant Node
 - Cleanup packages.xml
 - Remove ros control parameters for gazebo
  • Loading branch information
franklinselva committed Sep 10, 2024
1 parent c4b3dec commit 5a30311
Show file tree
Hide file tree
Showing 12 changed files with 192 additions and 290 deletions.
7 changes: 7 additions & 0 deletions canadarm2/.defaults.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"build":
{
"symlink-install": true,
"cmake_args": "-DCMAKE_BUILD_TYPE=Release -Wno-dev",
},
}
23 changes: 23 additions & 0 deletions canadarm2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM osrf/space-ros:core

ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp

# Install dependencies
RUN sudo apt update && sudo apt install -y ros-${ROS_DISTRO}-control-msgs \
ros-${ROS_DISTRO}-rmw-cyclonedds-cpp

# Prepare the workspace
SHELL ["bash", "-c"]
RUN mkdir -p ${HOME}/canadarm_ws/src
WORKDIR ${HOME}/canadarm_ws

COPY ./canadarm_demo src/canadarm_demo
COPY .defaults.yaml .defaults.yaml

# Build the workspace
RUN source /opt/ros/${ROS_DISTRO}/setup.bash \
&& source /opt/spaceros/setup.bash \
&& colcon build

# Source the workspace
RUN echo "source ${HOME}/canadarm_ws/install/setup.bash" >> ${HOME}/.bashrc
60 changes: 60 additions & 0 deletions canadarm2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Define variables
DOCKER_IMAGE = osrf/space-ros:canadarm_demo
WORKSPACE = ${HOME}/canadarm_ws
LOCAL_WORKSPACE = $(shell pwd)
SHELL := /bin/bash
XTERM_CONFIG = -bg black -fg white -fa 'Monospace' -fs 11

# Help target to describe each target
.PHONY: help
help:
@echo "CanadArm2 Makefile"
@echo " make build - Build the Docker image and the Gazebo workspace locally"
@echo " make build-docker - Build the Docker image"
@echo " make build-gazebo - Build the Gazebo workspace locally"
@echo " make run-gazebo - Run the CanadArm2 Gazebo simulation locally"
@echo " make run-demo - Run the CanadArm2 demo within Docker"
@echo " make clean - Clean the local workspace"
@echo " make all - Build and run everything"

# Build all
.PHONY: build
build: build-docker build-gazebo

# Build the Docker image
.PHONY: build-docker
build-docker:
docker build -t $(DOCKER_IMAGE) .

# Run the CanadArm Gazebo simulation locally
.PHONY: run-gazebo
run-gazebo:
xterm $(XTERM_CONFIG) -T 'CanadArm2 Gazebo' -e 'source /opt/ros/${ROS_DISTRO}/setup.bash \
&& source $(LOCAL_WORKSPACE)/install/setup.bash \
&& ros2 launch canadarm_gazebo canadarm.launch.py' &

# Build the Gazebo workspace locally
.PHONY: build-gazebo
build-gazebo:
@source /opt/ros/${ROS_DISTRO}/setup.bash && \
rosdep install --from-paths canadarm_gazebo --ignore-src -r -y && \
rosdep install --from-paths canadarm_description --ignore-src -r -y && \
colcon build --symlink-install --base-paths $(LOCAL_WORKSPACE) --install-base $(LOCAL_WORKSPACE)/install \
--cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
--packages-select canadarm_description canadarm_gazebo

# Run the CanadArm demo within Docker
.PHONY: run-docker
run-docker:
xterm $(XTERM_CONFIG) -T 'CanadArm2 Demo' -e "docker run -it --rm \
-e RMW_IMPLEMENTATION=rmw_cyclonedds_cpp \
$(DOCKER_IMAGE) \
bash -c 'source ~/.bashrc && ros2 launch canadarm_demo canadarm.launch.py'" &

.PHONY: clean
clean:
rm -rf $(LOCAL_WORKSPACE)/install $(LOCAL_WORKSPACE)/log $(LOCAL_WORKSPACE)/build

# Build and run everything
.PHONY: run
run: build run-gazebo run-docker
5 changes: 0 additions & 5 deletions canadarm2/canadarm_demo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ find_package(ament_cmake REQUIRED)
find_package(ament_cmake_python REQUIRED)
find_package(rclpy REQUIRED)
find_package(rosidl_default_generators REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)

rosidl_generate_interfaces(${PROJECT_NAME}
"action/MoveJoint.action"
Expand All @@ -34,9 +31,7 @@ endif()

install(DIRECTORY
action
config
launch
worlds
DESTINATION share/${PROJECT_NAME}
)

Expand Down
76 changes: 0 additions & 76 deletions canadarm2/canadarm_demo/config/canadarm_control.yaml

This file was deleted.

109 changes: 12 additions & 97 deletions canadarm2/canadarm_demo/launch/canadarm.launch.py
Original file line number Diff line number Diff line change
@@ -1,109 +1,24 @@
from http.server import executable
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess, RegisterEventHandler
from launch.substitutions import TextSubstitution, PathJoinSubstitution, LaunchConfiguration, Command
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare
from launch.event_handlers import OnProcessExit, OnExecutionComplete
import os
from os import environ
"""Canadarm2 demo launch file."""

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription # type: ignore

import xacro
from launch_ros.actions import Node # type: ignore


def generate_launch_description():
# ld = LaunchDescription()
"""Generate launch description with multiple components."""

canadarm_demos_path = get_package_share_directory('canadarm')
simulation_models_path = get_package_share_directory('simulation')

env = {'IGN_GAZEBO_SYSTEM_PLUGIN_PATH':
':'.join([environ.get('IGN_GAZEBO_SYSTEM_PLUGIN_PATH', default=''),
environ.get('LD_LIBRARY_PATH', default='')]),
'IGN_GAZEBO_RESOURCE_PATH':
':'.join([environ.get('IGN_GAZEBO_RESOURCE_PATH', default=''), canadarm_demos_path])}


urdf_model_path = os.path.join(simulation_models_path, 'models', 'canadarm', 'urdf', 'SSRMS_Canadarm2.urdf.xacro')
leo_model = os.path.join(canadarm_demos_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()}


#run_node = Node(
# run_node = Node(
# package="canadarm",
# executable="move_joint_server",
# output='screen'
#)

run_move_arm = Node(
package="canadarm",
executable="move_arm",
output='screen'
)


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'
)
# )

run_move_arm = Node(package="canadarm_demo", executable="move_arm", output="screen")

# Control
load_joint_state_broadcaster = ExecuteProcess(
cmd=['ros2', 'control', 'load_controller', '--set-state', 'active',
'joint_state_broadcaster'],
output='screen'
return LaunchDescription(
[
# run_node,
run_move_arm,
]
)

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,
#run_node,
run_move_arm,

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],
)
),
])
51 changes: 0 additions & 51 deletions canadarm2/canadarm_demo/nodes/hello_moveit.cpp

This file was deleted.

Loading

0 comments on commit 5a30311

Please sign in to comment.