-
Notifications
You must be signed in to change notification settings - Fork 0
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 #1 from husarion/dev
Implement CRSF teleop
- Loading branch information
Showing
21 changed files
with
986 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
name: Build/Publish Docker Image | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: tag that the image will be built with | ||
required: true | ||
default: humble | ||
branch: | ||
description: branch that will be used to build image | ||
required: true | ||
default: master | ||
|
||
jobs: | ||
build_ros: | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v1 | ||
with: | ||
ref: ${{ github.event.inputs.branch }} | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
with: | ||
version: latest | ||
|
||
- name: Login to Docker Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: docker.io | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push crsf_teleop image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
platforms: linux/arm64, linux/amd64 | ||
push: true | ||
tags: husarion/crsf-teleop:${{ github.event.inputs.tag }} |
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,11 @@ | ||
--- | ||
name: Pre-Commit | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
pre-commit: | ||
uses: ros-controls/ros2_control_ci/.github/workflows/reusable-pre-commit.yml@master | ||
with: | ||
ros_distro: humble |
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 @@ | ||
**/__pycache__ |
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,99 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.6.0 | ||
hooks: | ||
- id: check-added-large-files | ||
# mesh files has to be taken into account | ||
args: ["--maxkb=3000"] | ||
- id: check-ast | ||
- id: check-json | ||
# vscode .json files do not follow the standard JSON format | ||
exclude: ^.vscode/ | ||
- id: check-merge-conflict | ||
- id: check-symlinks | ||
- id: check-xml | ||
- id: check-yaml | ||
- id: debug-statements | ||
- id: destroyed-symlinks | ||
- id: detect-private-key | ||
- id: end-of-file-fixer | ||
- id: fix-byte-order-marker | ||
- id: name-tests-test | ||
- id: mixed-line-ending | ||
- id: trailing-whitespace | ||
|
||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.13.2 | ||
hooks: | ||
- id: isort | ||
args: ["--profile", "black"] | ||
|
||
- repo: https://github.com/cheshirekow/cmake-format-precommit | ||
rev: v0.6.13 | ||
hooks: | ||
- id: cmake-format | ||
|
||
- repo: https://github.com/pre-commit/mirrors-clang-format | ||
rev: v18.1.8 | ||
hooks: | ||
- id: clang-format | ||
|
||
- repo: https://github.com/codespell-project/codespell | ||
rev: v2.3.0 | ||
hooks: | ||
- id: codespell | ||
name: codespell | ||
description: Checks for common misspellings in text files. | ||
entry: codespell | ||
args: | ||
[ | ||
"--ignore-words-list", | ||
"ned" # north, east, down (NED) | ||
] | ||
exclude_types: [rst, svg] | ||
language: python | ||
types: [text] | ||
|
||
- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt | ||
rev: 0.2.3 | ||
hooks: | ||
- id: yamlfmt | ||
files: ^.github|./\.yaml | ||
args: [--mapping, '2', --sequence, '4', --offset, '2', --width, '100'] | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 24.8.0 | ||
hooks: | ||
- id: black | ||
args: ["--line-length=99"] | ||
|
||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 7.1.1 | ||
hooks: | ||
- id: flake8 | ||
args: | ||
["--ignore=E501,W503"] # ignore too long line and line break before binary operator, | ||
# black checks it | ||
|
||
- 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 | ||
- repo: https://github.com/PyCQA/doc8 | ||
rev: v1.1.1 | ||
hooks: | ||
- id: doc8 | ||
args: ["--max-line-length=100", "--ignore=D001"] | ||
exclude: ^.*\/CHANGELOG\.rst/.*$ | ||
|
||
- repo: https://github.com/tier4/pre-commit-hooks-ros | ||
rev: v0.10.0 | ||
hooks: | ||
- id: prettier-package-xml | ||
- id: sort-package-xml |
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,25 @@ | ||
ARG ROS_DISTRO=humble | ||
FROM husarnet/ros:${ROS_DISTRO}-ros-core | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
WORKDIR /ros2_ws | ||
|
||
COPY . src/husarion_ugv_crsf_teleop | ||
RUN apt-get update --fix-missing && \ | ||
apt upgrade -y && \ | ||
apt-get install -y ros-dev-tools && \ | ||
rm -rf /etc/ros/rosdep/sources.list.d/20-default.list && \ | ||
rosdep init && \ | ||
rosdep update --rosdistro $ROS_DISTRO && \ | ||
rosdep install -i --from-path src --rosdistro $ROS_DISTRO -y && \ | ||
source /opt/ros/$ROS_DISTRO/setup.bash && \ | ||
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release && \ | ||
rm -rf build log && \ | ||
export SUDO_FORCE_REMOVE=yes && \ | ||
apt-get remove -y ros-dev-tools && \ | ||
apt-get autoremove -y && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
CMD ["ros2", "launch", "husarion_ugv_crsf_teleop", "teleop.launch.py"] |
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 |
---|---|---|
@@ -1 +1,43 @@ | ||
# husarion_ugv_crsf_teleop | ||
# husarion_ugv_crsf_teleop | ||
|
||
This ROS 2 package allows you to control robots using a CRSF compatible remote control. A receiver should be connected to the robot's computer via USB-UART converter or be integrated as a hardware USB dongle. The CRSF protocol parser is implemented based on the following [specification](https://github.com/crsf-wg/crsf/wiki). | ||
|
||
## Launch Files | ||
|
||
- `teleop.launch.py`: Launches crsf_teleop_node node. Automatically respawns node if it exits. Node's namespace can be set using the `namespace` launch argument. | ||
|
||
## Configuration Files | ||
|
||
- [`crsf_teleop.yaml`](./config/crsf_teleop.yaml): Sets default parameter values for the crsf_teleop_node when `teleop.launch.py` is launched. | ||
|
||
## ROS Nodes | ||
|
||
### crsf_teleop_node | ||
|
||
Translates received CRSF commands to velocity commands for the robot. | ||
|
||
The following channels are used for controlling the robot via the TX16S remote control: | ||
- Channel 2 - Right gimbal up/down - forward/backward velocity | ||
- Channel 4 - Left gimbal left/right - turning (angular) velocity | ||
- Channel 5 - SF switch - emergency stop | ||
- Channel 7 - SA switch (down position) - silence `cmd_vel` messages, allows other nodes to control the robot while enabling e_stop functionality | ||
- Channel 11 - SG switch - tristate switch, selects robot speed | ||
|
||
#### Publishes | ||
|
||
- `cmd_vel` [*geometry_msgs/Twist*]: Publishes velocity commands to the robot. | ||
- `link_status` [*panther_crsf_teleop_msgs/LinkStatus*]: Describes radio link status between the remote control and the robot. Parameters are described in the [CRSF_FRAMETYPE_LINK_STATISTICS frame documentation](https://github.com/crsf-wg/crsf/wiki/CRSF_FRAMETYPE_LINK_STATISTICS). | ||
|
||
#### Service Clients | ||
|
||
- `hardware/e_stop_trigger` [*std_srvs/Trigger*]: Triggers an emergency stop. | ||
- `hardware/e_stop_reset` [*std_srvs/Trigger*]: Triggers an emergency stop reset. | ||
|
||
#### Parameters | ||
|
||
- `serial_port` [*string*, default: **/dev/ttyUSB0**]: Serial port to which the CRSF receiver is connected. | ||
- `baudrate` [*int*, default: **576000**]: Baudrate of the serial port. | ||
- `e_stop_republish` [*bool*, default: **False**]: Rebroadcasts asserted emergency stop signal once per second. Will override other emergency stop sources. | ||
- `enable_cmd_vel_silence_switch`[*bool*, default: **False**]: Enables remote to disable publishing `cmd_vel` messages on demand. Can be used as a remote emergency stop when using other nodes to control the robot. | ||
- `linear_speed_presets` [*double_array*, default: **[0.5, 1.0, 2.0]**]: Selectable robot maximum linear speed for `cmd_vel` topic. | ||
- `angular_speed_presets` [*double_array*, default: **[0.5, 1.0, 2.0]**]: Selectable robot maximum angular speed for the `cmd_vel` topic. |
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,16 @@ | ||
services: | ||
husarion_ugv_crsf_teleop: | ||
image: husarion/crsf-teleop:humble | ||
network_mode: host | ||
ipc: host | ||
pid: host | ||
restart: unless-stopped | ||
privileged: true | ||
environment: | ||
- RMW_IMPLEMENTATION=${RMW_IMPLEMENTATION:-rmw_cyclonedds_cpp} | ||
- ROS_DOMAIN_ID=${ROS_DOMAIN_ID:-0} | ||
devices: | ||
- /dev/ttyUSBPAD | ||
command: > | ||
ros2 launch husarion_ugv_crsf_teleop teleop.launch.py | ||
port:=/dev/ttyUSBPAD namespace:=panther |
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,15 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(husarion_ugv_crsf_interfaces) | ||
|
||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-Wall -Wextra -Wpedantic) | ||
endif() | ||
|
||
find_package(ament_cmake REQUIRED) | ||
find_package(rosidl_default_generators REQUIRED) | ||
find_package(std_msgs REQUIRED) | ||
|
||
rosidl_generate_interfaces(${PROJECT_NAME} "msg/LinkStatus.msg" DEPENDENCIES | ||
rosidl_default_generators std_msgs) | ||
|
||
ament_package() |
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,11 @@ | ||
std_msgs/Header header | ||
int16 rssi_1 | ||
int16 rssi_2 | ||
uint8 lq | ||
int8 uplink_snr | ||
uint8 used_antenna | ||
uint8 mode | ||
uint8 tx_power | ||
int16 downlink_rssi | ||
uint8 downlink_lq | ||
int8 downlink_snr |
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,27 @@ | ||
<?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>husarion_ugv_crsf_interfaces</name> | ||
<version>1.0.0</version> | ||
<description>Custom messages for the CRSF teleop node</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/husarion_ugv_crsf_teleop</url> | ||
<url type="bugtracker">https://github.com/husarion/husarion_ugv_crsf_teleop/issues</url> | ||
|
||
<author email="milosz.lagan@husarion.com">Milosz Lagan</author> | ||
|
||
<buildtool_depend>ament_cmake</buildtool_depend> | ||
|
||
<depend>std_msgs</depend> | ||
|
||
<build_depend>rosidl_default_generators</build_depend> | ||
<exec_depend>rosidl_default_runtime</exec_depend> | ||
<member_of_group>rosidl_interface_packages</member_of_group> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</package> |
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,9 @@ | ||
/**: | ||
crsf_teleop_node: | ||
ros__parameters: | ||
port: /dev/ttyUSB0 | ||
baud: 576000 | ||
e_stop_republish: false | ||
enable_cmd_vel_silence_switch: false | ||
linear_speed_presets: [0.5, 1.0, 2.0] | ||
angular_speed_presets: [0.5, 1.0, 2.0] |
Empty file.
Empty file.
Oops, something went wrong.