Skip to content

Commit

Permalink
Merge pull request #84 from husarion/ros2-combined-microros
Browse files Browse the repository at this point in the history
included launch for microros
  • Loading branch information
DominikN authored Dec 5, 2023
2 parents 74ff66e + 33e5603 commit 49f33f6
Show file tree
Hide file tree
Showing 15 changed files with 430 additions and 117 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/bump_version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ on:
description: Version to bump (major, minor, patch)
default: patch
required: true
pull_request:
branches: humble
types: [closed]
pull_request:
branches: humble
types: [closed]

jobs:
industrial_ci:
Expand Down
56 changes: 43 additions & 13 deletions .github/workflows/industrial_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,73 @@ on:
workflow_dispatch:
push:


jobs:
black:
name: Black
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
- name: Checkout
uses: actions/checkout@v3
- name: Black
uses: psf/[email protected]
with:
options: --line-length=99

spellcheck:
name: Spellcheck
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: rojopolis/[email protected]
name: Spellcheck
- name: Checkout
uses: actions/checkout@v3
- name: Spellcheck
uses: rojopolis/[email protected]

ros_industrial_ci:
name: ROS Industrial CI
runs-on: ubuntu-22.04
timeout-minutes: 30 # Set the job timeout to 30 minutes
needs:
- black
- spellcheck
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [humble]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3

- name: Act + Docker fix
run: |
sudo chown runner:docker /var/run/docker.sock
- name: Copy to src
run: |
mkdir -p src
find . -maxdepth 1 -not -name src -not -name . -exec mv {} src/ \;
- name: Clone installation requirements
shell: bash
run: python3 -m pip install -U vcstool && vcs import . < ./rosbot/rosbot_hardware.repos && vcs import . < ./rosbot/rosbot_simulation.repos
run: |
python3 -m pip install -U vcstool
vcs import src < src/rosbot/rosbot_hardware.repos && vcs import src < src/rosbot/rosbot_simulation.repos
- name: Copy only diff_drive_controller and imu_sensor_broadcaster, waits for features from ros2-control
shell: bash
run: cp -r ros2_controllers/diff_drive_controller . && cp -r ros2_controllers/imu_sensor_broadcaster . && rm -rf ros2_controllers
- uses: ros-industrial/industrial_ci@master
run: |
cp -r src/ros2_controllers/diff_drive_controller src/
cp -r src/ros2_controllers/imu_sensor_broadcaster src/
rm -rf src/ros2_controllers
# Package micro_ros_msgs does not have industrial ci and tests does not pass.
# For more information see https://github.com/micro-ROS/micro_ros_msgs/issues/7
- name: Remove tests from micro_ros_msgs
shell: bash
run: sed '/if(BUILD_TESTING)/,/endif()/d' src/micro_ros_msgs/CMakeLists.txt -i

