Aufgeräumt
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
# Base image
|
||||
FROM ros:melodic
|
||||
|
||||
ENV TZ=Europe/Amsterdam
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
# Basic tools
|
||||
RUN apt-get update && \
|
||||
apt-get install vim nano git tmux wget curl python-pip net-tools iputils-ping -y
|
||||
|
||||
# Install additional ros packages
|
||||
RUN apt-get update && apt-get install ros-melodic-rosbridge-server ros-melodic-joy -y
|
||||
RUN apt-get update && apt-get install python-smbus -y
|
||||
RUN pip install adafruit-pureio
|
||||
RUN pip install Adafruit-GPIO==1.0.3 --no-deps
|
||||
RUN pip install Adafruit-PCA9685==1.0.1 --no-deps
|
||||
|
||||
|
||||
# Install packages for camera use
|
||||
RUN apt-get update && \
|
||||
apt-get install ros-melodic-web-video-server ros-melodic-usb-cam -y
|
||||
|
||||
# Add ros sourcing to bashrc
|
||||
RUN echo ". /opt/ros/melodic/setup.bash" >> ~/.bashrc
|
||||
|
||||
# Create Ros workspace
|
||||
ENV EXOMY_WS=/root/exomy_ws
|
||||
RUN mkdir -p $EXOMY_WS/src
|
||||
|
||||
WORKDIR /root
|
||||
|
||||
COPY ./entrypoint.sh /
|
||||
RUN chmod +x /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
set -eo pipefail
|
||||
|
||||
cleanup() {
|
||||
for pid_var in HTTP_PID ROSMASTER_PID ROSBRIDGE_PID ROSAPI_PID ROBOT_PID MOTOR_PID JOYSTICK_PID JOY_PID DELAY_PID GPS_PID; do
|
||||
if [[ -n "${!pid_var:-}" ]]; then
|
||||
kill "${!pid_var}" 2>/dev/null || true
|
||||
fi
|
||||
done
|
||||
wait || true
|
||||
}
|
||||
|
||||
if [[ $1 == "config" ]]
|
||||
then
|
||||
cd /root/exomy_ws/src/exomy/scripts
|
||||
bash
|
||||
elif [[ $1 == "autostart" ]]
|
||||
then
|
||||
trap cleanup EXIT INT TERM
|
||||
source /opt/ros/melodic/setup.bash
|
||||
cd /root/exomy_ws
|
||||
catkin_make
|
||||
export ROS_MASTER_URI=http://localhost:11311
|
||||
source devel/setup.bash
|
||||
|
||||
cd src/exomy/gui
|
||||
python -m SimpleHTTPServer 8000 &
|
||||
HTTP_PID=$!
|
||||
cd /root/exomy_ws
|
||||
|
||||
rosmaster --core -p 11311 -w 3 > /tmp/rosmaster.log 2>&1 &
|
||||
ROSMASTER_PID=$!
|
||||
sleep 3
|
||||
|
||||
rosparam load /root/exomy_ws/src/exomy/config/exomy.yaml
|
||||
rosparam set /controller logitech-F710
|
||||
rosparam set /delay_seconds 0.0
|
||||
echo 0.0 > /tmp/exomy_delay.txt
|
||||
rosparam set /speed_limit_percent 100
|
||||
echo 100 > /tmp/exomy_speed_limit.txt
|
||||
|
||||
/opt/ros/melodic/lib/rosbridge_server/rosbridge_websocket > /tmp/rosbridge.log 2>&1 &
|
||||
ROSBRIDGE_PID=$!
|
||||
/opt/ros/melodic/lib/rosapi/rosapi_node > /tmp/rosapi.log 2>&1 &
|
||||
ROSAPI_PID=$!
|
||||
python /root/exomy_ws/src/exomy/src/delay_node.py > /tmp/delay_node.log 2>&1 &
|
||||
DELAY_PID=$!
|
||||
python /root/exomy_ws/src/exomy/src/f710_joy_node.py > /tmp/joy_node.log 2>&1 &
|
||||
JOY_PID=$!
|
||||
python /root/exomy_ws/src/exomy/src/robot_node.py > /tmp/robot_node.log 2>&1 &
|
||||
ROBOT_PID=$!
|
||||
python /root/exomy_ws/src/exomy/src/motor_node.py > /tmp/motor_node.log 2>&1 &
|
||||
MOTOR_PID=$!
|
||||
python /root/exomy_ws/src/exomy/src/joystick_parser_node.py > /tmp/joystick_parser.log 2>&1 &
|
||||
JOYSTICK_PID=$!
|
||||
python /root/exomy_ws/src/exomy/src/gps_node.py > /tmp/gps_node.log 2>&1 &
|
||||
GPS_PID=$!
|
||||
|
||||
wait -n "$HTTP_PID" "$ROSMASTER_PID" "$ROSBRIDGE_PID" "$ROSAPI_PID" "$ROBOT_PID" "$MOTOR_PID" "$JOYSTICK_PID" "$JOY_PID" "$DELAY_PID" "$GPS_PID"
|
||||
exit 1
|
||||
elif [[ $1 == "devel" ]]
|
||||
then
|
||||
cd /root/exomy_ws
|
||||
source /opt/ros/melodic/setup.bash
|
||||
# catkin_make
|
||||
# source devel/setup.bash
|
||||
bash
|
||||
else
|
||||
bash
|
||||
fi
|
||||
@@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
# run_exomy- A script to run containers for dedicated functions of exomy
|
||||
|
||||
help_text="Usage: "$0" [MODE] [OPTIONS]
|
||||
A script to run ExoMy in different configurations
|
||||
Options:
|
||||
-a, --autostart Toggles autostart mode on or off
|
||||
-c, --config Runs the motor configuration of ExoMy
|
||||
-d, --devel Runs the development mode to change some code of ExoMy
|
||||
-h, --help Shows this text
|
||||
"
|
||||
|
||||
### Main
|
||||
# Initialize parameters
|
||||
container_name="exomy"
|
||||
image_name="exomy"
|
||||
|
||||
# Process parameters
|
||||
if [ "$1" != "" ]; then
|
||||
case $1 in
|
||||
-a | --autostart)
|
||||
container_name="${container_name}_autostart"
|
||||
start_command="autostart"
|
||||
options="--restart always"
|
||||
|
||||
;;
|
||||
-s | --stop_autostart)
|
||||
docker container stop "${container_name}_autostart"
|
||||
exit
|
||||
;;
|
||||
-c | --config)
|
||||
container_name="${container_name}_config"
|
||||
start_command="config"
|
||||
options="--rm"
|
||||
;;
|
||||
-d | --devel)
|
||||
container_name="${container_name}_devel"
|
||||
start_command="devel"
|
||||
options="--restart always"
|
||||
;;
|
||||
-h | --help ) echo "$help_text"
|
||||
exit
|
||||
;;
|
||||
* ) echo "ERROR: Not a valid mode!"
|
||||
echo "$help_text"
|
||||
exit 1
|
||||
esac
|
||||
else
|
||||
echo "ERROR: You need to specify a mode!"
|
||||
echo "$help_text"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Build docker image from Dockerfile in directory
|
||||
directory=$( dirname "$0" )
|
||||
docker build -t $image_name $directory
|
||||
|
||||
# Stop any of the 3 containers if running
|
||||
RUNNING_CONTAINERS=$( docker container ls -a -q --filter ancestor=exomy )
|
||||
if [ -n "$RUNNING_CONTAINERS" ]; then
|
||||
docker rm -f "$RUNNING_CONTAINERS"
|
||||
fi
|
||||
|
||||
# Run docker container
|
||||
docker run \
|
||||
-it \
|
||||
-v ~/ExoMy_Software:/root/exomy_ws/src/exomy \
|
||||
-p 8000:8000 \
|
||||
-p 8080:8080 \
|
||||
-p 9090:9090 \
|
||||
--privileged \
|
||||
${options} \
|
||||
--name "${container_name}" \
|
||||
"${image_name}" \
|
||||
"${start_command}"
|
||||
Reference in New Issue
Block a user