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

Add script for node creation and update templates. #213

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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: 30 additions & 0 deletions docs/use-cases/ros_packages/setup_new_node.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
==========================================
Setup ROS 2 node
==========================================
.. _uc-setup-ros-node:

This use-case describes how to set up a new ROS 2 node in an existing package using scripts from ROS Team Workspace (RosTeamWS) framework.

.. note:: currently only C++ nodes and ``ament_cmake`` packages are supported.


Script for Setting up a ROS 2 Node
============================================

``setup-ros-node`` script accepts the file name, and optionally, list of dependencies and class name.
Dependencies are added to ``package.xml`` and ``CMakeLists.txt`` file.

.. note:: it is recommended to setup your package using :ref:`setup-new-package <uc-new-package>` script.

.. warning:: The script **has to be executed** from inside the package where the files should be generated.

The scripts copies template files from the ``templates/nodes`` folder, renames the files, and replaces the placeholders.

.. code-block:: bash
:caption: Usage of script for setting up the robot bringup.
:name: setup-robot-bringup

setup-ros-node FILE_NAME [PKG_DEPS] [CLASS_NAME]


After the files are successfully generated follow the instruction for test-launch of the node.
19 changes: 15 additions & 4 deletions scripts/_RosTeamWs_Defines.bash
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,13 @@ function RosTeamWS_setup_ros2_aliases {

# COLCON
alias cb="colcon_build"
alias cccb="colcon_console_cohesion_build"
alias cbd="colcon_build_debug"
alias cbr="colcon_build_release"
alias cbup="colcon_build_up_to"

alias ct="colcon_test"
alias cnt="colcon_no_test_build"
alias ctup="colcon_test_up_to"

alias ctres="colcon_test_results"
Expand Down Expand Up @@ -216,25 +218,33 @@ function colcon_helper_ros2_up_to {
}

function colcon_build {
colcon_helper_ros2 "colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo" "$*"
colcon_helper_ros2 "colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON" "$*"
}

function colcon_console_cohesion_build {
colcon_helper_ros2 "colcon build --symlink-install --event-handlers console_cohesion+ --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON" "$*"
}

function colcon_build_up_to {
colcon_helper_ros2_up_to "colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo" "$*"
colcon_helper_ros2_up_to "colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON" "$*"
}

function colcon_build_debug {
colcon_helper_ros2 "colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Debug" "$*"
colcon_helper_ros2 "colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Debug --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON" "$*"
}

function colcon_build_release {
colcon_helper_ros2 "colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release" "$*"
colcon_helper_ros2 "colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON" "$*"
}

function colcon_test {
colcon_helper_ros2 "colcon test" "$*"
}

function colcon_no_test_build {
colcon_helper_ros2 "colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON --cmake-args -DBUILD_TESTING=OFF" "$*"
}

function colcon_test_up_to {
colcon_helper_ros2_up_to "colcon test" "$*"
}
Expand Down Expand Up @@ -425,6 +435,7 @@ function set_framework_default_paths {
RosTeamWS_FRAMEWORK_OS_CONFIGURE_PATH="$RosTeamWS_FRAMEWORK_SCRIPTS_PATH/os_configure"
# Script-specific variables
PACKAGE_TEMPLATES="$FRAMEWORK_BASE_PATH/templates/package"
NODE_TEMPLATES="$FRAMEWORK_BASE_PATH/templates/nodes"
ROBOT_DESCRIPTION_TEMPLATES="$FRAMEWORK_BASE_PATH/templates/robot_description"
ROS2_CONTROL_TEMPLATES="$FRAMEWORK_BASE_PATH/templates/ros2_control"
ROS2_CONTROL_HW_ITF_TEMPLATES="$ROS2_CONTROL_TEMPLATES/hardware"
Expand Down
3 changes: 3 additions & 0 deletions scripts/_Team_Defines.bash
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ alias setup-robot-bringup=$RosTeamWS_FRAMEWORK_SCRIPTS_PATH/setup-robot-bringup.

alias setup-robot-description=$RosTeamWS_FRAMEWORK_SCRIPTS_PATH/setup-robot-description.bash

# nodes
alias setup-ros-node=$RosTeamWS_FRAMEWORK_SCRIPTS_PATH/nodes/setup-ros-node.bash

# ros2_control
alias ros2_control_setup-hardware-interface-package=$RosTeamWS_FRAMEWORK_SCRIPTS_PATH/ros2_control/setup-hardware-interface-package.bash
alias ros2_control_setup-controller-package=$RosTeamWS_FRAMEWORK_SCRIPTS_PATH/ros2_control/setup-controller-package.bash
Expand Down
Loading
Loading