-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnect.sh
More file actions
executable file
·31 lines (26 loc) · 1.05 KB
/
connect.sh
File metadata and controls
executable file
·31 lines (26 loc) · 1.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
#!/bin/bash
set -e
# Color definitions
GREEN="\e[0;32m"
RED="\e[0;31m"
NC="\e[0m"
# Find all potential drone simulation containers
CONTAINERS=$(docker ps --filter "name=ros2_drone" --format "{{.ID}} {{.Names}}")
if [ -z "$CONTAINERS" ]; then
echo -e "${RED}Error: No running drone simulation containers found${NC}"
echo "Please run ./start.sh first to start the simulation environment"
exit 1
fi
# If multiple containers found, let user choose
container_count=$(echo "$CONTAINERS" | wc -l)
if [ "$container_count" -gt 1 ]; then
echo "Multiple containers found:"
echo "$CONTAINERS" | nl
read -p "Select container number (1-$container_count): " selection
CONTAINER_ID=$(echo "$CONTAINERS" | sed -n "${selection}p" | cut -d' ' -f1)
else
CONTAINER_ID=$(echo "$CONTAINERS" | cut -d' ' -f1)
fi
# Connect to the container with ROS2 environment
echo -e "${GREEN}Connecting to drone simulation environment...${NC}"
docker exec -it $CONTAINER_ID bash -c "source /opt/ros/humble/setup.bash && source /root/ros2_ws/install/setup.bash && exec bash"