Skip to content

Commit

Permalink
Move all files
Browse files Browse the repository at this point in the history
  • Loading branch information
destogl committed May 28, 2021
1 parent 5f58183 commit 30f3f94
Show file tree
Hide file tree
Showing 17 changed files with 269 additions and 419 deletions.
15 changes: 14 additions & 1 deletion ros2_control_demo_bringup/launch/rrbot.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ def generate_launch_description():
have to be updated.",
)
)
declared_arguments.append(
DeclareLaunchArgument(
"use_sim",
default_value="false",
description="Start robot in Gazebo simulation.",
)
)
declared_arguments.append(
DeclareLaunchArgument(
"use_fake_hardware",
Expand Down Expand Up @@ -96,6 +103,7 @@ def generate_launch_description():
description_package = LaunchConfiguration("description_package")
description_file = LaunchConfiguration("description_file")
prefix = LaunchConfiguration("prefix")
use_sim = LaunchConfiguration("use_sim")
use_fake_hardware = LaunchConfiguration("use_fake_hardware")
fake_sensor_commands = LaunchConfiguration("fake_sensor_commands")
slowdown = LaunchConfiguration("slowdown")
Expand All @@ -106,11 +114,16 @@ def generate_launch_description():
[
PathJoinSubstitution([FindExecutable(name="xacro")]),
" ",
PathJoinSubstitution([FindPackageShare(description_package), "urdf", description_file]),
PathJoinSubstitution(
[FindPackageShare(description_package), "urdf", description_file]
),
" ",
"prefix:=",
prefix,
" ",
"use_sim:=",
use_sim,
" ",
"use_fake_hardware:=",
use_fake_hardware,
" ",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Copyright 2021 Department of Engineering Cybernetics, NTNU.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, ThisLaunchFileDir


def generate_launch_description():
# Declare arguments
declared_arguments = []
declared_arguments.append(
DeclareLaunchArgument(
"prefix",
default_value='""',
description="Prefix of the joint names, useful for \
multi-robot setup. If changed than also joint names in the controllers' configuration \
have to be updated.",
)
)
declared_arguments.append(
DeclareLaunchArgument(
"use_fake_hardware",
default_value="true",
description="Start robot with fake hardware mirroring command to its states.",
)
)
declared_arguments.append(
DeclareLaunchArgument(
"fake_sensor_commands",
default_value="false",
description="Enable fake command interfaces for sensors used for simple simulations. \
Used only if 'use_fake_hardware' parameter is true.",
)
)
declared_arguments.append(
DeclareLaunchArgument(
"slowdown", default_value="3.0", description="Slowdown factor of the RRbot."
)
)
declared_arguments.append(
DeclareLaunchArgument(
"robot_controller",
default_value="forward_position_controller",
description="Robot controller to start.",
)
)

# Initialize Arguments
prefix = LaunchConfiguration("prefix")
use_fake_hardware = LaunchConfiguration("use_fake_hardware")
fake_sensor_commands = LaunchConfiguration("fake_sensor_commands")
slowdown = LaunchConfiguration("slowdown")
robot_controller = LaunchConfiguration("robot_controller")

base_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource([ThisLaunchFileDir(), "/rrbot.launch.py"]),
launch_arguments={
"controllers_file": "rrbot_multi_interface_forward_controllers.yaml",
"description_file": "rrbot_system_multi_interface.urdf.xacro",
"prefix": prefix,
"use_fake_hardware": use_fake_hardware,
"fake_sensor_commands": fake_sensor_commands,
"slowdown": slowdown,
"robot_controller": robot_controller,
}.items(),
)

return LaunchDescription(declared_arguments + [base_launch])
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Copyright 2021 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution, ThisLaunchFileDir

from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare


def generate_launch_description():
# Declare arguments
declared_arguments = []
declared_arguments.append(
DeclareLaunchArgument(
"prefix",
default_value='""',
description="Prefix of the joint names, useful for \
multi-robot setup. If changed than also joint names in the controllers' configuration \
have to be updated.",
)
)
declared_arguments.append(
DeclareLaunchArgument(
"use_fake_hardware",
default_value="true",
description="Start robot with fake hardware mirroring command to its states.",
)
)
declared_arguments.append(
DeclareLaunchArgument(
"fake_sensor_commands",
default_value="false",
description="Enable fake command interfaces for sensors used for simple simulations. \
Used only if 'use_fake_hardware' parameter is true.",
)
)
declared_arguments.append(
DeclareLaunchArgument(
"slowdown", default_value="3.0", description="Slowdown factor of the RRbot."
)
)
declared_arguments.append(
DeclareLaunchArgument(
"robot_controller",
default_value="forward_position_controller",
description="Robot controller to start.",
)
)

# Initialize Arguments
prefix = LaunchConfiguration("prefix")
use_fake_hardware = LaunchConfiguration("use_fake_hardware")
fake_sensor_commands = LaunchConfiguration("fake_sensor_commands")
slowdown = LaunchConfiguration("slowdown")
robot_controller = LaunchConfiguration("robot_controller")

gazebo = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
[
PathJoinSubstitution(
[
FindPackageShare("gazebo_ros"),
"launch",
"/gazebo.launch.py",
]
)
]
),
launch_arguments={"verbose": "false"}.items(),
)

