-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from husarion/ros2-combined-microros
included launch for microros
- Loading branch information
Showing
15 changed files
with
430 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,3 +125,9 @@ TODO | |
delipl | ||
microros | ||
namespaces | ||
fastdds | ||
localhost | ||
SHM | ||
UDPv | ||
CustomUdpTransport | ||
UDPv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.