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 firmware flash utilities and microros #58

Merged
merged 23 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
3 changes: 3 additions & 0 deletions .github/workflows/industrial_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ jobs:
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
sed '/if(BUILD_TESTING)/,/endif()/d' src/micro_ros_msgs/CMakeLists.txt -i

- uses: ros-industrial/industrial_ci@master
env:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ rosbot_hardware_interfaces/
ros_components_description/
rosbot_controllers/
husarion/husarion_office_gz
micro-ROS-Agent/
micro_ros_msgs/
industrial_ci/
ros2_controllers/
diff_drive_controller/
imu_sensor_broadcaster/
Expand Down
3 changes: 0 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,3 @@ repos:
rev: 1.0.0
hooks:
- id: xmllint
args:
- --schema
- http://download.ros.org/schema/package_format3.xsd
15 changes: 15 additions & 0 deletions .wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ utils
tf
yaml
odometry
pyftdi
usbutils
CustomUdpTransport
UDPv
SHM
UDPv
laggy
CBUS
cbus
ftdi
RST
url
subprocess
Ftdi
Microros
namespaces
namespace
delihus
Expand Down
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Metapackage that contains dependencies to other repositories. It is also used to

### `rosbot_xl_bringup`

Package that contains launch, which starts all base functionalities. Also configs for `robot_localization` and `laser_filters` are defined there.
Package that contains launch, which starts all base functionalities with the microros agent. Also configs for `robot_localization` and `laser_filters` are defined there.

### `rosbot_xl_description`

Expand All @@ -32,6 +32,10 @@ Launch files for Ignition Gazebo working with ROS2 control.

ROS2 hardware controller for ROSbot XL. Inputs and outputs data from ROS2 control and forwards it via ROS topic to be read by microros.

### `rosbot_xl_utils`

This package contains the stable firmware version with the flash script.

## ROS API

Available in [ROS_API.md](./ROS_API.md)
Expand Down Expand Up @@ -67,13 +71,19 @@ source /opt/ros/$ROS_DISTRO/setup.bash

vcs import src < src/rosbot_xl/rosbot_xl_hardware.repos

# Remove tests from micro_ros_msgs
sed '/if(BUILD_TESTING)/,/endif()/d' src/micro_ros_msgs/CMakeLists.txt -i

rm -r src/rosbot_xl_gazebo

# Copy only diff_drive_controller and imu_sensor_broadcaster, waits for features from ros2-control
cp -r src/ros2_controllers/diff_drive_controller src/
cp -r src/ros2_controllers/imu_sensor_broadcaster src/
rm -rf src/ros2_controllers

# stm32flash is not in the ros index and should be installed manually
sudo apt install stm32flash

rosdep init
rosdep update --rosdistro $ROS_DISTRO
rosdep install -i --from-path src --rosdistro $ROS_DISTRO -y
Expand All @@ -84,9 +94,19 @@ colcon build
> Before starting the software on the robot please make sure that you're using the latest firmware and run the `micro-ROS` agent as described in the [Usage on hardware](#usage-on-hardware) step.

2. **Running**

Flash firmware.
```bash
# Get admin permissions to flash firmware
sudo su
source install/setup.bash
ros2 run rosbot_xl_utils flash_firmware
exit
```

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

### Build and run Gazebo simulation
Expand All @@ -100,6 +120,9 @@ source /opt/ros/$ROS_DISTRO/setup.bash
vcs import src < src/rosbot_xl/rosbot_xl_hardware.repos
vcs import src < src/rosbot_xl/rosbot_xl_simulation.repos

# Remove tests from micro_ros_msgs
sed '/if(BUILD_TESTING)/,/endif()/d' src/micro_ros_msgs/CMakeLists.txt -i

# Copy only diff_drive_controller and imu_sensor_broadcaster, waits for features from ros2-control
cp -r src/ros2_controllers/diff_drive_controller src/
cp -r src/ros2_controllers/imu_sensor_broadcaster src/
Expand Down
8 changes: 8 additions & 0 deletions rosbot_xl/rosbot_xl_hardware.repos
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ repositories:
type: git
url: https://github.com/husarion/ros_components_description.git
version: ros2
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
rosbot_controllers:
type: git
url: https://github.com/husarion/rosbot_controllers
Expand Down
26 changes: 26 additions & 0 deletions rosbot_xl_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="https://raw.githubusercontent.com/eProsima/Fast-DDS/master/resources/xsd/fastRTPS_profiles.xsd">
<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>
166 changes: 166 additions & 0 deletions rosbot_xl_bringup/launch/combined.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# 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.