spawn_entity = Node(
package="gazebo_ros",
executable="spawn_entity.py",
arguments=["-topic", "robot_description", "-entity", "rrbot_system_position"],
output="screen",
)

base_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource([ThisLaunchFileDir(), "/rrbot.launch.py"]),
launch_arguments={
"description_file": "rrbot_system_position_only.urdf.xacro",
"prefix": prefix,
"use_fake_hardware": use_fake_hardware,
"fake_sensor_commands": fake_sensor_commands,
"slowdown": slowdown,
"robot_controller": robot_controller,
}.items(),
)

return LaunchDescription(declared_arguments + [gazebo, base_launch, spawn_entity])
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">

<xacro:macro name="rrbot_system_multi_interface" params="name prefix">
<xacro:macro name="rrbot_system_multi_interface" params="name prefix use_sim:=^|false use_fake_hardware:=^|true fake_sensor_commands:=^|false slowdown:=2.0">

<ros2_control name="${name}" type="system">
<hardware>
<plugin>ros2_control_demo_hardware/RRBotSystemMultiInterfaceHardware</plugin>
<param name="example_param_hw_start_duration_sec">2.0</param>
<param name="example_param_hw_stop_duration_sec">3.0</param>
<param name="example_param_hw_slowdown">2.0</param>
</hardware>

<xacro:if value="$(arg use_sim)">
<hardware>
<plugin>gazebo_ros2_control/GazeboSystem</plugin>
</hardware>
</xacro:if>
<xacro:unless value="$(arg use_sim)">
<hardware>
<xacro:if value="${use_fake_hardware}">
<plugin>fake_components/GenericSystem</plugin>
<param name="fake_sensor_commands">${fake_sensor_commands}</param>
<param name="state_following_offset">0.0</param>
</xacro:if>
<xacro:unless value="${use_fake_hardware}">
<plugin>ros2_control_demo_hardware/RRBotSystemMultiInterfaceHardware</plugin>
<param name="example_param_hw_start_duration_sec">2.0</param>
<param name="example_param_hw_stop_duration_sec">3.0</param>
<param name="example_param_hw_slowdown">${slowdown}</param>
</xacro:unless>
</hardware>
</xacro:unless>

<joint name="joint1">
<command_interface name="position">
<param name="min">-1</param>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0"?>
<!-- Revolute-Revolute Manipulator -->
<!--
Copied and modified from ROS1 example:
https://github.com/ros-simulation/gazebo_ros_demos/blob/kinetic-devel/rrbot_description/urdf/rrbot.xacro
-->
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="2dof_robot">
<xacro:arg name="use_sim" default="false" />

<!-- Enable setting arguments from the launch file -->
<xacro:arg name="use_fake_hardware" default="true" />
<xacro:arg name="fake_sensor_commands" default="false" />
<xacro:arg name="prefix" default="" />
<xacro:arg name="slowdown" default="2.0" />

<!-- Import RRBot macro -->
<xacro:include filename="$(find ros2_control_demo_description)/urdf/rrbot/rrbot.urdf.xacro" />

<!-- Import all Gazebo-customization elements, including Gazebo colors -->
<xacro:include filename="$(find ros2_control_demo_description)/urdf/rrbot/gazebo/rrbot.gazebo.xacro" />

<!-- Import Rviz colors -->
<xacro:include filename="$(find ros2_control_demo_description)/urdf/rrbot/gazebo/rrbot.materials.xacro" />

<!-- Import RRBot ros2_control description -->
<xacro:include filename="$(find ros2_control_demo_description)/urdf/rrbot/ros2_control/rrbot_system_position_only.ros2_control.xacro" />

<!-- Used for fixing robot -->
<link name="world"/>
<gazebo reference="world">
<static>true</static>
</gazebo>

<xacro:rrbot parent="world" prefix="$(arg prefix)">
<origin xyz="0 0 0" rpy="0 0 0" />
</xacro:rrbot>

<xacro:rrbot_gazebo prefix="$(arg prefix)" />

<xacro:rrbot_system_multi_interface
name="RRBotSystemMultiInterface" prefix="$(arg prefix)"
use_fake_hardware="$(arg use_fake_hardware)"
fake_sensor_commands="$(arg fake_sensor_commands)"
slowdown="$(arg slowdown)" />

</robot>

This file was deleted.

Loading

0 comments on commit 30f3f94

Please sign in to comment.