diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2015-02-03 20:07:55 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2015-02-03 20:07:55 +0100 |
commit | dc46736eadac43527f875b281cc1f50032d36066 (patch) | |
tree | 5ee20f8423847161b624fd4f1e943d5a1608d171 /Tools | |
parent | 3e7faa6018dbff54860304a2e1a35d853160ef64 (diff) | |
parent | d441d38677eb78d1e599973dd1e993d3af1af218 (diff) | |
download | px4-firmware-dc46736eadac43527f875b281cc1f50032d36066.tar.gz px4-firmware-dc46736eadac43527f875b281cc1f50032d36066.tar.bz2 px4-firmware-dc46736eadac43527f875b281cc1f50032d36066.zip |
Merge ROS into master
Diffstat (limited to 'Tools')
m--------- | Tools/gencpp | 0 | ||||
m--------- | Tools/genmsg | 0 | ||||
-rwxr-xr-x | Tools/px_generate_uorb_topic_headers.py | 159 | ||||
-rw-r--r-- | Tools/ros/docker/px4-ros-full/Dockerfile | 57 | ||||
-rw-r--r-- | Tools/ros/docker/px4-ros-full/README.md | 12 | ||||
-rw-r--r-- | Tools/ros/docker/px4-ros-full/scripts/setup-workspace.sh | 45 | ||||
-rwxr-xr-x | Tools/ros/px4_ros_installation_ubuntu.sh | 41 | ||||
-rwxr-xr-x | Tools/ros/px4_workspace_create.sh | 9 | ||||
-rwxr-xr-x | Tools/ros/px4_workspace_setup.sh | 33 | ||||
-rw-r--r-- | Tools/ros/vagrant/docker-host-base/Vagrantfile | 58 | ||||
-rw-r--r-- | Tools/ros/vagrant/docker-host-base/config/docker-default | 29 | ||||
-rw-r--r-- | Tools/ros/vagrant/docker-host-base/config/xsessionrc | 6 | ||||
-rw-r--r-- | Tools/ros/vagrant/docker-host/Vagrantfile | 38 | ||||
-rw-r--r-- | Tools/ros/vagrant/px4-ros/Vagrantfile | 61 |
14 files changed, 548 insertions, 0 deletions
diff --git a/Tools/gencpp b/Tools/gencpp new file mode 160000 +Subproject 26a86f04bcec0018af6652b3ddd3f680e6e3fa2 diff --git a/Tools/genmsg b/Tools/genmsg new file mode 160000 +Subproject 72f0383f0e6a489214c51802ae12d6e271b1e45 diff --git a/Tools/px_generate_uorb_topic_headers.py b/Tools/px_generate_uorb_topic_headers.py new file mode 100755 index 000000000..4bcab4d54 --- /dev/null +++ b/Tools/px_generate_uorb_topic_headers.py @@ -0,0 +1,159 @@ +#!/usr/bin/env python +############################################################################# +# +# Copyright (C) 2013-2014 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################# + +""" +px_generate_uorb_topic_headers.py +Generates c/cpp header files for uorb topics from .msg (ROS syntax) +message files +""" +from __future__ import print_function +import os +import shutil +import filecmp +import argparse +import genmsg.template_tools + +__author__ = "Thomas Gubler" +__copyright__ = "Copyright (C) 2013-2014 PX4 Development Team." +__license__ = "BSD" +__email__ = "thomasgubler@gmail.com" + + +msg_template_map = {'msg.h.template': '@NAME@.h'} +srv_template_map = {} +incl_default = ['std_msgs:./msg/std_msgs'] +package = 'px4' + + +def convert_file(filename, outputdir, templatedir, includepath): + """ + Converts a single .msg file to a uorb header + """ + print("Generating headers from {0}".format(filename)) + genmsg.template_tools.generate_from_file(filename, + package, + outputdir, + templatedir, + includepath, + msg_template_map, + srv_template_map) + + +def convert_dir(inputdir, outputdir, templatedir): + """ + Converts all .msg files in inputdir to uORB header files + """ + includepath = incl_default + [':'.join([package, inputdir])] + for f in os.listdir(inputdir): + fn = os.path.join(inputdir, f) + if os.path.isfile(fn): + convert_file( + fn, + outputdir, + templatedir, + includepath) + + +def copy_changed(inputdir, outputdir, prefix=''): + """ + Copies files from inputdir to outputdir if they don't exist in + ouputdir or if their content changed + """ + + # Make sure output directory exists: + if not os.path.isdir(outputdir): + os.makedirs(outputdir) + + for f in os.listdir(inputdir): + fni = os.path.join(inputdir, f) + if os.path.isfile(fni): + # Check if f exists in outpoutdir, copy the file if not + fno = os.path.join(outputdir, prefix + f) + if not os.path.isfile(fno): + shutil.copy(fni, fno) + print("{0}: new header file".format(f)) + continue + # The file exists in inputdir and outputdir + # only copy if contents do not match + if not filecmp.cmp(fni, fno): + shutil.copy(fni, fno) + print("{0}: updated".format(f)) + continue + + print("{0}: unchanged".format(f)) + + +def convert_dir_save(inputdir, outputdir, templatedir, temporarydir, prefix): + """ + Converts all .msg files in inputdir to uORB header files + Unchanged existing files are not overwritten. + """ + # Create new headers in temporary output directory + convert_dir(inputdir, temporarydir, templatedir) + + # Copy changed headers from temporary dir to output dir + copy_changed(temporarydir, outputdir, prefix) + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + description='Convert msg files to uorb headers') + parser.add_argument('-d', dest='dir', help='directory with msg files') + parser.add_argument('-f', dest='file', + help="files to convert (use only without -d)", + nargs="+") + parser.add_argument('-e', dest='templatedir', + help='directory with template files',) + parser.add_argument('-o', dest='outputdir', + help='output directory for header files') + parser.add_argument('-t', dest='temporarydir', + help='temporary directory') + parser.add_argument('-p', dest='prefix', default='', + help='string added as prefix to the output file ' + ' name when converting directories') + args = parser.parse_args() + + if args.file is not None: + for f in args.file: + convert_file( + f, + args.outputdir, + args.templatedir, + incl_default) + elif args.dir is not None: + convert_dir_save( + args.dir, + args.outputdir, + args.templatedir, + args.temporarydir, + args.prefix) diff --git a/Tools/ros/docker/px4-ros-full/Dockerfile b/Tools/ros/docker/px4-ros-full/Dockerfile new file mode 100644 index 000000000..1242b56b5 --- /dev/null +++ b/Tools/ros/docker/px4-ros-full/Dockerfile @@ -0,0 +1,57 @@ +# +# PX4 full ROS container +# +# License: according to LICENSE.md in the root directory of the PX4 Firmware repository + +FROM ubuntu:14.04.1 +MAINTAINER Andreas Antener <andreas@uaventure.com> + +# Install basics +## Use the "noninteractive" debconf frontend +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get update \ + && apt-get -y install wget git mercurial + +# Main ROS Setup +# Following http://wiki.ros.org/indigo/Installation/Ubuntu +# Also adding dependencies for gazebo http://gazebosim.org/tutorials?tut=drcsim_install + +## add ROS repositories and keys +## install main ROS pacakges +RUN echo "deb http://packages.ros.org/ros/ubuntu trusty main" > /etc/apt/sources.list.d/ros-latest.list \ + && wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O - | apt-key add - \ + && apt-get update \ + && apt-get -y install ros-indigo-desktop-full + +RUN rosdep init \ + && rosdep update + +## setup environment variables +RUN echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc + +## get rosinstall +RUN apt-get -y install python-rosinstall + +## additional dependencies +RUN apt-get -y install ros-indigo-octomap-msgs ros-indigo-joy + +## install drcsim +RUN echo "deb http://packages.osrfoundation.org/drc/ubuntu trusty main" > /etc/apt/sources.list.d/drc-latest.list \ + && wget http://packages.osrfoundation.org/drc.key -O - | apt-key add - \ + && apt-get update \ + && apt-get -y install drcsim + +# Install x11-utils to get xdpyinfo, for X11 display debugging +# mesa-utils provides glxinfo, handy for understanding the 3D support +RUN apt-get -y install x11-utils mesa-utils + +# Some QT-Apps/Gazebo don't not show controls without this +ENV QT_X11_NO_MITSHM 1 + +# FIXME: this doesn't work when building from vagrant +COPY scripts/setup-workspace.sh /root/scripts/ +RUN chmod +x -R /root/scripts/* +RUN chown -R root:root /root/scripts/* + +CMD ["/usr/bin/xterm"] diff --git a/Tools/ros/docker/px4-ros-full/README.md b/Tools/ros/docker/px4-ros-full/README.md new file mode 100644 index 000000000..af5170c70 --- /dev/null +++ b/Tools/ros/docker/px4-ros-full/README.md @@ -0,0 +1,12 @@ +# PX4 ROS # + +Full desktop ROS container. + +License: according to LICENSE.md in the root directory of the PX4 Firmware repository + +**TODO:** + +- use https://github.com/phusion/baseimage-docker as base +- add user, best synced with host +- configure ssh to work with vagrant out of the box + diff --git a/Tools/ros/docker/px4-ros-full/scripts/setup-workspace.sh b/Tools/ros/docker/px4-ros-full/scripts/setup-workspace.sh new file mode 100644 index 000000000..2de5f8bec --- /dev/null +++ b/Tools/ros/docker/px4-ros-full/scripts/setup-workspace.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# +# Create workspace at current location and fetch source repositories +# + +# License: according to LICENSE.md in the root directory of the PX4 Firmware repository + +WDIR=`pwd` +WORKSPACE=$WDIR/catkin_ws + +# Setup workspace +mkdir -p $WORKSPACE/src +cd $WORKSPACE/src +catkin_init_workspace +cd $WORKSPACE +catkin_make +echo "source $WORKSPACE/devel/setup.bash" >> ~/.bashrc + +# PX4 Firmware +cd $WORKSPACE/src +git clone https://github.com/PX4/Firmware.git \ + && cd Firmware \ + && git checkout ros + +# euroc simulator +cd $WORKSPACE/src +git clone https://github.com/PX4/euroc_simulator.git \ + && cd euroc_simulator \ + && git checkout px4_nodes + +# mav comm +cd $WORKSPACE/src +git clone https://github.com/PX4/mav_comm.git + +# glog catkin +cd $WORKSPACE/src +git clone https://github.com/ethz-asl/glog_catkin.git + +# catkin simple +cd $WORKSPACE/src +git clone https://github.com/catkin/catkin_simple.git + +cd $WORKSPACE +catkin_make + diff --git a/Tools/ros/px4_ros_installation_ubuntu.sh b/Tools/ros/px4_ros_installation_ubuntu.sh new file mode 100755 index 000000000..7efc400cd --- /dev/null +++ b/Tools/ros/px4_ros_installation_ubuntu.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# License: according to LICENSE.md in the root directory of the PX4 Firmware repository + +# main ROS Setup +# following http://wiki.ros.org/indigo/Installation/Ubuntu +# also adding drcsim http://gazebosim.org/tutorials?tut=drcsim_install +# run this file with . ./px4_ros_setup_ubuntu.sh + +## add ROS repository +sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu trusty main" > /etc/apt/sources.list.d/ros-latest.list' + +## add key +wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O - | \ + sudo apt-key add - + +## Install main ROS pacakges +sudo apt-get update +sudo apt-get -y install ros-indigo-desktop-full +sudo rosdep init +rosdep update + +## Setup environment variables +echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc +. ~/.bashrc + +# get rosinstall +sudo apt-get -y install python-rosinstall + +# additional dependencies +sudo apt-get -y install ros-indigo-octomap-msgs ros-indigo-joy + +## drcsim setup (for models) +### add osrf repository +sudo sh -c 'echo "deb http://packages.osrfoundation.org/drc/ubuntu trusty main" > /etc/apt/sources.list.d/drc-latest.list' + +### add key +wget http://packages.osrfoundation.org/drc.key -O - | sudo apt-key add - + +### install drcsim +sudo apt-get update +sudo apt-get -y install drcsim diff --git a/Tools/ros/px4_workspace_create.sh b/Tools/ros/px4_workspace_create.sh new file mode 100755 index 000000000..cf80bcf8d --- /dev/null +++ b/Tools/ros/px4_workspace_create.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# this script creates a catkin_ws in the current folder +# License: according to LICENSE.md in the root directory of the PX4 Firmware repository + +mkdir -p catkin_ws/src +cd catkin_ws/src +catkin_init_workspace +cd .. +catkin_make diff --git a/Tools/ros/px4_workspace_setup.sh b/Tools/ros/px4_workspace_setup.sh new file mode 100755 index 000000000..53568b4fb --- /dev/null +++ b/Tools/ros/px4_workspace_setup.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# License: according to LICENSE.md in the root directory of the PX4 Firmware repository + +# run this script from the root of your catkin_ws +source devel/setup.bash +cd src + +# PX4 Firmware +git clone https://github.com/PX4/Firmware.git +cd Firmware +git checkout ros +cd .. + +# euroc simulator +git clone https://github.com/PX4/euroc_simulator.git +cd euroc_simulator +git checkout px4_nodes +cd .. + +# mav comm +git clone https://github.com/PX4/mav_comm.git + +# glog catkin +git clone https://github.com/ethz-asl/glog_catkin.git + +# catkin simple +git clone https://github.com/catkin/catkin_simple.git + +# drcsim (for scenery and models) + +cd .. + +catkin_make diff --git a/Tools/ros/vagrant/docker-host-base/Vagrantfile b/Tools/ros/vagrant/docker-host-base/Vagrantfile new file mode 100644 index 000000000..06e4e897d --- /dev/null +++ b/Tools/ros/vagrant/docker-host-base/Vagrantfile @@ -0,0 +1,58 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# +# Vagrantfile to create docker-host-base +# +# Maintainer: Andreas Antener <andreas@uaventure.com> +# +# After build, do "vagrant package --base docker-host-base" to package, +# and import as box: "vagrant box add --name uaventure/docker-host-base package.box" +# +# License: according to LICENSE.md in the root directory of the PX4 Firmware repository + +Vagrant.configure(2) do |config| + config.vm.box = "ubuntu/trusty64" + + config.vm.define "docker-host-base" + + config.vm.provider "virtualbox" do |vb| + vb.name = "docker-host-base" + vb.gui = true + vb.memory = "1024" + end + + config.vm.provision "file", source: "config/docker-default", destination: "/home/vagrant/docker-default" + config.vm.provision "file", source: "config/xsessionrc", destination: "/home/vagrant/.xsessionrc" + + config.vm.provision "shell", inline: <<-SHELL + # Update and install apps + export DEBIAN_FRONTEND=noninteractive + sudo apt-get update + sudo apt-get upgrade -y + sudo apt-get install -y --no-install-recommends ubuntu-desktop + sudo apt-get install -y gnome-terminal unity-lens-applications + + # Reset the ssh key (because vagrant regenerates it during provisioning) + sudo wget --no-check-certificate https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub -O /home/vagrant/.ssh/authorized_keys + sudo chmod 0700 /home/vagrant/.ssh + sudo chmod 0600 /home/vagrant/.ssh/authorized_keys + sudo chown -R vagrant /home/vagrant/.ssh + + # Copy docker config + sudo mv /home/vagrant/docker-default /etc/default/docker + + # Enable autologin so docker can start GUI apps + sudo echo "autologin-user=vagrant" >> /usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf + sudo echo "autologin-user-timeout=0" >> /usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf + + # X session RC + chmod +x /home/vagrant/.xsessionrc + SHELL + + config.vm.provision "docker" + + # Shutdown after provisioning. "vagrant halt" doesn't recognize the original ssh key anymore + # and would just kill the VM. This might lead to FS inconsistencies (e.g. in the docker DB). + config.vm.provision "shell", inline: "sudo shutdown -h now" +end diff --git a/Tools/ros/vagrant/docker-host-base/config/docker-default b/Tools/ros/vagrant/docker-host-base/config/docker-default new file mode 100644 index 000000000..19c466b6b --- /dev/null +++ b/Tools/ros/vagrant/docker-host-base/config/docker-default @@ -0,0 +1,29 @@ +# +# Default config for docker /etc/default/docker +# Copied from a provisioned vagrant box +# +# Modifications: +# - listen to TCP port +# - removing deprecated "-r=true" option which apparently doesn't work anymore +# > use restart policies for specific containers if necessary +# + +# Docker Upstart and SysVinit configuration file + +# Customize location of Docker binary (especially for development testing). +#DOCKER="/usr/local/bin/docker" + +# Use DOCKER_OPTS to modify the daemon startup options. +#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4" + +# If you need Docker to use an HTTP proxy, it can also be specified here. +#export http_proxy="http://127.0.0.1:3128/" + +# This is also a handy place to tweak where Docker's temporary files go. +#export TMPDIR="/mnt/bigdrive/docker-tmp" + +# Expose TCP port in addition to socket + +# License: according to LICENSE.md in the root directory of the PX4 Firmware repository + +DOCKER_OPTS="${DOCKER_OPTS} -H unix:///var/run/docker.sock -H 0.0.0.0:2375" diff --git a/Tools/ros/vagrant/docker-host-base/config/xsessionrc b/Tools/ros/vagrant/docker-host-base/config/xsessionrc new file mode 100644 index 000000000..1bd4f8d3f --- /dev/null +++ b/Tools/ros/vagrant/docker-host-base/config/xsessionrc @@ -0,0 +1,6 @@ +#!/bin/sh +# +# Disable X access control so we can easily start GUI apps +# +# License: according to LICENSE.md in the root directory of the PX4 Firmware repository +xhost + diff --git a/Tools/ros/vagrant/docker-host/Vagrantfile b/Tools/ros/vagrant/docker-host/Vagrantfile new file mode 100644 index 000000000..2a0a02271 --- /dev/null +++ b/Tools/ros/vagrant/docker-host/Vagrantfile @@ -0,0 +1,38 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# +# Actual docker host VM to run. +# +# Maintainer: Andreas Antener <andreas@uaventure.com> +# +# To add local docker images into the docker host, configure your local +# docker client to control the docker daemon on the running "docker-host" VM. +# The box ("docker-host-base") configures docker to listen on any IP on port 2375. +# You can then load an existing image, e.g.: +# "docker load -i container-image.tar" +# +# License: according to LICENSE.md in the root directory of the PX4 Firmware repository + +Vagrant.configure(2) do |config| + config.vm.box = "uaventure/docker-host-base" + + config.vm.define "docker-host" + + config.vm.provider "virtualbox" do |vb| + vb.name = "docker-host" + vb.gui = true + vb.memory = "4096" + vb.cpus = 2 + vb.customize ["modifyvm", :id, "--graphicscontroller", "vboxvga"] + vb.customize ["modifyvm", :id, "--accelerate3d", "on"] + vb.customize ["modifyvm", :id, "--ioapic", "on"] + vb.customize ["modifyvm", :id, "--vram", "128"] + vb.customize ["modifyvm", :id, "--hwvirtex", "on"] + end + + config.vm.network "private_network", ip: "192.168.59.104" + + # TBD: would it be better to provision docker here instead of in the base box? + #config.vm.provision "docker" +end diff --git a/Tools/ros/vagrant/px4-ros/Vagrantfile b/Tools/ros/vagrant/px4-ros/Vagrantfile new file mode 100644 index 000000000..5b372a94d --- /dev/null +++ b/Tools/ros/vagrant/px4-ros/Vagrantfile @@ -0,0 +1,61 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# +# Boot docker SITL environment +# +# Maintainer: Andreas Antener <andreas@uaventure.com> +# +# "vagrant up" will build the images. Should eventually start "xterm" from within the docker container. +# +# Notes: +# (will change, need proper docs) +# +# Build with multiple dependent docker containers: +# Use the "--no-parallel" option so the containers will be built/started in order. +# e.g.: "vagrant up --no-parallel" +# +# Running apps directly: +# "vagrant docker-run ros -- <cmd>" +# Attention: will loose all data when stopped, vagrant runs docker always with "--rm" +# +# TODO +# - do not run the docker container with "--rm" (vagrant default). is that even possible? +# - maybe map a local working directory to compile stuff without loosing it in side the docker container +# +# License: according to LICENSE.md in the root directory of the PX4 Firmware repository + +Vagrant.configure(2) do |config| + # Configure docker host + config.vm.provider "docker" do |d| + d.vagrant_machine = "docker-host" + d.vagrant_vagrantfile = "../docker-host/Vagrantfile" + end + + # Configure docker apps to run + config.vm.define "ros" do |app| + app.vm.provider "docker" do |d| + d.name = "ros" + d.image = "uaventure/px4-ros-full" + #d.build_dir = "../../docker/px4-ros-full" + #d.build_args = ["-t=uaventure/px4-ros-full"] + + # Share docker host x11 socket + # Run privileged to support 3d acceleration + d.volumes = [ + "/tmp/.X11-unix:/tmp/.X11-unix:ro" + ] + d.create_args = ["--privileged"] + + # TODO: get display number from host system + d.env = { + "DISPLAY" => ":0" + } + + d.remains_running = true + d.cmd = ["xterm"] + #d.has_ssh = true + end + end + +end |