Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update description and bringup generated files to be also applicable to mobile robots. Update generated documenation in README files. Add templates for simulation and moveit setup. #192

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions scripts/setup-robot-bringup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,20 @@ cp -n $ROS2_CONTROL_TEMPLATES/test_goal_publishers_config.yaml $ROBOT_FPC_PUB_YA
for file_type in "${LAUNCH_FILE_TYPES[@]}"; do
# Construct the file paths
ROBOT_LAUNCH="launch/${ROBOT_NAME}.launch${file_type}"
ROBOT_CONTROL_LAUNCH="launch/${ROBOT_NAME}_control.launch${file_type}"
TEST_FWD_POS_CTRL_LAUNCH="launch/test_forward_position_controller.launch${file_type}"
TEST_JTC_LAUNCH="launch/test_joint_trajectory_controller.launch${file_type}"

# Copy the templates to the destination with the specified file type
cp -n "$ROS2_CONTROL_TEMPLATES/robot_ros2_control.launch${file_type}" "${ROBOT_LAUNCH}"
if [ -f "$ROS2_CONTROL_TEMPLATES/robot.launch${file_type}" ]; then # only .xml for now
cp -n "$ROS2_CONTROL_TEMPLATES/robot.launch${file_type}" "${ROBOT_LAUNCH}"
fi
cp -n "$ROS2_CONTROL_TEMPLATES/robot_ros2_control.launch${file_type}" "${ROBOT_CONTROL_LAUNCH}"
cp -n "$ROS2_CONTROL_TEMPLATES/test_forward_position_controller.launch${file_type}" "${TEST_FWD_POS_CTRL_LAUNCH}"
cp -n "$ROS2_CONTROL_TEMPLATES/test_joint_trajectory_controller.launch${file_type}" "${TEST_JTC_LAUNCH}"

# sed all needed files
FILES_TO_SED=($ROBOT_LAUNCH $TEST_FWD_POS_CTRL_LAUNCH $TEST_JTC_LAUNCH)
FILES_TO_SED=($ROBOT_CONTROL_LAUNCH $TEST_FWD_POS_CTRL_LAUNCH $TEST_JTC_LAUNCH)
destogl marked this conversation as resolved.
Show resolved Hide resolved

for SED_FILE in "${FILES_TO_SED[@]}"; do
sed -i "s/\\\$PKG_NAME\\\$/${PKG_NAME}/g" $SED_FILE
Expand All @@ -123,14 +127,26 @@ done
prepend_to_string="if(BUILD_TESTING)"
sed -i "s/$prepend_to_string/install\(\\n DIRECTORY config launch\\n DESTINATION share\/\$\{PROJECT_NAME\}\\n\)\\n\\n$prepend_to_string/g" CMakeLists.txt

# extend README with general instructions
# extend main README with general instructions
if [ -f ../README.md ]; then
cat $ROS2_CONTROL_TEMPLATES/append_to_MAIN_README.md >> ../README.md
sed -i "s/\\\$PKG_NAME\\\$/${PKG_NAME}/g" ../README.md
sed -i "s/\\\$ROBOT_NAME\\\$/${ROBOT_NAME}/g" ../README.md
sed -i "s/\\\$DESCR_PKG_NAME\\\$/${DESCR_PKG_NAME}/g" ../README.md
else
echo "No README.md in parent directory found, skipping adding short bringup info."
fi

# extend package README with general instructions
if [ -f README.md ]; then
cat $ROS2_CONTROL_TEMPLATES/append_to_README.md >>README.md
sed -i "s/\\\$PKG_NAME\\\$/${PKG_NAME}/g" README.md
sed -i "s/\\\$ROBOT_NAME\\\$/${ROBOT_NAME}/g" README.md
sed -i "s/\\\$DESCR_PKG_NAME\\\$/${DESCR_PKG_NAME}/g" $SED_FILE
echo "#${PKG_NAME}\n\n" > README.md
fi

cat $ROS2_CONTROL_TEMPLATES/append_to_README.md >>README.md
sed -i "s/\\\$PKG_NAME\\\$/${PKG_NAME}/g" README.md
sed -i "s/\\\$ROBOT_NAME\\\$/${ROBOT_NAME}/g" README.md
sed -i "s/\\\$DESCR_PKG_NAME\\\$/${DESCR_PKG_NAME}/g" README.md

# TODO: Add license checks

# Compile and add new package the to the path
Expand Down
8 changes: 6 additions & 2 deletions scripts/setup-robot-description.bash
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,15 @@ cp -n "$ROBOT_DESCRIPTION_TEMPLATES/materials.xacro" urdf/common/materials.xacro
# Copy launch files for testing the description
for file_type in "${LAUNCH_FILE_TYPES[@]}"; do
mkdir -p launch

