Skip to content

Commit

Permalink
Merge branch 'main' into planner_node
Browse files Browse the repository at this point in the history
  • Loading branch information
rdyro authored Jul 10, 2023
2 parents 604cf57 + 0a7a5cb commit 3036bc6
Show file tree
Hide file tree
Showing 68 changed files with 3,386 additions and 563 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/foxy.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .github/workflows/humble.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ jobs:
uses: ros-tooling/setup-ros@v0.5
with:
required-ros-distributions: humble
- name: Install dependencies
run: pip install black
- name: ROS2 build and test
uses: ros-tooling/action-ros-ci@v0.2
with:
import-token: ${{ secrets.GITHUB_TOKEN }}
target-ros2-distro: humble
skip-tests: true
5 changes: 3 additions & 2 deletions .github/workflows/rolling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
build_docker:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
container:
image: ubuntu:jammy
steps:
Expand All @@ -18,9 +18,10 @@ jobs:
uses: ros-tooling/setup-ros@v0.5
with:
required-ros-distributions: rolling
- name: Install dependencies
run: pip install black
- name: ROS2 build and test
uses: ros-tooling/action-ros-ci@v0.2
with:
import-token: ${{ secrets.GITHUB_TOKEN }}
target-ros2-distro: rolling
skip-tests: true
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.vscode
.vscode/*
.history/


# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
58 changes: 53 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# freeflyer2
![foxy build](https://github.com/StanfordASL/freeflyer2/actions/workflows/foxy.yml/badge.svg?event=push)
![humble build](https://github.com/StanfordASL/freeflyer2/actions/workflows/humble.yml/badge.svg?event=push)
![rolling build](https://github.com/StanfordASL/freeflyer2/actions/workflows/rolling.yml/badge.svg?event=push)

ASL FreeFlyer software stack with ROS2. See build status for support on ROS2 distrbutions.

## Quick Start
1. Install ROS2 ([Foxy](https://docs.ros.org/en/foxy/Installation.html),
[Humble](https://docs.ros.org/en/humble/Installation.html), or
1. Install ROS2 (
[Humble](https://docs.ros.org/en/humble/Installation.html) or
[Rolling](https://docs.ros.org/en/rolling/Installation.html))
2. Clone the repo into a ROS2 workspace, e.g.
```sh
Expand All @@ -18,19 +17,68 @@ git clone git@github.com:StanfordASL/freeflyer2.git ~/ff_ws/src/freeflyer2
```sh
rosdep update && rosdep install --from-paths ~/ff_ws/src --ignore-src -y
```
4. Build the code
4. Build the code (skipping the driver package)
```sh
cd ~/ff_ws && colcon build
cd ~/ff_ws && colcon build --packages-skip ff_drivers
```

5. Source workspace install
```sh
source ~/ff_ws/install/local_setup.bash
```

## Development Guide
The CI will build and run all registered tests. PR can be merged only when all status checks
pass. [ROS2 code styles](https://docs.ros.org/en/humble/The-ROS2-Project/Contributing/Code-Style-Language-Versions.html)
are enforced for C++. Python code style is enforced through `black`.
Here are some tips for fixing code style issues for a PR.

Run the following command to manually run all tests and see detailed test results including
format violation
```sh
$ colcon build && colcon test && colcon test-result --verbose
```

#### Copyright
Every source file (e.g. `.cpp`, `.hpp`, `.py`) including launch files should have a copy of
the license at the very top. See any source files for an example.

#### C++ Code Style
1. Run `ament_uncrustify --reformat` to automatically format C++ source files.
2. Run `ament_cpplint` to check for style violations and fix them manually.

#### Python Code Style
Please install `black` with `pip install black` for the first time.

Importantly
- to format all Python code with black automatically run
```sh
$ cd freeflyer2
$ black .
```
- to check formatting without changing the files run
```sh
$ cd freeflyer2
$ black --check .
```

#### Disable Code Style Test
If you hate the ROS2 conventions so bad, you can disable specific code style test by adding
the following line before `ament_lint_auto_find_test_dependencies()` in `CMakeLists.txt`.
```cmake
set(AMENT_LINT_AUTO_EXCLUDE <test1> [<test2> ...])
```
For example, if you want to disable code style checks for all Python files, you can add
```cmake
set(AMENT_LINT_AUTO_EXCLUDE ament_cmake_flake8 ament_cmake_pep257)
```

## Package Layout

* `freeflyer` -- top level pacakge (contains just launch files)
* `ff_estimate` -- implement different state estimators
* `ff_control` -- implement different controllers
* `ff_drivers` -- driver code that interfaces with hardware
* `ff_msgs` -- custom message types
* `ff_params` -- shared parameters about dynamics and actuators
* `ff_sim` -- a lightweight pure Python simulator
Expand Down
38 changes: 23 additions & 15 deletions ff_control/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_python REQUIRED)
find_package(eigen3_cmake_module REQUIRED)
find_package(Eigen3)
find_package(geometry_msgs REQUIRED)
Expand All @@ -25,11 +26,13 @@ ament_target_dependencies(ctrl_lib rclcpp ff_msgs ff_params Eigen3)
ament_export_targets(ctrl_libTarget HAS_LIBRARY_TARGET)
ament_export_dependencies(rclcpp ff_msgs ff_params Eigen3 eigen3_cmake_module)

# install headers
install(
DIRECTORY include/
DESTINATION include
)

# install CPP libraries
install(
TARGETS ctrl_lib
EXPORT ctrl_libTarget
Expand All @@ -39,28 +42,33 @@ install(
INCLUDES DESTINATION include
)

add_executable(wrench_ctrl_node src/nodes/wrench_ctrl_node.cpp)
target_link_libraries(wrench_ctrl_node ctrl_lib)
add_executable(wrench_ctrl_cpp_node src/nodes/wrench_ctrl_node.cpp)
target_link_libraries(wrench_ctrl_cpp_node ctrl_lib)

add_executable(pd_ctrl_node src/nodes/pd_ctrl_node.cpp)
target_link_libraries(pd_ctrl_node ctrl_lib)
ament_target_dependencies(pd_ctrl_node geometry_msgs)
add_executable(pd_ctrl_cpp_node src/nodes/pd_ctrl_node.cpp)
target_link_libraries(pd_ctrl_cpp_node ctrl_lib)
ament_target_dependencies(pd_ctrl_cpp_node geometry_msgs)

add_executable(key_teleop_node src/nodes/key_teleop_node.cpp)
target_link_libraries(key_teleop_node ctrl_lib)
add_executable(key_teleop_cpp_node src/nodes/key_teleop_node.cpp)
target_link_libraries(key_teleop_cpp_node ctrl_lib)

install(TARGETS wrench_ctrl_node pd_ctrl_node key_teleop_node
# install CPP nodes
install(TARGETS wrench_ctrl_cpp_node pd_ctrl_cpp_node key_teleop_cpp_node
DESTINATION lib/${PROJECT_NAME})

# install Python libraries
ament_python_install_package(${PROJECT_NAME})

# install Python nodes
install(PROGRAMS
scripts/pd_ctrl_py_node
DESTINATION lib/${PROJECT_NAME}
)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# comment the line when a copyright and license is added to all source files
set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# comment the line when this package is in a git repo and when
# a copyright and license is added to all source files
set(ament_cmake_cpplint_FOUND TRUE)
# disable Python style checkers
set(AMENT_LINT_AUTO_EXCLUDE ament_cmake_flake8 ament_cmake_pep257)
ament_lint_auto_find_test_dependencies()
endif()

Expand Down
21 changes: 21 additions & 0 deletions ff_control/ff_control/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License
#
# Copyright (c) 2023 Stanford Autonomous Systems Lab
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
Loading

0 comments on commit 3036bc6

Please sign in to comment.