Skip to content

Commit

Permalink
Add controller config path (#70)
Browse files Browse the repository at this point in the history
* Add controller_config_path arg

* Add deprecated info

* Readme update

* pre-commit

* spellcheck

* Use pre-commit action instead spellcheck

* Black inside pre-commit

* Remove local repos from pre-commit

* Update version

* Fix noise
  • Loading branch information
rafal-gorecki authored May 15, 2024
1 parent 7a1388e commit fd6d730
Show file tree
Hide file tree
Showing 15 changed files with 301 additions and 220 deletions.
23 changes: 7 additions & 16 deletions .github/workflows/industrial_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,19 @@ on:


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

spellcheck:
name: Spellcheck
pre-commit:
name: pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: rojopolis/spellcheck-github-actions@0.33.1
name: Spellcheck
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: pre-commit/action@v3.0.1

ros_industrial_ci:
name: ROS Industrial CI
needs:
- black
- spellcheck
- pre-commit
strategy:
fail-fast: false
matrix:
Expand All @@ -37,7 +28,7 @@ jobs:
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup ROS2 Workspace and Clone Repositories
run: |
Expand Down
35 changes: 18 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,26 @@ repos:
- id: isort
args: [--profile, black]

- repo: local
hooks:
- id: ament_lint_cmake
name: ament_lint_cmake
description: Check format of CMakeLists.txt files.
entry: ament_lint_cmake
language: system
files: CMakeLists\.txt$
# Need to figure out how o check local repos in action
# - repo: local
# hooks:
# - id: ament_lint_cmake
# name: ament_lint_cmake
# description: Check format of CMakeLists.txt files.
# entry: ament_lint_cmake
# language: system
# files: CMakeLists\.txt$

- repo: local
hooks:
- id: ament_copyright
name: ament_copyright
description: Check if copyright notice is available in all files.
stages: [commit]
entry: ament_copyright
language: system
# - repo: local
# hooks:
# - id: ament_copyright
# name: ament_copyright
# description: Check if copyright notice is available in all files.
# stages: [commit]
# entry: ament_copyright
# language: system

# Docs - RestructuredText hooks
# Docs - RestructuredText hooks
- repo: https://github.com/PyCQA/doc8
rev: v1.1.1
hooks:
Expand Down
101 changes: 0 additions & 101 deletions .wordlist.txt

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ You can find ROS API and detailed package description in [ROS_API.md](./ROS_API.

```bash
source install/setup.bash
ros2 launch rosbot_xl_bringup combined.launch.py
ros2 launch rosbot_xl_bringup bringup.launch.py
```

> [!IMPORTANT]
Expand Down
4 changes: 2 additions & 2 deletions ROS_API.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Package that contains launch, which starts all base functionalities with the mic

**Available Launch Files:**

- `bringup.launch.py` - is responsible for activating all logic related to the robot's movement and processing of sensory data.
- `combined.launch.py` - launches `bringup.launch.py` ​​and communication with the firmware allows you to control the robot.
- `bringup.launch.py` - is responsible for communicating with firmware and activating all logic related to the robot's movement and processing of sensory data.
- `microros.launch.py` - establishes connection with the firmware.

**Launch Params:**

Expand Down
21 changes: 20 additions & 1 deletion rosbot_xl_bringup/launch/bringup.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
from launch.conditions import UnlessCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from launch.substitutions import (
LaunchConfiguration,
PathJoinSubstitution,
PythonExpression,
ThisLaunchFileDir,
)
from launch_ros.actions import Node, SetParameter
from launch_ros.substitutions import FindPackageShare

Expand Down Expand Up @@ -90,6 +96,12 @@ def generate_launch_description():
description="Which simulation engine will be used",
)

combined_launch_deprecated = LaunchConfiguration("combined_launch_deprecated")
declare_combined_launch_deprecated_arg = DeclareLaunchArgument(
"combined_launch_deprecated",
default_value="False",
)

rosbot_xl_controller = FindPackageShare("rosbot_xl_controller")
rosbot_xl_bringup = FindPackageShare("rosbot_xl_bringup")

Expand Down Expand Up @@ -150,6 +162,11 @@ def generate_launch_description():
namespace=namespace,
)

microros_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource([ThisLaunchFileDir(), "/microros.launch.py"]),
condition=UnlessCondition(PythonExpression([use_sim, " or ", combined_launch_deprecated])),
)

return LaunchDescription(
[
declare_namespace_arg,
Expand All @@ -159,7 +176,9 @@ def generate_launch_description():
declare_include_camera_mount_arg,
declare_use_sim_arg,
declare_simulation_engine_arg,
declare_combined_launch_deprecated_arg,
SetParameter(name="use_sim_time", value=use_sim),
microros_launch,
controller_launch,
robot_localization_node,
laser_filter_node,
Expand Down
6 changes: 6 additions & 0 deletions rosbot_xl_bringup/launch/combined.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,15 @@ def generate_launch_description():
"lidar_model": lidar_model,
"camera_model": camera_model,
"include_camera_mount": include_camera_mount,
"combined_launch_deprecated": LaunchConfiguration(
"combined_launch_deprecated", default=True
),
}.items(),
)

print(
"\033[93m[WARN] [launch]: combined.launch.py will be is deprecated and will be removed please use bringup.launch.py instead.\033[0m"
)
return LaunchDescription(
[
declare_port_arg,
Expand Down
102 changes: 102 additions & 0 deletions rosbot_xl_bringup/launch/microros.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Copyright 2024 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.

import os

from launch import LaunchDescription
from launch.actions import (
DeclareLaunchArgument,
LogInfo,
OpaqueFunction,
SetEnvironmentVariable,
)
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare


def generate_microros_agent_node(context, *args, **kwargs):
env_setup_actions = []

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)
)

port = LaunchConfiguration("port").perform(context)

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

if os.environ.get("ROS_LOCALHOST_ONLY") == "1":
env_setup_actions.extend(
[
LogInfo(
msg=[
"ROS_LOCALHOST_ONLY set to 1. Using FASTRTPS_DEFAULT_PROFILES_FILE=",
localhost_only_fastrtps_profiles_file,
".",
]
),
SetEnvironmentVariable(name="RMW_IMPLEMENTATION", value="rmw_fastrtps_cpp"),
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=["udp4", "--port", port],
output="screen",
)

return env_setup_actions + [microros_agent_node]


def generate_launch_description():
declare_port_arg = DeclareLaunchArgument(
"port",
default_value="8888",
description="UDP4 port for micro-ROS agent",
)

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

# Construct the path to the XML file within the package
fastrtps_profiles_file = PathJoinSubstitution(
[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"
),
)

return LaunchDescription(
[
declare_port_arg,
declare_localhost_only_fastrtps_profiles_file_arg,
OpaqueFunction(function=generate_microros_agent_node),
]
)
Loading

0 comments on commit fd6d730

Please sign in to comment.