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

CI integration #154

Merged
merged 25 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0510b48
create workflow "test.yml"
apmilko May 13, 2024
b3aef12
add hook "check-added-large-files", init pre-commit action
apmilko May 13, 2024
7c4a7bc
update hook "check-added-large-files"
apmilko May 13, 2024
c24cb3b
update hook "check-merge-conflict"
apmilko May 13, 2024
33500ef
add hook "check-xml"
apmilko May 13, 2024
53db069
add hook "check-toml"
apmilko May 13, 2024
d100c8e
add hook "end-of-file-fixer"
apmilko May 13, 2024
611bd83
add hook "mixed-line-ending"
apmilko May 13, 2024
03fc81d
add hook "trailing-whitespace"
apmilko May 13, 2024
521187f
add hook "cmake-format", "cmake-lint"
apmilko May 13, 2024
5f01378
add hook "ruff", "ruff-format"
apmilko May 13, 2024
caad4c2
add hook "clang-format"
apmilko May 13, 2024
ee83f72
update hook "clang-format"
apmilko May 13, 2024
709b4c8
add hook "yamllint"
apmilko May 13, 2024
8ce7630
add hook "check-json", "check-yaml", fix .yaml files
apmilko May 13, 2024
0798261
Merge branch 'master' into apmilko-ci
apmilko May 15, 2024
c80b7db
apply pre-commit to last merge commit
apmilko May 15, 2024
391c1b5
fix pointer alignment in hook "clang-format"
apmilko May 15, 2024
57c1539
set new max line-length for ".yamllint-config.yaml"
apmilko May 15, 2024
d1c8511
add config ".cmake-format.py" for hook "cmake-format"
apmilko May 15, 2024
c6fcd41
update ".clang-format"
apmilko May 15, 2024
d2234e5
update ".clang-format"
apmilko May 15, 2024
a1afea9
Merge branch 'master' into apmilko-ci
apmilko May 15, 2024
3437c5b
Add CI badge to README.md
apmilko May 15, 2024
fa61773
run pre-commit after last merge
apmilko May 15, 2024
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
1 change: 0 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
BasedOnStyle: Google
Language: Cpp

AlignTrailingComments: true
AccessModifierOffset: -2
AlignAfterOpenBracket: AlwaysBreak
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Test

on:
pull_request:
branches: [master]
push:
branches: [master]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
pre-commit:
name: Run pre-commit hooks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with: { python-version: "3.10" }
- uses: pre-commit/action@v3.0.1
45 changes: 45 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
repos:
# Common sanity checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
args: [--enforce-all, --maxkb=12300]
- id: check-merge-conflict
- id: check-xml
- id: check-json
- id: check-yaml
- id: check-toml
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace

# YAML linter
- repo: https://github.com/adrienverge/yamllint
rev: v1.35.1
hooks:
- id: yamllint
exclude: ^.clang-tidy$
args: [--strict, -d, ".yamllint-config.yaml"]

# CMake linter and formatter
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.10
hooks:
- id: cmake-format
- id: cmake-lint

# Python linters & formatters
apmilko marked this conversation as resolved.
Show resolved Hide resolved
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
hooks:
- id: ruff
args: [--fix, --show-fixes]
- id: ruff-format

# C++ formatter
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.6
hooks:
- id: clang-format
types_or: [c, c++]
17 changes: 17 additions & 0 deletions .yamllint-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
rules:
line-length:
max: 180
apmilko marked this conversation as resolved.
Show resolved Hide resolved

quoted-strings:
quote-type: double
required: false

braces:
min-spaces-inside: 1
max-spaces-inside: 1
min-spaces-inside-empty: 0
max-spaces-inside-empty: 0

brackets:
min-spaces-inside-empty: 0
max-spaces-inside-empty: 0
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ ENV PYTORCH_WHL="torch-1.13.0a0+340c4120.nv22.06-cp38-cp38-linux_aarch64.whl"
ENV PYTORCH_URL="https://developer.download.nvidia.com/compute/redist/jp/v50/pytorch/${PYTORCH_WHL}"

