-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use husarion-controller from main branch (#116)
* added docker setup for local build * ros2 humble works without custom controllers
- Loading branch information
Showing
5 changed files
with
143 additions
and
8 deletions.
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,2 @@ | ||
SERIAL_PORT=/dev/ttyUSB0 | ||
ROS_NAMESPACE=robot1 |
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,32 @@ | ||
ARG ROS_DISTRO=humble | ||
|
||
FROM husarnet/ros:${ROS_DISTRO}-ros-base | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
WORKDIR /ros2_ws | ||
|
||
COPY . src/ | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
python3-pip \ | ||
stm32flash \ | ||
ros-${ROS_DISTRO}-teleop-twist-keyboard | ||
|
||
RUN vcs import src < src/rosbot/rosbot_hardware.repos && \ | ||
# cp -r src/ros2_controllers/diff_drive_controller src/ && \ | ||
# cp -r src/ros2_controllers/imu_sensor_broadcaster src/ && \ | ||
# rm -rf src/ros2_controllers && \ | ||
rm -r src/rosbot_gazebo | ||
|
||
# Create a script to install runtime dependencies for final image | ||
RUN apt update && \ | ||
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} --reinstall --simulate -y --dependency-types exec >> /rosdep_install.sh && \ | ||
chmod +x /rosdep_install.sh | ||
|
||
RUN apt update && \ | ||
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y && \ | ||
source /opt/ros/$ROS_DISTRO/setup.bash && \ | ||
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release && \ | ||
echo $(cat /ros2_ws/src/rosbot/package.xml | grep '<version>' | sed -r 's/.*<version>([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') >> /version.txt && \ | ||
rm -rf build log src |
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,19 @@ | ||
services: | ||
rosbot: | ||
build: | ||
context: .. | ||
dockerfile: docker/Dockerfile | ||
network_mode: host | ||
ipc: host | ||
devices: | ||
- ${SERIAL_PORT:?err} | ||
- /dev/bus/usb/ # FTDI | ||
# environment: | ||
# - ROS_NAMESPACE | ||
# command: tail -f /dev/null | ||
command: > | ||
ros2 launch rosbot_bringup combined.launch.py | ||
mecanum:=${MECANUM:-False} | ||
serial_port:=$SERIAL_PORT | ||
serial_baudrate:=576000 | ||
# namespace:=${ROS_NAMESPACE:-rosbot} |
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,89 @@ | ||
set dotenv-load # to read ROBOT_NAMESPACE from .env file | ||
|
||
[private] | ||
default: | ||
@just --list --unsorted | ||
|
||
[private] | ||
alias flash := flash-firmware | ||
|
||
[private] | ||
alias teleop := run-teleop-docker | ||
|
||
# run teleop_twist_keybaord (inside rviz2 container) | ||
run-teleop-docker: _run-as-user | ||
#!/bin/bash | ||
docker compose exec rosbot /bin/bash -c "/ros_entrypoint.sh ros2 run teleop_twist_keyboard teleop_twist_keyboard" # --ros-args -r __ns:=/${ROS_NAMESPACE}" | ||
|
||
flash-firmware: _install-yq _run-as-user | ||
#!/bin/bash | ||
echo "Stopping all running containers" | ||
docker ps -q | xargs -r docker stop | ||
|
||
if grep -q "Raspberry Pi" /proc/cpuinfo; then | ||
echo "Setting up Raspberry Pi GPIO Port" | ||
gpio_chip=/dev/gpiochip0 | ||
serial_port=/dev/ttyAMA0 | ||
elif grep -q "Intel(R) Atom(TM) x5-Z8350" /proc/cpuinfo; then | ||
echo "Setting up UpBoard GPIO Port" | ||
gpio_chip=/dev/gpiochip4 | ||
serial_port=/dev/ttyS4 | ||
else | ||
echo "Probably user laptop" | ||
gpio_chip=/dev/bus/usb | ||
serial_port=$SERIAL_PORT | ||
enable_usb="--usb" | ||
fi | ||
|
||
echo "Flashing the firmware for STM32 microcontroller in ROSbot through $serial_port" | ||
docker run --rm -it \ | ||
--device $gpio_chip \ | ||
--device $serial_port \ | ||
docker-rosbot \ | ||
ros2 run rosbot_utils flash_firmware ${enable_usb} | ||
|
||
run: | ||
#/bin/bash | ||
docker compose up | ||
|
||
build: | ||
#/bin/bash | ||
docker compose build | ||
|
||
_run-as-root: | ||
#!/bin/bash | ||
if [ "$EUID" -ne 0 ]; then | ||
echo -e "\e[1;33mPlease re-run as root user to install dependencies\e[0m" | ||
exit 0 | ||
fi | ||
|
||
_run-as-user: | ||
#!/bin/bash | ||
if [ "$EUID" -eq 0 ]; then | ||
echo -e "\e[1;33mPlease re-run as non-root user\e[0m" | ||
exit 0 | ||
fi | ||
|
||
_install-yq: | ||
#!/bin/bash | ||
if ! command -v /usr/bin/yq &> /dev/null; then | ||
if [ "$EUID" -ne 0 ]; then | ||
echo -e "\e[1;33mPlease run as root to install dependencies\e[0m" | ||
exit 0 | ||
fi | ||
|
||
YQ_VERSION=v4.35.1 | ||
ARCH=$(arch) | ||
|
||
if [ "$ARCH" = "x86_64" ]; then | ||
YQ_ARCH="amd64" | ||
elif [ "$ARCH" = "aarch64" ]; then | ||
YQ_ARCH="arm64" | ||
else | ||
YQ_ARCH="$ARCH" | ||
fi | ||
|
||
curl -L https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${YQ_ARCH} -o /usr/bin/yq | ||
chmod +x /usr/bin/yq | ||
echo "yq installed successfully!" | ||
fi |
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