ROBOT_DESCRIPTION_LAUNCH="launch/${ROBOT_NAME}_description.launch${file_type}"
cp -n "$ROBOT_DESCRIPTION_TEMPLATES/robot_description.launch${file_type}" $ROBOT_DESCRIPTION_LAUNCH

VIEW_ROBOT_LAUNCH="launch/view_${ROBOT_NAME}.launch${file_type}"
cp -n "$ROBOT_DESCRIPTION_TEMPLATES/view_robot.launch${file_type}" $VIEW_ROBOT_LAUNCH

# sed all needed files
FILES_TO_SED=($ROBOT_URDF_XACRO $ROBOT_MACRO $ROBOT_MACRO_ROS2_CONTROL $VIEW_ROBOT_LAUNCH)
FILES_TO_SED=($ROBOT_URDF_XACRO $ROBOT_MACRO $ROBOT_MACRO_ROS2_CONTROL $ROBOT_DESCRIPTION_LAUNCH $VIEW_ROBOT_LAUNCH)

for SED_FILE in "${FILES_TO_SED[@]}"; do
sed -i "s/\\\$PKG_NAME\\\$/${PKG_NAME}/g" $SED_FILE
Expand Down Expand Up @@ -188,7 +192,7 @@ sed -i "/$pattern/a$lines_to_append" CMakeLists.txt

# extend README with general instructions
if [ ! -f README.md ]; then
echo "${PKG_NAME}\n\n" > README.md
echo "#${PKG_NAME}\n\n" > README.md
fi

cat $ROBOT_DESCRIPTION_TEMPLATES/append_to_README.md >> README.md
Expand Down
104 changes: 104 additions & 0 deletions templates/robot_description/robot_description.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Copyright (c) 2024, Stogl Robotics Consulting UG (haftungsbeschränkt)
#
# 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.

#
# Source of this file is https://github.com/StoglRobotics/ros_team_workspace repository.
#
# Author: Dr. Denis
#

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare
from launch.conditions import IfCondition


def generate_launch_description():
# Declare arguments
declared_arguments = []
declared_arguments.append(
DeclareLaunchArgument(
"description_package",
default_value="$PKG_NAME$",
description="Description package of the $ROBOT_NAME$. Usually the argument is not set, \
it enables use of a custom description.",
)
)
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(
"launch_rviz",
default_value="false",
description="Launch Rviz?",
)
)

# Initialize Arguments
description_package = LaunchConfiguration("description_package")
prefix = LaunchConfiguration("prefix")
launch_rviz = LaunchConfiguration("launch_rviz")

# Get URDF via xacro
robot_description_content = Command(
[
PathJoinSubstitution([FindExecutable(name="xacro")]),
" ",
PathJoinSubstitution(
[FindPackageShare(description_package), "urdf", "$ROBOT_NAME$.urdf.xacro"]
),
" ",
"prefix:=",
prefix,
" ",
]
)

robot_description = {"robot_description": robot_description_content}

rviz_config_file = PathJoinSubstitution(
[FindPackageShare(description_package), "rviz", "$ROBOT_NAME$.rviz"]
)

robot_state_publisher_node = Node(
package="robot_state_publisher",
executable="robot_state_publisher",
output="both",
parameters=[robot_description],
)
rviz_node = Node(
package="rviz2",
executable="rviz2",
name="rviz2",
output="log",
condition=IfCondition(launch_rviz),
arguments=["-d", rviz_config_file],
)

return LaunchDescription(
declared_arguments
+ [
robot_state_publisher_node,
rviz_node,
]
)
53 changes: 53 additions & 0 deletions templates/robot_description/robot_description.launch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!--
Copyright (c) 2024, Stogl Robotics Consulting UG (haftungsbeschränkt)

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.


Source of this file are templates in https://github.com/StoglRobotics/ros_team_workspace repository.
-->

<launch>
<arg name="description_package"
default="$PKG_NAME$"
description="Description package of the dte_ea_1000. Usually the argument is not set, it enables use of a custom description."/>
<arg name="prefix"
default=""
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."/>
<arg name="use_mock_hardware"
default="false"
description="Start robot with mock hardware mirroring command to its states."/>
<arg name="mock_sensor_commands"
default="false"
description="Enable mock command interfaces for sensors used for simple simulations. Used only if 'use_mock_hardware' parameter is true."/>
<arg name="sim_gazebo"
default="false"
description="Start robot in Gazebo simulation."/>
<arg name="simulation_controllers"
default=""
description="Path to the yaml file with controllers used in the simulation."/>
<arg name="launch_rviz"
default="false"
description="Launch RViz?"/>

<let name="robot_description_content" value="$(command '$(find-exec xacro) $(find-pkg-share $(var description_package))/urdf/$ROBOT_NAME$.urdf.xacro prefix:=$(var prefix) use_mock_hardware:=$(var use_mock_hardware) mock_sensor_commands:=$(var mock_sensor_commands) sim_gazebo:=$(var sim_gazebo) simulation_controllers:=$(var simulation_controllers)')" />

