-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
165 lines (142 loc) · 5.03 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
set dotenv-load
[private]
default:
@just --list --unsorted
[private]
alias husarnet := connect-husarnet
[private]
alias flash := flash-firmware
[private]
alias rosbot := start-rosbot
[private]
alias pc := start-pc
[private]
alias joy := run-joy
[private]
alias teleop := run-teleop
[private]
alias teleop-docker := run-teleop-docker
[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
# connect to Husarnet VPN network
connect-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}}
# Copy repo content to remote host with 'rsync' and watch for changes
sync hostname="${ROBOT_NAMESPACE}" password="husarion": _install-rsync _run-as-user
#!/bin/bash
mkdir -m 775 -p maps
sshpass -p "{{password}}" rsync -vRr --exclude='.git/' --exclude='maps/' --delete ./ husarion@{{hostname}}:/home/husarion/${PWD##*/}
while inotifywait -r -e modify,create,delete,move ./ --exclude='.git/' --exclude='maps/' ; do
sshpass -p "{{password}}" rsync -vRr --exclude='.git/' --exclude='maps/' --delete ./ husarion@{{hostname}}:/home/husarion/${PWD##*/}
done
# flash the proper firmware for STM32 microcontroller in ROSbot XL
flash-firmware: _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
# start containers on a physical ROSbot XL
start-rosbot: _run-as-user
#!/bin/bash
mkdir -m 775 -p maps
docker compose down
docker compose pull
docker compose up
# start containers on PC
start-pc: _run-as-user
#!/bin/bash
xhost +local:docker
docker compose -f compose.pc.yaml up ros2router rviz ffmpeg_decoder
# start containers on PC
run-joy: _run-as-user
#!/bin/bash
xhost +local:docker
docker compose -f compose.pc.yaml up joy2twist
# run teleop_twist_keybaord (host)
run-teleop:
#!/bin/bash
. .env.local
ros2 run teleop_twist_keyboard teleop_twist_keyboard # --ros-args -r __ns:=/${ROBOT_NAMESPACE}
# run teleop_twist_keybaord (inside rviz2 container)
run-teleop-docker:
#!/bin/bash
docker compose -f compose.pc.yaml exec rviz /bin/bash -c "/ros_entrypoint.sh ros2 run teleop_twist_keyboard teleop_twist_keyboard"
_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
# source ROS 2 workspace
config:
#!/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
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