Skip to content

Commit fdb7b1b

Browse files
authored
Merge pull request #74 from ArendJan/develop
2 parents 0b72566 + e355f8b commit fdb7b1b

File tree

4 files changed

+93
-19
lines changed

4 files changed

+93
-19
lines changed

install_ROS2.sh

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,14 @@ if [[ $branch == "develop" || $branch == "main" ]]; then
8686

8787
# Install mirte ros packages with apt from github, since they take ages to compile and it's easier to update them.
8888
# colcon ignore those packages
89-
89+
if [[ $branch == "develop" ]]; then
90+
arch="${arch}_develop"
91+
fi
9092
echo "Using precompiled version of packages"
93+
echo "deb [trusted=yes] $github_url/raw/ros_mirte_${ROS_NAME}_${ubuntu_version}_${arch}/ ./" | sudo tee /etc/apt/sources.list.d/mirte-ros-packages.list
94+
echo "yaml $github_url/raw/ros_mirte_${ROS_NAME}_${ubuntu_version}_${arch}/local.yaml ${ROS_NAME}" | sudo tee /etc/ros/rosdep/sources.list.d/mirte-ros-packages.list
95+
sudo apt update
96+
9197
cd /home/mirte/mirte_ws/src/ || exit 1
9298
ignore=(mirte_telemetrix_cpp mirte_msgs mirte_teleop astra_camera astra_camera_msgs libuvc mirte_base_control mirte_master_arm_control mirte_control usb_cam)
9399
packages=''
@@ -106,14 +112,16 @@ if [[ $branch == "develop" || $branch == "main" ]]; then
106112
fi
107113
touch $path/COLCON_IGNORE
108114
i_dash=$(echo $i | tr '_' '-')
109-
packages="$packages ros-$ROS_NAME-$i_dash"
115+
pkg_name="ros-$ROS_NAME-$i_dash"
116+
# check if dbgsym package exists
117+
sudo apt-cache madison "$pkg_name-dbgsym"
118+
119+
if sudo apt-cache madison "$pkg_name-dbgsym" | grep -vqz "Unable to locate package"; then
120+
echo "Adding debug package $pkg_name-dbgsym"
121+
packages="$packages $pkg_name-dbgsym"
122+
fi
123+
packages="$packages $pkg_name"
110124
done
111-
if [[ $branch == "develop" ]]; then
112-
arch="${arch}_develop"
113-
fi
114-
echo "deb [trusted=yes] $github_url/raw/ros_mirte_${ROS_NAME}_${ubuntu_version}_${arch}/ ./" | sudo tee /etc/apt/sources.list.d/mirte-ros-packages.list
115-
echo "yaml $github_url/raw/ros_mirte_${ROS_NAME}_${ubuntu_version}_${arch}/local.yaml ${ROS_NAME}" | sudo tee /etc/ros/rosdep/sources.list.d/mirte-ros-packages.list
116-
sudo apt update
117125
sudo apt install -y -m $packages || fallback=false # TODO: disabled fallback for now as mirte-arm doesn't compile.
118126
fi
119127

@@ -167,8 +175,6 @@ sudo adduser mirte dialout
167175
# Some nice extra packages: clean can clean workspaces and packages. No need to do it by hand. lint can check for errors in the cmake/package code.
168176
sudo pip3 install colcon-clean colcon-lint
169177

170-
# Add colcon top level workspace, this makes it possible to run colcon build from any folder, it will find the workspace and build it. Otherwise it will create a new workspace in the subdirectory.
171-
172178
if [[ $MIRTE_TYPE == "mirte-master" ]]; then
173179
# TODO: need to check and edit the next part:
174180
sudo apt install ros-$ROS_NAME-slam-toolbox -y
@@ -207,12 +213,9 @@ if [[ $MIRTE_TYPE == "mirte-master" ]]; then
207213

208214
fi
209215

210-
cd /tmp
211-
git clone https://github.com/rhaschke/colcon-top-level-workspace
212-
cd colcon-top-level-workspace
213-
pip install .
214-
cd ..
215-
rm -rf colcon-top-level-workspace
216+
# Add colcon top level workspace, this makes it possible to run colcon build from any folder, it will find the workspace and build it. Otherwise it will create a new workspace in the subdirectory.
217+
pip install git+https://github.com/arendjan/colcon-top-level-workspace.git
218+
216219
# zsh does not work nicely with ros2 autocomplete, so we need to add a function to fix it.
217220
# ROS 2 Foxy should have this fixed, but we are using ROS 2 Humble.
218221
# TODO: check for ROS2 jazzy