<node pkg="robot_state_publisher" exec="robot_state_publisher" output="both">
<param name="robot_description" value="$(var robot_description_content)" />
<param name="use_sim_time" value="$(var sim_gazebo)" />
</node>

<node if="$(var launch_rviz)" pkg="rviz2" exec="rviz2" output="log" args="-d $(find-pkg-share $(var description_package))/rviz/$ROBOT_NAME$.rviz">
<param name="use_sim_time" value="$(var sim_gazebo)" />
</node>
</launch>
73 changes: 55 additions & 18 deletions templates/robot_description/robot_macro.ros2_control.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<xacro:if value="${use_mock_hardware}">
<plugin>mock_components/GenericSystem</plugin>
<param name="mock_sensor_commands">${mock_sensor_commands}</param>
<param name="calculate_dynamics">true</param>
</xacro:if>
<xacro:if value="${sim_gazebo_classic}">
<plugin>gazebo_ros2_control/GazeboSystem</plugin>
Expand All @@ -35,8 +36,12 @@
<state_interface name="position">
<param name="initial_value">0.0</param>
</state_interface>
<state_interface name="velocity"/>
<state_interface name="acceleration"/>
<state_interface name="velocity">
<param name="initial_value">0.0</param>
</state_interface>
<state_interface name="acceleration">
<param name="initial_value">0.0</param>
</state_interface>
</joint>
<joint name="${prefix}joint2">
<command_interface name="position"> <!-- Add/Remove interfaces as needed -->
Expand All @@ -46,8 +51,12 @@
<state_interface name="position">
<param name="initial_value">0.0</param>
</state_interface>
<state_interface name="velocity"/>
<state_interface name="acceleration"/>
<state_interface name="velocity">
<param name="initial_value">0.0</param>
</state_interface>
<state_interface name="acceleration">
<param name="initial_value">0.0</param>
</state_interface>
</joint>
<joint name="${prefix}joint3">
<command_interface name="position"> <!-- Add/Remove interfaces as needed -->
Expand All @@ -57,8 +66,12 @@
<state_interface name="position">
<param name="initial_value">0.0</param>
</state_interface>
<state_interface name="velocity"/>
<state_interface name="acceleration"/>
<state_interface name="velocity">
<param name="initial_value">0.0</param>
</state_interface>
<state_interface name="acceleration">
<param name="initial_value">0.0</param>
</state_interface>
</joint>
<joint name="${prefix}joint4">
<command_interface name="position"> <!-- Add/Remove interfaces as needed -->
Expand All @@ -68,8 +81,12 @@
<state_interface name="position">
<param name="initial_value">0.0</param>
</state_interface>
<state_interface name="velocity"/>
<state_interface name="acceleration"/>
<state_interface name="velocity">
<param name="initial_value">0.0</param>
</state_interface>
<state_interface name="acceleration">
<param name="initial_value">0.0</param>
</state_interface>
</joint>
<joint name="${prefix}joint5">
<command_interface name="position"> <!-- Add/Remove interfaces as needed -->
Expand All @@ -79,8 +96,12 @@
<state_interface name="position">
<param name="initial_value">0.0</param>
</state_interface>
<state_interface name="velocity"/>
<state_interface name="acceleration"/>
<state_interface name="velocity">
<param name="initial_value">0.0</param>
</state_interface>
<state_interface name="acceleration">
<param name="initial_value">0.0</param>
</state_interface>
</joint>
<joint name="${prefix}joint6">
<command_interface name="position"> <!-- Add/Remove interfaces as needed -->
Expand All @@ -90,16 +111,32 @@
<state_interface name="position">
<param name="initial_value">0.0</param>
</state_interface>
<state_interface name="velocity"/>
<state_interface name="acceleration"/>
<state_interface name="velocity">
<param name="initial_value">0.0</param>
</state_interface>
<state_interface name="acceleration">
<param name="initial_value">0.0</param>
</state_interface>
</joint>
<sensor name="tcp_fts_sensor"> <!-- Remove/change sensors as needed -->
<state_interface name="fx"/>
<state_interface name="fy"/>
<state_interface name="fz"/>
<state_interface name="tx"/>
<state_interface name="ty"/>
<state_interface name="tz"/>
<state_interface name="fx">
<param name="initial_value">0.0</param>
</state_interface>
<state_interface name="fy">
<param name="initial_value">0.0</param>
</state_interface>
<state_interface name="fz">
<param name="initial_value">0.0</param>
</state_interface>
<state_interface name="tx">
<param name="initial_value">0.0</param>
</state_interface>
<state_interface name="ty">
<param name="initial_value">0.0</param>
</state_interface>
<state_interface name="tz">
<param name="initial_value">0.0</param>
</state_interface>
<param name="frame_id">tool0</param> <!-- Change sensors as needed -->
<param name="min_fx">-100</param>
<param name="max_fx">100</param>
Expand Down
Loading
Loading