RUN wget --no-check-certificate -qO ${PYTORCH_WHL} ${PYTORCH_URL} \
&& pip3 install --no-cache-dir ${PYTORCH_WHL} \
&& pip3 install --no-cache-dir ${PYTORCH_WHL} \
&& rm -rf /tmp/*

RUN wget -qO - https://github.com/pytorch/vision/archive/refs/tags/v${TORCHVISION_VERSION}.tar.gz | tar -xz \
Expand All @@ -243,7 +243,7 @@ RUN wget -qO - https://github.com/IntelRealSense/librealsense/archive/refs/tags/
-DBUILD_WITH_TM2=false \
&& make -j$(($(nproc)-1)) install \
&& rm -rf /tmp/*

FROM --platform=linux/amd64 truck-common AS truck-cuda-amd64

# INSTALL OPENCV
Expand Down Expand Up @@ -443,7 +443,7 @@ RUN cd ${ROS_TMP} \
&& colcon build \
--merge-install \
--install-base ${ROS_ROOT} \
--cmake-args -DBUILD_TESTING=OFF \
--cmake-args -DBUILD_TESTING=OFF \
&& rm -rf /tmp/*

RUN printf "export ROS_ROOT=${ROS_ROOT}\n" >> /root/.bashrc \
Expand All @@ -460,7 +460,7 @@ RUN git clone https://github.com/Slamtec/sllidar_ros2.git \
&& colcon build \
--merge-install \
--install-base ${ROS_ROOT} \
--cmake-args -DBUILD_TESTING=OFF \
--cmake-args -DBUILD_TESTING=OFF \
&& rm -rf /tmp/*

FROM truck-ros AS truck-dev
Expand All @@ -481,7 +481,7 @@ RUN apt-get update -q && \
libeigen3-dev \
libtbb-dev \
libproj-dev \
libsuitesparse-dev \
libsuitesparse-dev \
&& rm -rf /var/lib/apt/lists/* && apt-get clean

ARG LIBNABO_VERSION="1.0.7"
Expand Down
2 changes: 0 additions & 2 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ build_dir:
ackermann_vehicle_svg: build_dir
latex -output-directory build tex/ackermann_vehicle.tex
dvisvgm --no-fonts build/ackermann_vehicle.dvi -o svg/*


4 changes: 1 addition & 3 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
### Overview
- [Ackermann model](ackermann_vehicle.md)
- [Nodes & topics](nodes_and_topics.md)

### Dev
- [Getting started](getting_started.md)
- [Foxglove](foxglove.md)
- [CPP guides](https://github.com/robotics-laboratory/cookbook/blob/master/cpp/style.md)

### Build docs
To rebuild docs run `make` in current dir.


2 changes: 1 addition & 1 deletion doc/foxglove.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ At current moment we use [rosbridge](http://wiki.ros.org/rosbridge_suite) to com
- For local run just use address ```ws://localhost:9090```.

## Layouts
We have several launch configs in package 'truck'. Some layout is prepared for each of them. Freely use it, exporting from repo to foxglove studio.
We have several launch configs in package 'truck'. Some layout is prepared for each of them. Freely use it, exporting from repo to foxglove studio.
8 changes: 4 additions & 4 deletions doc/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ docker-compose up -d truck-jetson
# exit doesn't stop the container
docker exec -it truck bash

# also you
# also you

# stop container
docker stop truck
Expand Down Expand Up @@ -91,18 +91,18 @@ gzclient --verbose
```

## Connecting bluetooth gamepad
Note: you should run the following commands on a host device, not in a docker container.
Note: you should run the following commands on a host device, not in a docker container.
Start bluetoothctl. Enable the agent and set it as default:
```
[bluetooth]# agent on
[bluetooth]# default-agent
```

Power on the Bluetooth controller, and set it as discoverable:
Power on the Bluetooth controller, and set it as discoverable:
```
[bluetooth]# power on
[bluetooth]# discoverable on
[bluetooth]# pairable on
[bluetooth]# pairable on
```

Switch controller to pairing mode:
Expand Down
2 changes: 1 addition & 1 deletion doc/nodes_and_topics.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- `/motion/command` [[truck_interfecase/Control](https://github.com/robotics-laboratory/truck/blob/master/packages/truck_interfaces/msg/Control.msg)] - target of trajectory follower

### Remote control
- `/joy/set_feedback` [[sensos_msgs/JoyFeedback](http://docs.ros.org/en/melodic/api/sensor_msgs/html/msg/JoyFeedback.html)] - joypad input topic (rumble, leds and etc)
- `/joy/set_feedback` [[sensos_msgs/JoyFeedback](http://docs.ros.org/en/melodic/api/sensor_msgs/html/msg/JoyFeedback.html)] - joypad input topic (rumble, leds and etc)
- `/joy` [[sensos_msgs/Joy](http://docs.ros.org/en/melodic/api/sensor_msgs/html/msg/Joy.html)] - joypad output topic

### Control
Expand Down
2 changes: 1 addition & 1 deletion doc/svg/ackermann_vehicle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 17 additions & 17 deletions doc/tex/ackermann_vehicle.tex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
% truck axes
\draw[->, blue, thick] (0,0) -- (4,0) node[black, right] {$x_{truck}$};
\draw[->, blue, thick] (0,0) -- (0,3) node[black, above] {$y_{truck}$};

% base points
\node[fill=blue, opacity=0.4, label=above:{$O$}] at (-3,12) {};
\node[fill=blue, opacity=0.4, label={below right:{$(x,y,\theta,v)$}}] at (0,0) {};
Expand All @@ -26,69 +26,69 @@
% axial guides
\draw[dashed] (-5,-2) -- (6,-2);
\draw[dashed] (-5,2) -- (6,2);

% steering guides
\draw[<->, black, dashed] (-3, 0) -- (-3,12) node[left, midway] {$R_b$};
\draw[black, dashed] (-3, -3) -- (-3,0);
\draw[<->, black, dashed] (-3, 0) -- (-3,12) node[left, midway] {$R_b$};
\draw[black, dashed] (-3, -3) -- (-3,0);

\draw[<->, black, dashed] (0,0) -- (-3,12) node[right, midway] {$R$};
\draw[<->, black, dashed] (3,2) -- (-3,12) node[right, midway] {$R_l$};
\draw[<->, black, dashed] (3,-2) -- (-3,12) node[right, midway] {$R_r$};

% rear tyres
\draw[red, very thick] (-4.0,+1.5) rectangle (-2.0,+2.5);
\draw[red, very thick] (-4.0,-2.5) rectangle (-2.0,-1.5);

% front tires
\draw[red, very thick, shift={(3,2)}, rotate=30.96] (-1.0,-0.5) rectangle (+1.0,+0.5);
\draw[red, very thick, shift={(3,-2)}, rotate=22.85] (-1.0,-0.5) rectangle (+1.0,+0.5);

% front guides
\draw[black, dashed] (3,-3) -- (3,2);
\draw[black, dashed, shift={(3,2)}, rotate=30] (0,0) -- (3,0);
\draw[black, dashed, shift={(3,-2)}, rotate=22.85] (0,0) -- (3,0);

% width
\draw[<->] (-5,-2) -- (-5,2) node[left, midway] {$w$};

% from rear to base
\draw[<->] (-3,0) -- (0,0) node[midway, below right] {$l_b$};

% length
\draw[<->] (-3,-3) -- (3,-3) node[midway, above] {$l$};

% front angles
\fill[green, opacity=0.3] (3,2) -- (4.5,2) arc [start angle=0, end angle=30, radius=1.5];
\node[label=above:{$\delta_l$}] at (3,2) {};

\fill[green, opacity=0.3] (3,-2) -- (4.5,-2) arc [start angle=0, end angle=22.85, radius=1.5];
\node[label=above:{$\delta_r$}] at (3,-2) {};

% path
\draw[->, blue, very thick, opacity=0.3, rotate=14.04] (0,0) arc [start angle=-90, end angle=-40, radius=12.37];
\draw[->, red, very thick, opacity=0.3, shift={(3,2)}, rotate=30.96] (0,0) arc [start angle=-90, end angle=-60,radius=11.66];
\draw[->, red, very thick, opacity=0.3, shift={(3,-2)}, rotate=23.20] (0,0) arc [start angle=-90, end angle=-60,radius=15.23];

% velocity
\draw[->, blue, very thick, rotate=14.04] (0,0) -- (2,0) node[black, midway, above] {$\vec{v}$};
\draw[->, red, very thick] (-3,2) node[black, above]{$v_l$} -- (-1.10,2);
\draw[->, red, very thick] (-3,-2) node[black, above]{$v_r$} -- (-0.90,-2);
\end{scope}

% pose
\draw[dashed] (7,2) -- (7,0) node[fill=blue, opacity=0.4, label=above left:{$x$}] {};
\draw[dashed] (9,2) -- (0,2) node[fill=blue, opacity=0.4, label=above left:{$y$}] {};

\fill[green, opacity=0.3] (7,2) -- (8.5,2) arc [start angle=0, end angle=30, radius=1.5];
\node[label=above:{$\theta$}] at (7, 2) {};

% hints
\draw (12,-1) node[fill=yellow!30, draw, rounded corners] {$v_l = \big(1 + C_b \frac{w}{2} \big) \cdot v_b$};
\draw (12,-2) node[fill=yellow!30, draw, rounded corners] {$v_r = \big(1 - C_b \frac{w}{2} \big) \cdot v_b$};

\draw (5,11) node[fill=yellow!30, draw, rounded corners] {$\delta_l = \arctan \big(|C_b| l, 1 - C_b \frac{w}{2} \big)$};
\draw (5,10) node[fill=yellow!30, draw, rounded corners] {$\delta_r = \arctan \big(|C_b| l, 1 + C_b \frac{w}{2} \big)$};


\draw (0, 4.5) node[fill=yellow!30, draw, rounded corners] {$C_b = \frac{C}{\sqrt{1 - (C l_b)^2}}$};
\draw (0, 3.5) node[fill=yellow!30, draw, rounded corners] {$C = \frac{C_b}{\sqrt{1 + (C_b l_b)^2}}$};
Expand Down
2 changes: 1 addition & 1 deletion layout/pure_pursuit.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@
"direction": "row",
"splitPercentage": 98
}
}
}
44 changes: 21 additions & 23 deletions packages/aruco_localization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,29 @@ find_package(tf2_geometry_msgs REQUIRED)
find_package(tf2_msgs REQUIRED)

add_executable(
aruco_localization
src/aruco_localization.cpp
src/math_helpers.cpp
src/camera_tracker.cpp
src/transform.cpp
src/visualization_helpers.cpp
src/tf_graph.cpp
src/graph_algorithms.cpp
)
aruco_localization
src/aruco_localization.cpp
src/math_helpers.cpp
src/camera_tracker.cpp
src/transform.cpp
src/visualization_helpers.cpp
src/tf_graph.cpp
src/graph_algorithms.cpp)

target_include_directories(aruco_localization PRIVATE include/aruco_localization)
target_include_directories(aruco_localization
PRIVATE include/aruco_localization)
ament_target_dependencies(
${PROJECT_NAME}
cv_bridge
nav_msgs
OpenCV
rclcpp
sensor_msgs
tf2
tf2_geometry_msgs
tf2_msgs
visualization_msgs )
${PROJECT_NAME}
cv_bridge
nav_msgs
OpenCV
rclcpp
sensor_msgs
tf2
tf2_geometry_msgs
tf2_msgs
visualization_msgs)

install(TARGETS
${PROJECT_NAME}
DESTINATION lib/${PROJECT_NAME})
install(TARGETS ${PROJECT_NAME} DESTINATION lib/${PROJECT_NAME})

ament_package()
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@

namespace rosaruco {


class ArucoLocalization : public rclcpp::Node {
public:
public:
ArucoLocalization();

private:
private:
void HandleImage(sensor_msgs::msg::Image::ConstSharedPtr msg);
void UpdateCameraInfo(sensor_msgs::msg::CameraInfo::ConstSharedPtr msg);

Expand All @@ -51,4 +50,4 @@ class ArucoLocalization : public rclcpp::Node {
CameraTracker coordinator_;
};

} // namespace rosaruco
} // namespace rosaruco
Loading