-
Notifications
You must be signed in to change notification settings - Fork 1
/
justfile
171 lines (145 loc) · 5.85 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
set dotenv-load
[private]
default:
@just --list --unsorted
[private]
pre-commit:
#!/bin/bash
if ! command -v pre-commit &> /dev/null; then
pip install pre-commit
pre-commit install
fi
pre-commit run -a
# [PC/ROSbot] connect to Husarnet VPN network
husarnet joincode hostname: _run-as-root
#!/bin/bash
if ! command -v husarnet > /dev/null; then
echo "Husarnet is not installed. Installing now..."
curl https://install.husarnet.com/install.sh | bash
fi
husarnet join {{joincode}} {{hostname}}
# [PC] Copy repo content to remote host with 'rsync' and watch for changes
sync hostname="${SYNC_HOSTNAME}" password="husarion": _install-rsync _run-as-user
#!/bin/bash
sshpass -p "{{password}}" rsync -vRr --exclude='.git/' --delete ./ husarion@{{hostname}}:/home/husarion/${PWD##*/}
while inotifywait -r -e modify,create,delete,move ./ --exclude='.git/' ; do
sshpass -p "{{password}}" rsync -vRr --exclude='.git/' --delete ./ husarion@{{hostname}}:/home/husarion/${PWD##*/}
done
# [ROSbot] flash the proper firmware for STM32 microcontroller in ROSbot XL
flash: _install-yq _run-as-user
#!/bin/bash
echo "Stopping all running containers"
docker ps -q | xargs -r docker stop
echo "Flashing the firmware for STM32 microcontroller in ROSbot"
docker run \
--rm -it \
--device /dev/ttyUSBDB \
--device /dev/bus/usb/ \
$(yq .services.rosbot.image compose.yaml) \
ros2 run rosbot_xl_utils flash_firmware --port /dev/ttyUSBDB
# flash-firmware.py -p /dev/ttyUSBDB # todo
# [ROSbot] setup udevs for managing OAK-1 USB camera permissions
udev:
#!/bin/bash
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="03e7", MODE="0666"' | sudo tee /etc/udev/rules.d/80-movidius.rules
sudo udevadm control --reload-rules && sudo udevadm trigger
# [ROSbot] start containers on a physical ROSbot XL
rosbot: _run-as-user
#!/bin/bash
mkdir -p maps
docker compose -f compose.rosbot.yaml down
docker compose -f compose.rosbot.yaml up
# [ROSbot] start containers on a physical ROSbot XL (without Nav2)
rosbot-navless: _run-as-user
#!/bin/bash
docker compose -f compose.rosbot-navless.yaml down
docker compose -f compose.rosbot-navless.yaml up
# [ROSbot] start containers on a physical ROSbot XL (with Foxglove)
rosbot-foxglove: _run-as-user
#!/bin/bash
docker compose -f compose.rosbot-foxglove.yaml down
docker compose -f compose.rosbot-foxglove.yaml up
# [ROSbot] start containers on a physical ROSbot XL (wthout Nav2, with Foxglove)
rosbot-navless-foxglove: _run-as-user
#!/bin/bash
docker compose -f compose.rosbot-navless-foxglove.yaml down
docker compose -f compose.rosbot-navless-foxglove.yaml up
# [PC] start RViz
rviz: _run-as-user
#!/bin/bash
xhost +local:docker
docker compose -f compose.rviz.yaml down
docker compose -f compose.rviz.yaml up
# [PC] start RQT Image View with keyboard teleop and joy2twist
teleop: _run-as-user
#!/bin/bash
xhost +local:docker
docker compose -f compose.teleop.yaml down
docker compose -f compose.teleop.yaml up -d --wait
docker compose -f compose.teleop.yaml exec teleop bash -c "/ros_entrypoint.sh ros2 run teleop_twist_keyboard teleop_twist_keyboard"
docker compose -f compose.teleop.yaml down
# [PC] dock
dock: _run-as-user
#!/bin/bash
docker compose -f compose.rosbot.yaml run --rm --no-deps docking bash -c "ros2 action send_goal /dock_robot opennav_docking_msgs/action/DockRobot '{dock_id: home_dock}'"
# [PC] undock
undock: _run-as-user
#!/bin/bash
docker compose -f compose.rosbot.yaml run --rm --no-deps docking bash -c "ros2 action send_goal /undock_robot opennav_docking_msgs/action/UndockRobot '{dock_type: simple_charging_dock}'"
# [PC/ROSbot] optimize DDS settings; Use if you experience stability issues.
dds-tunning:
#!/bin/bash
# https://fast-dds.docs.eprosima.com/en/latest/fastdds/use_cases/large_data/large_data.html#
# https://docs.ros.org/en/humble/How-To-Guides/DDS-tuning.html
sudo sysctl -w net.core.wmem_max=12582912
sudo sysctl -w net.core.rmem_max=12582912
sudo sysctl -w net.core.wmem_default=16384000
sudo sysctl -w net.core.rmem_default=16384000
sudo sysctl -w net.ipv4.ipfrag_high_thresh=134217728 # (128 MB)
sudo sysctl -w net.ipv4.ipfrag_time=3
sudo sysctl -w net.ipv6.ip6frag_time=3 # 3s
sudo sysctl -w net.ipv6.ip6frag_high_thresh=134217728 # (128 MB)
sudo ip link set txqueuelen 500 dev hnet0
sudo ip link set dev hnet0 mtu 1350
# sudo ip link set dev hnet0 mtu 9000
_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 1
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 1
fi
_install-rsync:
#!/bin/bash
if ! command -v rsync &> /dev/null || ! command -v sshpass &> /dev/null || ! command -v inotifywait &> /dev/null; then
if [ "$EUID" -ne 0 ]; then
echo -e "\e[1;33mPlease run as root to install dependencies\e[0m"
exit 1
fi
apt install -y rsync sshpass inotify-tools
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 1
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