-
rv2_startup
rv2_startup βββ content β βββ scripts β β βββ cyclonedds.xml β β βββ run-internet-check.sh β β βββ run-network-check.sh β βββ packages.yaml (generated by `update-repo-list`) βββ launch β βββ scripts β β βββ <package_name>_<id> (generated by `create`) β β β βββ .config (if package uses `config_file` instead of `params_file`) β β β βββ cyclonedds.xml (generated by `create-service`) β β β βββ params.yaml β β β βββ system.yaml β β β βββ ... β β βββ ... β βββ services β βββ rv2_startup_<package_name>_<id>.service (generated by `create-service`) β βββ ... βββ log β βββ <YYYY_MM_DD>.log (generated by `setup.sh`) βββ setup.sh βββ config.yaml (Grab from FTP server) βββREADME.md
-
RV2 Package Structure
rv2_ros2_ws (ROS2 workspace) βββ src β βββ <rv2_package> β β βββ include/<package_name> β β β βββ ... β β βββ launch β β β βββ launch.py β β βββ params (or config) β β β βββ params.yaml β β β βββ system.yaml (optional) β β βββ scripts β β β βββ custom.sh (optional) β β β βββ script_after_build.sh (optional) β β β βββ script_before_build.sh (optional) β β β βββ source_env.sh (optional) β β βββ src β β β βββ ... β β βββ CMakeLists.txt β β βββ package.xml β β βββ requirements_apt.txt (optional) β β βββ requirements_pip.txt (optional) β β βββ ... β βββ ... βββ ...
NOTE: If the package is a non-launchable package, the
launch
andparams
directories will not be used.NOTE: If the package is a non-launchable package, the
custom.sh
andsource_env.sh
scripts will not be used.NOTE: If the package use
config
instead ofparams
directory, the.config
file will be generated in the package launcher directory, and the andros2 launch
command will use theconfig_file
argument instead ofparams_file
. -
Global Packages
Now the package launcher support the global packages that follows the
rv2_package
structure. The global packages usually placed in the/opt/ros/${ROS_DISTRO}/shared
directory.NOTE: The global packages will not be built by the
build
command.WARNING: User should avoid using same package name in the global packages and the ROS2 workspace.
-
Non-launchable Packages
The non-launchable packages may be the interface packages that contains ROS2 interfaces such as
msg
,srv
etc., or component packages for nodes. The non-launchable packages can becreate
andbuild
but notcreate-service
since the packages are not a launchable package.To
create
a non-launchable package or component, add the--pkg-no-launch
flag to the command. The created directory will be empty.NOTE: If
--pkg-no-launch
provided, the--pkg-id
flag is not required, and the package launcher name will be<package_name>_nolaunch
.
-
Package Launcher: A package launcher is a directory that contains the
params.yaml
andsystem.yaml
files. The package launcher is used to manage the ROS2 package and theservice
. The package launcher name should be composed of thepackage name
and the ID:<package_name>_<id>
. -
Service: A
systemd
service file that manages the package launcher. The service file name should be composed of the package name and the ID:rv2_startup_<package_name>_<id>.service
. -
Package Name: A ROS2 package name defined in the
package.xml
. should be under the repository directory. -
Repository Name: A repository directory name. A repository directory contains one or more ROS2 packages.
- OS: Ubuntu 22.04
- ROS2: Humble
-
Setup the environment using
curl
curl -fsSL ftp://61.220.23.239/rv2-example/deploy.sh | bash
The package will be installed in
${HOME}/rv2_startup
. -
Setup the environment using
git
-
Install required packages
sudo apt update sudo apt install -y python3-yaml
-
Clone the repository
git clone https://github.com/cocobird231/rv2_startup.git ${HOME}/rv2_startup
-
Grab
config.yaml
wget -O ${HOME}/rv2_startup/config.yaml ftp://61.220.23.239/rv2-example/config.yaml
WARNING: The
rv2_startup
directory should be placed in the home directory. -
-
Config the
config.yaml
file in${HOME}/rv2_startup
. Set theROS2_WS_PATH
to the ROS2 workspace path. If FTP server is used, set theFTP_SERVER_PATH
andFTP_SERVER_REPO_VERSION
properly.# config.yaml ENVIRONMENT_SETUP: ROS2_WS_PATH: "~/rv2_ros2_ws" FTP_SERVER_PATH: "" FTP_SERVER_REPO_VERSION: ""
-
Update the repository list from the FTP server. (Optional)
. setup.sh update-repo-list
-
Update the repositories under the ROS2 workspace source directory. (Optional)
. setup.sh update-repos
The package launcher name should be composed of the package name and the ID: <package_name>_<id>
. The <package_name>
is the ROS2 package name defined in the package.xml
, and the <id>
is the unique ID of the package launcher.
-
Create a new package launcher.
. setup.sh create --pkg-name <package_name> --pkg-id <id>
The package launcher directory
<package_name>_<id>
will be created in therv2_startup/launch/scripts
, and the files under repositoryparams
directory will be copied to the package launcher directory.NOTE: If the package is not for launch, add the
--pkg-no-launch
flag to the command. The created directory will be empty. -
Config the
system.yaml
file in the package launcher directory. Set thenetwork
field properly.# system.yaml launch: params: "params.yaml" launch: "launch.py" use_root: false network: interface: "eth0" internet_required: false
The
interface
should be the network interface that the program will use. Ifinternet_required
set totrue
, the program will check the internet connection before starting the program.NOTE: Ignore this step if the package is an non-launchable package.
-
Create a systemd service and runfile. The service will be enabled after service creation.
. setup.sh create-service --pkg-name <package_name> --pkg-id <id>
The service file
rv2_startup_<package_name>_<id>.service
will be created inrv2_startup/launch/services
directory, andrunfile.sh
will be created in the package launcher directory.NOTE: Ignore this step if the package is an non-launchable package.
-
Build the ROS2 workspace.
. setup.sh build
The ROS2 workspace will be built accrording to the packages in the
rv2_startup/launch/scripts
. The global packages will not be built. -
Start the service, or reboot the system to start the service automatically.
sudo systemctl start rv2_startup_<package_name>_<id>.service
WARNING: The service will fail to start if the package is not built.
NOTE: The order of step 3 and 4 can be swapped. The step 4 could be ignored if all the package launchers are using global packages.
-
Remove the
<package_name>_<id>
package launcher.. setup.sh remove --pkg-name <package_name> --pkg-id <id>
The package launcher directory
<package_name>_<id>
will be removed from therv2_startup/launch/scripts
, and the service will be removed, the service filerv2_startup_<package_name>_<id>.service
will be removed from therv2_startup/launch/services
.NOTE: If want to keep the package launcher directory, use the
remove-service
command instead ofremove
to remove the service only.NOTE: If want to remove all the package launchers, use the
--all
flag instead of--pkg-name
and--pkg-id
.
If the package launcher directory <package_name>_<id>
exists, run the following command to re-create the service.
. setup.sh create-service --pkg-name <package_name> --pkg-id <id>
The remove-service
will be called before creating the service.
-
Show more information while running the setup script.
. setup.sh --debug
NOTE: The
--debug
option controls the debug message printed in the terminal. The debug message will always be written to the log files. -
The log files located at
${HOME}/rv2_startup/log/<YYYY_MM_DD>.log
. -
If using
--gui-mode
, the log messages will formed with specific prefixes, suffixes, and delimiters. The mode is designed for the GUI application for easier parsing the log messages to the GUI.
- Show the logs of the
rv2_startup_<package_name>_<id>.service
.sudo journalctl -u rv2_startup_<package_name>_<id>.service
The config.yaml
file is used to define the package launcher settings. The file should be placed in the ${HOME}/rv2_startup
directory.
ENVIRONMENT_SETUP:
ROS2_WS_PATH: "~/rv2_ros2_ws"
FTP_SERVER_PATH: ""
FTP_SERVER_REPO_VERSION: ""
# The following parameters are used to search the ROS2 package under global shared directory.
ROS2_SHARE_PKG_NAME_REGEX:
RV2_PKG_NAME_REGEX: "^rv2_[a-z0-9_]+"
# Customized package name regex can be added here.
ROS2_WS_PATH
(string): The path to the ROS2 workspace. (Required)FTP_SERVER_PATH
(string): The path to the FTP server. (Optional)FTP_SERVER_REPO_VERSION
(string): The version of the repository on the FTP server. (Optional)RV2_PKG_NAME_REGEX
(string): The regular expression to search the ROS2 package under the global shared directory. (Optional)
WARNING: If the FTP_XXX
not set properly, the restore-repos
, update-repos
and update-repo-list
commands will not work, and list
can only use scripts
and services
. The rest of the commands will work normally.
The packages.yaml
file is stored under rv2_startup/content
directory. The file describes the repositories that can be tracked and fetched from online git servers.
The packages.yaml
file can be generated by the update-repo-list
command, users can also manually create the file with the following format:
packages:
rv2_package_example:
description: "RV2 Example Package"
url: "https://github.com/cocobird231/rv2_package_example.git"
packages:
- rv2_package_example
<repo_name>:
description: "Some description"
url: "<git repository url>"
packages:
- <package_name>
- <package_name2>
- <package_name3>
NOTE: The <repo_name>
will be the directory name while fetching the repository into the ROS2 workspace source directory.
NOTE: The <package_name>
should be the ROS2 package name defined in the package.xml
.
NOTE: If the packages.yaml
is customized, do not run the update-repo-list
command, or the file will be overwritten.
-
--pkg-name <package_name>
:The name of the ROS2 package (Defined in
package.xml
). The name should follow the regular expression[a-z0-9_-]+
. -
--pkg-id <id>
:The unique ID of the package launcher. The ID must fit the regular expression
[a-zA-Z0-9\.]+
. The ID should follow the regular expression[a-zA-Z0-9\.]+
. -
--pkg-no-launch
:Set the flag if
<package_name>
package is not for launch. The--pkg-id
flag is not required if the flag is provided, and the package launcher name will be<package_name>_nolaunch
.WARNING: The package can not create a service since the package is not a launchable package.
-
create {--pkg-name <package_name>} {--pkg-id <id>|--pkg-no-launch}
:Create a new package launcher. The package launcher directory
<package_name>_<id>
will be created in therv2_startup/launch/scripts
, and the file underparams
directory will be copied to the package launcher directory.WARNING: If the package is not for launch, use the
--pkg-no-launch
flag. The directory<package_name>_nolaunch
will be created in therv2_startup/launch/scripts
, and the directory will be empty. -
create-service {--pkg-name <package_name>} {--pkg-id <id>}
:Create a systemd service.
- First run
custom.sh
if exists in the repositoryscripts
directory. - Create
runfile.sh
in the package launcher directory. Ifsource_env.sh
exists in the repositoryscripts
directory, thesource_env.sh
will be appended to therunfile.sh
before theros2 launch
command. - Create a systemd service file
rv2_startup_<package_name>_<id>.service
in therv2_startup/launch/services
directory.
WARNING: The
system.yaml
file should be placed in the package launcher directory, and thenetwork
field should be set properly.WARNING: The command does not support the non-launchable package (package created with
--pkg-no-launch
flag).WARNING: The command will remove the service if the service already exists. The service will be enabled after service creation.
- First run
-
remove-service {{--pkg-name <package_name>} {--pkg-id <id>}|--all}
:Remove a systemd service. The service and file of
rv2_startup_<package_name>_<id>.service
will be removed, and therunfile.sh
will be removed from the package launcher directory.--all
: Remove all the services without specifying the package name and ID.
-
remove {{--pkg-name <package_name>} {--pkg-id <id>}|--all}
:Remove a package launcher. The
remove-service
command will be executed before removing the package launcher directory.--all
: Remove all the package launchers without specifying the package name and ID.
-
build [--clean] [--depend]
:Build the ROS2 workspace. The ROS2 workspace will be built according to the packages in the
rv2_startup/launch/scripts
.--clean
: Clean thebuild
,install
andlog
directories before building.--depend
: Force install the dependencies before building (includerosdep install
).
-
restore-repos
:Restore the repositories under the ROS2 workspace source directory. The repositories will be restored according to the
packages.yaml
file which is generated underrv2_startup/content
by theupdate-repo-list
command.WARNING: This command will not modify the repositories which are not listed in the
packages.yaml
file.WARNING: The changes in the repositories will be lost after running this command.
-
update-repos [--clean]
:Update the repositories under the ROS2 workspace source directory. The repositories will be updated according to the
packages.yaml
file which is generated underrv2_startup/content
by theupdate-repo-list
command.--clean
: Clean the repositories before updating.
WARNING: This command will not modify the repositories which are not listed in the
packages.yaml
file.WARNING: Without the
--clean
option, the changes in the repositories will be kept after running this command. -
update-repo-list
:Update the repository list from the FTP server. The
packages.yaml
file will be generated underrv2_startup/content
.WARNING: The
FTP_SERVER_PATH
andFTP_SERVER_REPO_VERSION
should be set properly in theconfig.yaml
file. -
list {all|pkgs|scripts|services}
:List the package launchers and repositories.
-
all
: List all the package launchers and repositories. The printed information:<pkg_launcher_name> <pkg_launcher_status> <package_name> <package_status>
<pkg_launcher_name>
(string): The package launcher directory.<pkg_launcher_status>
(0|1): 0 for no service, 1 for service installed.<package_name>
(string): The ROS2 package name.<package_status>
(0|1|2|3):- 0: Package in global share.
- 1: Custom package in local src.
- 2: Package tracked (in packages.yaml) but not fetched.
- 3: Package fetched.
-
pkgs
: List the repositories. The printed information:<package_name> <package_status>
<package_name>
(string): The ROS2 package name.<package_status>
(0|1|2|3):- 0: Package in global share.
- 1: Custom package in local src.
- 2: Package tracked (in packages.yaml) but not fetched.
- 3: Package fetched.
-
scripts
: List the package launchers. The printed information:<pkg_launcher_name> ... <pkg_launcher_name>
-
services
: List the package launchers that have services. The printed information:<pkg_launcher_name> ... <pkg_launcher_name>
-
-
--gui-mode
:The flag will formed the output and log messages with specific prefixes, suffixes, and delimiters. The mode is designed for the GUI application for easier parsing the log messages to the GUI.
-
--debug
:Print more information while running the setup script. The debug message will always be written to the log files.