-
Notifications
You must be signed in to change notification settings - Fork 11
dockerfile_scripts
M1chaelM edited this page Dec 2, 2020
·
3 revisions
- You will need to create three files:
Dockerfile
,ros_entrypoint.sh
, andrun_my_system.bash
. *First, create a directory to keep them in:
mkdir ~/vorc_docker; cd ~/vorc_docker
- Run
gedit Dockerfile
and copy the following text into it:
# This is an auto generated Dockerfile for ros:ros-base
# generated from docker_images/create_ros_image.Dockerfile.em
FROM ros:melodic-ros-core-bionic
# install ros packages
RUN apt-get update && apt-get install -y \
ros-melodic-ros-base=1.4.1-0* \
&& rm -rf /var/lib/apt/lists/*
# Copy over script to Docker container
COPY ./run_my_system.bash /
# Use your ros_entrypoint
COPY ./ros_entrypoint.sh /
- Run
gedit ros_entrypoint.sh
and copy the following text into the file:
#!/bin/bash
set -e
# setup ros environment
source "/opt/ros/$ROS_DISTRO/setup.bash"
/run_my_system.bash
Then run chmod +x ros_entrypoint.sh
to make it executable.
- Run
gedit run_my_system.sh
and copy the following text into the file:
#!/bin/bash
# Create ros master if not already started
rostopic list > /dev/null 2>&1
retVal=$?
if [ $retVal -ne 0 ]; then
roscore &
echo "Wait for 5s to allow rosmaster to start"
sleep 5s
else
echo "rosmaster already setup"
fi
# Send forward command
RATE=1
CMD=2
echo "Sending forward command"
rostopic pub /vorc/thrusters/left_thrust_cmd std_msgs/Float32 -r ${RATE} -- ${CMD} &
rostopic pub /vorc/thrusters/right_thrust_cmd std_msgs/Float32 -r ${RATE} -- ${CMD}
Then run chmod +x run_my_system.bash
to make it executable.