-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from NVIDIA-Jetson/sim_docker
Redtail Docker, APM rover and fixes
- Loading branch information
Showing
14 changed files
with
638 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
FROM ubuntu:14.04 | ||
|
||
# Build with: | ||
# docker build -t erle-sim:indigo -f Dockerfile.indigo . | ||
|
||
ENV HOME /root | ||
|
||
COPY scripts/* $HOME/scripts/ | ||
RUN chmod +x -R $HOME/scripts/* | ||
RUN chown -R root:root $HOME/scripts/* | ||
|
||
WORKDIR $HOME | ||
# Add repos: | ||
# ROS | ||
# Gazebo | ||
# DRC | ||
RUN apt-get update && apt-get install -y --no-install-recommends wget && \ | ||
sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' && \ | ||
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key 0xB01FA116 && \ | ||
sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -sc) main" > /etc/apt/sources.list.d/gazebo-stable.list' && \ | ||
wget http://packages.osrfoundation.org/gazebo.key -O - | apt-key add - && \ | ||
sh -c 'echo "deb http://packages.osrfoundation.org/drc/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/drc-latest.list' && \ | ||
wget http://packages.osrfoundation.org/drc.key -O - | apt-key add - && \ | ||
apt-get update | ||
|
||
# Install required components first. | ||
RUN apt-get install -y --no-install-recommends \ | ||
gawk make git curl cmake g++ \ | ||
python-dev python-pip python-matplotlib \ | ||
python-serial python-wxgtk2.8 python-scipy \ | ||
python-opencv python-numpy python-pyparsing \ | ||
python-setuptools ccache realpath \ | ||
libopencv-dev libxml2-dev libxslt1-dev \ | ||
lsb-release unzip libgl1-mesa-dri | ||
|
||
# Python packages and MAVProxy | ||
RUN pip install wheel && \ | ||
pip install future && \ | ||
pip install pymavlink catkin_pkg --upgrade && \ | ||
pip install MAVProxy==1.5.2 | ||
|
||
# ArUco | ||
RUN wget "https://downloads.sourceforge.net/project/aruco/OldVersions/aruco-1.3.0.tgz?ts=1494024608&use_mirror=cytranet" -O aruco-1.3.0.tgz && \ | ||
tar -xvzf aruco-1.3.0.tgz && \ | ||
cd aruco-1.3.0/ && \ | ||
mkdir build && cd build && \ | ||
cmake .. && \ | ||
make -j `nproc` && \ | ||
make install | ||
|
||
# APM | ||
WORKDIR $HOME | ||
RUN mkdir -p simulation && \ | ||
cd simulation && \ | ||
git clone https://github.com/erlerobot/ardupilot -b gazebo | ||
|
||
# ROS | ||
# Install and init ROS base and MAVROS | ||
RUN apt-get install -y ros-indigo-ros-base ros-indigo-mavros ros-indigo-mavros-extras && \ | ||
rosdep init && \ | ||
rosdep update && \ | ||
echo "source /opt/ros/indigo/setup.bash" >> $HOME/.bashrc | ||
|
||
# Install ROS packages | ||
RUN apt-get install -y --no-install-recommends python-rosinstall \ | ||
ros-indigo-octomap-msgs \ | ||
ros-indigo-joy \ | ||
ros-indigo-geodesy \ | ||
ros-indigo-octomap-ros \ | ||
ros-indigo-mavlink \ | ||
ros-indigo-control-toolbox \ | ||
ros-indigo-transmission-interface \ | ||
ros-indigo-joint-limits-interface \ | ||
ros-indigo-image-transport \ | ||
ros-indigo-cv-bridge \ | ||
ros-indigo-angles \ | ||
ros-indigo-polled-camera \ | ||
ros-indigo-camera-info-manager \ | ||
ros-indigo-controller-manager | ||
|
||
# Install Gazebo | ||
WORKDIR $HOME | ||
RUN apt-get install -y --no-install-recommends gazebo7 libgazebo7-dev drcsim7 | ||
|
||
# Create ROS workspace | ||
WORKDIR $HOME | ||
RUN bash $HOME/scripts/init_workspace.bash | ||
|
||
WORKDIR $HOME/simulation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Running simulation in Docker for Erle Robotics vehicles | ||
|
||
This repository contains scripts and instructions on building Docker container for the purpose of running simulations with [Erle Robotics](http://erlerobotics.com/) vehicles. It is essentially dockerized instructions provided on the official [Erle Robotics website](http://docs.erlerobotics.com/simulation). Currently only ROS Indigo is supported and tested, Kinetic is in the works. | ||
|
||
## Building Docker image | ||
To build a Docker container, run the following command from this directory: | ||
```sh | ||
docker build -t erle-sim:indigo -f Dockerfile.indigo . | ||
``` | ||
This command will create a Docker image with the tag ```erle-sim:indigo```. Once the build is finished, you can verify that the image is built by running ```docker images``` command. | ||
|
||
## Creating Docker container | ||
In order to be able to run Gazebo from the Docker container, you need to connect host's X server to the Docker container. A good tutorial on various methods is documented on the [ROS Wiki](http://wiki.ros.org/docker/Tutorials/GUI), here we use the most simple (and insecure!) way. | ||
1. Create Docker container: | ||
```sh | ||
docker run -it --network=host -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix${DISPLAY} --name=erle-sim erle-sim:indigo bash | ||
``` | ||
This command will create a container named ```erle-sim``` from the image with the same name (```erle-sim```) and enable executing GUI programs. | ||
2. Exit the container and restart/attach the container granting the permissions to xhost first: | ||
```sh | ||
xhost +local:`docker ps -aqf "name=erle-sim"` | ||
docker start erle-sim && docker attach erle-sim | ||
``` | ||
Replace ```erle-sim``` with your container name if needed. | ||
3. Run Gazebo to make sure everything is working: | ||
```sh | ||
gazebo | ||
``` | ||
You should see Gazebo window. | ||
### Troubleshooting | ||
In case you see messages like ```failed to load driver``` while executing step 3 **and** no Gazebo window opens up, you might be missing drivers. The current Docker script already contains command that installs Mesa drivers (```libgl1-mesa-dri```) but that might not be enough so try googling for more information. | ||
## Testing | ||
Once the container is created, try running simulator. For example, to run Rover simulator, run the following commands from the container: | ||
```sh | ||
source ~/simulation/ros_catkin_ws/devel/setup.bash | ||
cd ~/simulation/ardupilot/APMrover2/ | ||
../Tools/autotest/sim_vehicle.sh -j 4 -f Gazebo | ||
# once MAVProxy has launched completely, load the parameters | ||
param load /[full_path_to_your_home_directory]/simulation/ardupilot/Tools/Frame_params/3DR_Rover.param | ||
# For example: param load /root/simulation/ardupilot/Tools/Frame_params/3DR_Rover.param | ||
``` | ||
Now connect another terminal to the currently running Docker container: | ||
```sh | ||
docker exec -it erle-sim bash | ||
``` | ||
and run the following commands: | ||
```sh | ||
source ~/simulation/ros_catkin_ws/devel/setup.bash | ||
roslaunch ardupilot_sitl_gazebo_plugin rover_spawn.launch | ||
``` | ||
If everything was setup correctly, you should see Gazebo window with Rover model that you can control from the first terminal using MAVProxy commands: | ||
![Gazebo Erle Rover](./images/gazebo.png) | ||
Some of the MAVProxy commands are described [here](http://docs.erlerobotics.com/simulation/vehicles/erle_rover/tutorial_1). | ||
You can also use ```run_erle_sim.sh``` script to create new container or attach to a running container. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
ERLE_SIM_NAME=erle-sim | ||
ERLE_SIM_ID=`docker ps -aqf "name=^/${ERLE_SIM_NAME}$"` | ||
ERLE_SIM_HOST_DATA_DIR=/data/ | ||
if [ -z "${ERLE_SIM_ID}" ]; then | ||
echo "Creating new Erle Sim container." | ||
docker run -it --network=host -v ${ERLE_SIM_HOST_DATA_DIR}:/data/:rw -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix${DISPLAY} --name=${ERLE_SIM_NAME} erle-sim:indigo bash | ||
else | ||
echo "Found Erle Sim container: ${ERLE_SIM_ID}." | ||
# Check if the container is already running and start if necessary. | ||
if [ -z `docker ps -qf "name=^/${ERLE_SIM_NAME}$"` ]; then | ||
xhost +local:${ERLE_SIM_ID} | ||
echo "Starting and attaching to Erle Sim container..." | ||
docker start ${ERLE_SIM_ID} | ||
docker attach ${ERLE_SIM_ID} | ||
else | ||
echo "Found running Erle Sim container, attaching bash to it..." | ||
docker exec -it --privileged ${ERLE_SIM_ID} bash | ||
fi | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash | ||
# | ||
|
||
# Stop in case of any error | ||
set -e | ||
|
||
source /opt/ros/indigo/setup.bash | ||
|
||
WDIR=`pwd` | ||
|
||
# Create catkin workspace | ||
mkdir -p simulation/ros_catkin_ws/src | ||
cd simulation/ros_catkin_ws/src | ||
catkin_init_workspace | ||
cd .. | ||
catkin_make | ||
source devel/setup.bash | ||
|
||
# Get packages | ||
cd $WDIR/simulation/ros_catkin_ws/src | ||
|
||
git clone https://github.com/ros-drivers/driver_common | ||
git clone https://github.com/erlerobot/ardupilot_sitl_gazebo_plugin | ||
git clone https://github.com/erlerobot/rotors_simulator -b sonar_plugin | ||
git clone https://github.com/PX4/mav_comm.git | ||
git clone https://github.com/ethz-asl/glog_catkin.git | ||
git clone https://github.com/catkin/catkin_simple.git | ||
git clone https://github.com/erlerobot/mavros.git | ||
git clone https://github.com/ros-simulation/gazebo_ros_pkgs.git -b indigo-devel | ||
git clone https://github.com/erlerobot/gazebo_python_examples | ||
#git clone https://github.com/erlerobot/gazebo_cpp_examples | ||
#git clone https://github.com/tu-darmstadt-ros-pkg/hector_gazebo/ | ||
|
||
# Make packages | ||
cd .. | ||
catkin_make --pkg mav_msgs mavros_msgs gazebo_msgs | ||
source devel/setup.bash | ||
catkin_make -j `nproc` | ||
|
||
# Gazebo models | ||
cd $WDIR | ||
mkdir -p .gazebo/models | ||
cd .gazebo/models | ||
git clone https://github.com/erlerobot/erle_gazebo_models |
Oops, something went wrong.