install_arduino.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export PICO_SDK_PATH=$MIRTE_SRC_DIR/pico/pico-sdk
4242
add_rc "export PICO_SDK_PATH=$MIRTE_SRC_DIR/pico/pico-sdk"
4343
git clone https://github.com/raspberrypi/picotool.git --depth=1 # shallow clone to save space
4444
cd picotool || exit 1
45-
sudo cp udev/99-picotool.rules /etc/udev/rules.d/
45+
sudo cp udev/*.rules /etc/udev/rules.d/
4646

4747
mkdir build
4848
cd build || exit 1

network_setup.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/bin/bash
2+
MIRTE_SRC_DIR=/usr/local/src/mirte
3+
4+
($MIRTE_SRC_DIR/mirte-install-scripts/services/mirte_auto_dhcp_eth.sh || true) &
25

36
# wait for wlan0 to be up, with max 30 seconds
47
TIMEOUT=30
@@ -131,8 +134,6 @@ function file_empty() {
131134

132135
}
133136

134-
MIRTE_SRC_DIR=/usr/local/src/mirte
135-
136137
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf || true
137138

138139
# Create unique SSID

services/mirte_auto_dhcp_eth.sh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env bash
2+
3+
# nm dispatcher is whack and not running reliably or without the interface name.
4+
5+
# this script repeatedly checks eth0, when it goes up, wait for a few seconds
6+
# if no ip assigned: start dnsmasq
7+
# if ip assigned:don't do anything
8+
# when eth0 goes down, kill dnsmasq if started
9+
10+
set -xe
11+
12+
# start dnsmasq
13+
SUBNET=45
14+
interface=eth0
15+
16+
dnsmasq_pid=$(pgrep -f "dnsmasq --address=/#/192.168.$SUBNET.1") || true
17+
18+
function cleanup {
19+
has_dhcp=false
20+
echo "Cleaning up..."
21+
if [ -n "$dnsmasq_pid" ]; then
22+
echo "Stopping dnsmasq with PID $dnsmasq_pid"
23+
sudo kill "$dnsmasq_pid" || true
24+
dnsmasq_pid=""
25+
else
26+
echo "No dnsmasq process found."
27+
fi
28+
sudo ip address del 192.168."$SUBNET".1/24 dev eth0 || true
29+
# exit 0
30+
echo "Cleanup complete."
31+
# exit 0
32+
}
33+
34+
function start_dhcp {
35+
cleanup
36+
has_dhcp=true
37+
sudo ip address add 192.168."$SUBNET".1/24 dev eth0
38+
sudo dnsmasq --address=/#/192.168."$SUBNET".1 --dhcp-range=192.168."$SUBNET".10,192.168."$SUBNET".100 --conf-file --domain-needed --bogus-priv --server=8.8.8.8 --dhcp-option=option:dns-server,8.8.8.8 --interface="$interface" --except-interface=lo --bind-interfaces -p0 --dhcp-leasefile=/tmp/dnsmasq.leases
39+
dnsmasq_pid=$(pgrep -f "dnsmasq --address=/#/192.168.$SUBNET.1")
40+
}
41+
42+
function check_up {
43+
is_up=$(ip addr show $interface | grep -q "state UP" && echo true || echo false)
44+
has_ip=$(ip addr show $interface | grep -q "inet " && echo true || echo false)
45+
if [ "$is_up" = false ]; then
46+
SECONDS=0
47+
elif [ $SECONDS -gt 10 ] && [ "$has_ip" = false ]; then
48+
echo "Interface $interface has been up for more than 10 seconds."
49+
echo "No IP address assigned, starting DHCP server."
50+
start_dhcp
51+
fi
52+
}
53+
54+
function check_down {
55+
is_up=$(ip addr show $interface | grep -q "state UP" && echo true || echo false)
56+
if [ "$is_up" = false ] && [ "$has_dhcp" = true ]; then
57+
echo "Interface $interface is down, stopping DHCP server."
58+
cleanup
59+
fi
60+
}
61+
62+
trap cleanup EXIT
63+
64+
is_up=false
65+
has_dhcp=false
66+
while true; do
67+
check_up
68+
check_down
69+
sleep 5
70+
done

0 commit comments

Comments
 (0)