-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhardware_stack.sh
More file actions
82 lines (67 loc) · 2.05 KB
/
hardware_stack.sh
File metadata and controls
82 lines (67 loc) · 2.05 KB
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
#!/bin/bash
# ...save as start_hardware_stack.sh...
# Set your CAN interface name here, or pass as argument
CAN_IFACE="${CAN_IFACE:-can0}"
# Check CAN interface variable
if [ -z "$CAN_IFACE" ]; then
echo "Error: CAN_IFACE environment variable not set."
exit 1
fi
# Bring up CAN interface at 500000 baud
echo "Bringing up $CAN_IFACE at 500000 baud..."
sudo ip link set $CAN_IFACE down 2>/dev/null
sudo ip link set $CAN_IFACE type can bitrate 500000
sudo ip link set $CAN_IFACE up
if [ $? -ne 0 ]; then
echo "Error: Failed to bring up $CAN_IFACE"
exit 1
fi
# Wait a couple seconds
sleep 2
# Set ROS_DOMAIN_ID (change as needed)
export ROS_DOMAIN_ID=${ROS_DOMAIN_ID:-0}
echo "ROS_DOMAIN_ID set to $ROS_DOMAIN_ID"
# Launch first container
echo "Launching first container..."
docker compose -f docker/docker-compose-hardware.yml up
if [ $? -ne 0 ]; then
echo "Error: Failed to launch first container."
exit 1
fi
# Wait for the first container to be running
echo "Waiting for first container to be running..."
for i in {1..10}; do
status=$(docker inspect -f '{{.State.Running}}' r2m_4wd_diff_drive_odrive 2>/dev/null)
if [ "$status" == "true" ]; then
echo "First container is running."
break
fi
sleep 1
done
if [ "$status" != "true" ]; then
echo "Error: First container did not start."
exit 1
fi
# Launch second container (example, replace with your actual service name)
SECOND_CONTAINER=my_second_container
echo "Launching second container..."
docker compose -f docker/docker-compose-hardware.yml up -d $SECOND_CONTAINER
if [ $? -ne 0 ]; then
echo "Error: Failed to launch second container."
exit 1
fi
# Wait for confirmation (container running)
echo "Waiting for second container to be running..."
for i in {1..10}; do
status2=$(docker inspect -f '{{.State.Running}}' $SECOND_CONTAINER 2>/dev/null)
if [ "$status2" == "true" ]; then
echo "Second container is running."
break
fi
sleep 1
done
if [ "$status2" != "true" ]; then
echo "Error: Second container did not start."
exit 1
fi
echo "Both containers are running. Finished."