from launch import LaunchDescription
from launch_ros.substitutions import FindPackageShare
from launch.actions import (
IncludeLaunchDescription,
DeclareLaunchArgument,
LogInfo,
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):
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",
)

mecanum = LaunchConfiguration("mecanum")
declare_mecanum_arg = DeclareLaunchArgument(
"mecanum",
default_value="False",
description=(
"Whether to use mecanum drive controller (otherwise diff drive controller is used)"
),
)

camera_model = LaunchConfiguration("camera_model")
declare_camera_model_arg = DeclareLaunchArgument(
"camera_model",
default_value="None",
description="Add camera model to the robot URDF",
choices=[
"None",
"intel_realsense_d435",
"orbbec_astra",
"stereolabs_zed",
"stereolabs_zedm",
"stereolabs_zed2",
"stereolabs_zed2i",
"stereolabs_zedx",
"stereolabs_zedxm",
],
)

lidar_model = LaunchConfiguration("lidar_model")
declare_lidar_model_arg = DeclareLaunchArgument(
"lidar_model",
default_value="slamtec_rplidar_s1",
description="Add LiDAR model to the robot URDF",
choices=[
"None",
"slamtec_rplidar_a2",
"slamtec_rplidar_a3",
"slamtec_rplidar_s1",
"slamtec_rplidar_s2",
"slamtec_rplidar_s3",
"velodyne_puck",
],
)

include_camera_mount = LaunchConfiguration("include_camera_mount")
declare_include_camera_mount_arg = DeclareLaunchArgument(
"include_camera_mount",
default_value="False",
description="Whether to include camera mount to the robot URDF",
)

# 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 = 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"]),
launch_arguments={
"mecanum": mecanum,
"lidar_model": lidar_model,
"camera_model": camera_model,
"include_camera_mount": include_camera_mount,
}.items(),
)

return LaunchDescription(
[
declare_port_arg,
declare_localhost_only_fastrtps_profiles_file_arg,
declare_mecanum_arg,
declare_camera_model_arg,
declare_lidar_model_arg,
declare_include_camera_mount_arg,
OpaqueFunction(function=generate_microros_agent_node),
bringup_launch,
]
)
4 changes: 4 additions & 0 deletions rosbot_xl_bringup/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@

<exec_depend>laser_filters</exec_depend>
<exec_depend>robot_localization</exec_depend>
<exec_depend>micro_ros_agent</exec_depend>

<!-- Microros agent build dependency-->
<build_depend>git</build_depend>

<test_depend>rclpy</test_depend>
<test_depend>python3-pytest</test_depend>
Expand Down
1 change: 1 addition & 0 deletions rosbot_xl_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
Binary file added rosbot_xl_utils/firmware/firmware-v1.4.0.bin
Binary file not shown.
33 changes: 33 additions & 0 deletions rosbot_xl_utils/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>rosbot_xl_utils</name>
<version>0.8.12</version>
<description>Utilities for ROSbot XL</description>

<maintainer email="support@husarion.com">Husarion</maintainer>

<license>Apache License 2.0</license>

<url type="website">https://husarion.com/</url>
<url type="repository">https://github.com/husarion/rosbot_xl_ros</url>
<url type="bugtracker">https://github.com/husarion/rosbot_xl_ros/issues</url>

<author email="jakub.delicat@husarion.com">Jakub Delicat</author>

<exec_depend>python3-sh</exec_depend>
<exec_depend>python-periphery-pip</exec_depend>
<exec_depend>python3-pyftdi-pip</exec_depend>
<exec_depend>usbutils</exec_depend>
<exec_depend>python3-serial</exec_depend>
<exec_depend>python3-requests</exec_depend>

<test_depend>ament_copyright</test_depend>
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>python3-pytest</test_depend>

<export>
<build_type>ament_python</build_type>
</export>
</package>
Empty file.
Empty file.
Loading
Loading