- name: Running ROS Industrial CI
uses: ros-industrial/industrial_ci@master
env:
ROS_DISTRO: ${{matrix.ROS_DISTRO}}
DOCKER_IMAGE: ros:${{matrix.ROS_DISTRO}}-ros-base
IMMEDIATE_TEST_OUTPUT: true
6 changes: 6 additions & 0 deletions .wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,9 @@ TODO
delipl
microros
namespaces
fastdds
localhost
SHM
UDPv
CustomUdpTransport
UDPv
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,21 @@ cd src/
black rosbot*
```

### Testing `.github/workflows/industrial_ci.yaml` Locally

At fist install [act](https://github.com/nektos/act):

```
cd /
curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
```

And test the workflow with:

```
act -W .github/workflows/industrial_ci.yaml
```

## Demo
Below you can find demos with ROSbots:
- in [rosbot-docker](https://github.com/husarion/rosbot-docker/tree/ros2) you will find a simple example how to drive ROSbot with `teleop_twist_keyboard`.
Expand Down
8 changes: 8 additions & 0 deletions rosbot/rosbot_hardware.repos
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ repositories:
type: git
url: https://github.com/delihus/ros2_controllers
version: humble-backport
micro_ros_msgs:
type: git
url: https://github.com/micro-ROS/micro_ros_msgs.git
version: humble
micro-ROS-Agent:
type: git
url: https://github.com/micro-ROS/micro-ROS-Agent.git
version: humble
26 changes: 26 additions & 0 deletions rosbot_bringup/config/microros_localhost_only.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--The only purpose of this file is to disable
Fast-DDS SHM transport used by default to use UDPv4-->
<dds>
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
<transport_descriptors>
<transport_descriptor>
<transport_id>CustomUdpTransport</transport_id>
<type>UDPv4</type>
<interfaceWhiteList>
<address>127.0.0.1</address>
</interfaceWhiteList>
</transport_descriptor>
</transport_descriptors>

<participant profile_name="participant_profile" is_default_profile="true">
<rtps>
<userTransports>
<transport_id>CustomUdpTransport</transport_id>
</userTransports>

<useBuiltinTransports>false</useBuiltinTransports>
</rtps>
</participant>
</profiles>
</dds>
117 changes: 117 additions & 0 deletions rosbot_bringup/launch/combined.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Copyright 2023 Husarion
#
# 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_ros.substitutions import FindPackageShare
from launch.actions import (
IncludeLaunchDescription,
DeclareLaunchArgument,
SetEnvironmentVariable,
OpaqueFunction,
)
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import ThisLaunchFileDir, LaunchConfiguration
from launch_ros.actions import Node
import os


def generate_microros_agent_node(context, *args, **kwargs):
# Additional environment variable setup actions
env_setup_actions = []

# Check if ROS_DOMAIN_ID is set and not empty
ros_domain_id = os.environ.get("ROS_DOMAIN_ID")
if ros_domain_id:
env_setup_actions.append(
SetEnvironmentVariable(name="XRCE_DOMAIN_ID_OVERRIDE", value=ros_domain_id)
)

serial_port = LaunchConfiguration("serial_port").perform(context)
serial_baudrate = LaunchConfiguration("serial_baudrate").perform(context)
localhost_only_fastrtps_profiles_file = LaunchConfiguration(
"localhost_only_fastrtps_profiles_file"
).perform(context)

if os.environ.get("ROS_LOCALHOST_ONLY") == "1":
# with localhost only setup fastdds is required with a custom config
rmw_implementation = "rmw_fastrtps_cpp"

env_setup_actions.extend(
[
SetEnvironmentVariable(name="RMW_IMPLEMENTATION", value=rmw_implementation),
SetEnvironmentVariable(
name="FASTRTPS_DEFAULT_PROFILES_FILE",
value=localhost_only_fastrtps_profiles_file,
),
]
)

microros_agent_node = Node(
package="micro_ros_agent",
executable="micro_ros_agent",
arguments=["serial", "-D", serial_port, "-b", serial_baudrate],
output="screen",
)

return env_setup_actions + [microros_agent_node]
else:
microros_agent_node = Node(
package="micro_ros_agent",
executable="micro_ros_agent",
arguments=["serial", "-D", serial_port, "-b", serial_baudrate],
output="screen",
)

return env_setup_actions + [microros_agent_node]


def generate_launch_description():
declare_serial_port_arg = DeclareLaunchArgument(
"serial_port",
default_value="/dev/ttySERIAL",
description="Serial port for micro-ROS agent",
)

declare_serial_baudrate_arg = DeclareLaunchArgument(
"serial_baudrate", default_value="576000", description="Baud rate for serial communication"
)

# Locate the rosbot_bringup package
package_dir = FindPackageShare("rosbot_bringup").find("rosbot_bringup")

# Construct the path to the XML file within the package
fastrtps_profiles_file = os.path.join(package_dir, "config", "microros_localhost_only.xml")

declare_localhost_only_fastrtps_profiles_file_arg = DeclareLaunchArgument(
"localhost_only_fastrtps_profiles_file",
default_value=fastrtps_profiles_file,
description=(
"Path to the Fast RTPS default profiles file for Micro-ROS agent for localhost only"
" setup"
),
)

bringup_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource([ThisLaunchFileDir(), "/bringup.launch.py"])
)

return LaunchDescription(
[
declare_serial_port_arg,
declare_serial_baudrate_arg,
declare_localhost_only_fastrtps_profiles_file_arg,
OpaqueFunction(function=generate_microros_agent_node),
bringup_launch,
]
)
1 change: 1 addition & 0 deletions rosbot_bringup/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<exec_depend>launch_ros</exec_depend>
<exec_depend>rosbot_controller</exec_depend>
<exec_depend>robot_localization</exec_depend>
<exec_depend>micro_ros_agent</exec_depend>

<test_depend>python3-pytest</test_depend>
<test_depend>launch</test_depend>
Expand Down
1 change: 1 addition & 0 deletions rosbot_bringup/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
("share/" + package_name, ["package.xml"]),
(os.path.join("share", package_name, "launch"), glob("launch/*.launch.py")),
(os.path.join("share", package_name, "config"), glob("config/*.yaml")),
(os.path.join("share", package_name, "config"), glob("config/*.xml")),
],
install_requires=["setuptools"],
zip_safe=True,
Expand Down
Loading

0 comments on commit 49f33f6

Please sign in to comment.