diff --git a/README.md b/README.md index 365d665487b152e10a912aca30ee47abcf0cb583..f84b9f318aa9245a64cf69ad0064c15f23c5c9d1 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,15 @@ To install and configure a development environment, follow these steps: - [Install Nvidia Docker drivers](doc/docker_nvidia.md) if you have an Nvidia graphics card and you are not using a virtual machine +- [Install the Development Docker Image](doc/docker_install.md) containing the Docker-based LRS modules. -## Development Environments +## Interacting with the Development Docker Container + +The following document shows some general examples for interfacing between the Development System and the Development Docker Container. -- [Using a Local ROS Installation with LRS Docker Modules](doc/local_ros_installation.md) +- [Interfacing to LRS Docker Modules](doc/docker_interfacing.md) + +## Development Environments For more information on how to integrate your code we have split the information in different sub-areas: diff --git a/doc/docker_install.md b/doc/docker_install.md new file mode 100644 index 0000000000000000000000000000000000000000..9306ff70ecc8be4dd55043746ad9ce1fb4fc875e --- /dev/null +++ b/doc/docker_install.md @@ -0,0 +1,30 @@ +# Using LRS Dockers + +To install the Docker-based LRS modules, you should first clone the `lrs_devenv_common` repo: + +```bash +git clone git@gitlab.liu.se:lrs/lrs_devenv_common.git +``` + +or if you need to specify the `wara_deploy` deploy key to gain access: +```bash +GIT_SSH_COMMAND='ssh -i ~/.ssh/wara_deploy -o IdentitiesOnly=yes' git clone git@gitlab.liu.se:lrs/waraps.git +``` + +Put the script directory of the `lrs_devenv_common` repo in your `PATH` and add the following variables, for example in .bashrc: + +```bash +export PATH="...../lrs_devenv_common/script:$PATH" + +export WORLD_ORIGIN_LAT=57.7605573519 +export WORLD_ORIGIN_LON=16.6827607783 +export WORLD_ORIGIN_ELEVATION=29.8 +``` + +Finally, pull (download) the latest version of the Development Docker Image. You may have to start a new `bash` shell for this to work (scripts such as `wpull` are in the script directory that was just added to your PATH): + +```bash +wpull +``` + +If you want to update this image to the latest version, run `wpull` again. diff --git a/doc/local_ros_installation.md b/doc/docker_interfacing.md similarity index 60% rename from doc/local_ros_installation.md rename to doc/docker_interfacing.md index b3d06beaf4f4b17a2b2930026b07e4a41bafc89b..d27a49426d6ac8632b33719f358b0a3d78118edd 100644 --- a/doc/local_ros_installation.md +++ b/doc/docker_interfacing.md @@ -1,76 +1,50 @@ -# Local ROS Installation and LRS +# Using LRS Dockers -Here we describe how to use a local ROS installation and interface -with the LRS Modules available through docker. The intention is that -this should be enough for a person knowledgeable about ROS to start -developing their own functionality and interface with the available ROS -modules. +Here we describe how to interface with the Docker-based LRS modules from the local ROS installation of your Development System. The intention is that this should be enough for a person knowledgeable about ROS to start developing their own functionality and interface with the available ROS modules. -See the following for en overview of the available functionality: +See the following for an overview of the available functionality: - https://aiics.waraps.org/index.php/lrs-lrs_jupyter-md-djisdk-md/ - https://aiics.waraps.org/index.php/lrs-lrs_jupyter-md-single_agent-md/ - https://aiics.waraps.org/index.php/lrs-lrs_jupyter-md-single_agent_tst-md/ -## Table of Content +## Table of Contents -- [Preparations](#preparations) - [Scripts](#scripts) - [How to start different parts](#how-to-start-different-parts) - [Flying with Gamepad](#flying-with-gamepad) - -## Preparation - -Get the lrs_devenv_common repo: -```bash -git clone git@gitlab.liu.se:lrs/lrs_devenv_common.git -``` -or if you need to specify the key: -```bash -GIT_SSH_COMMAND='ssh -i ~/.ssh/wara_deploy -o IdentitiesOnly=yes' git clone git@gitlab.liu.se:lrs/waraps.git -``` - -Put the script directory of the lrs_devenv_common repo in your PATH plus add -some variables that are needed. For example in .bashrc: - -```bash -export PATH="...../lrs_devenv_common/script:$PATH" - -export WORLD_ORIGIN_LAT=57.7605573519 -export WORLD_ORIGIN_LON=16.6827607783 -export WORLD_ORIGIN_ELEVATION=29.8 -``` - -If you have gotten a lot of running containers that interfere with -each other you can stop allrunning containers with: - -```bash -docker stop $(docker container ls -q) -``` - -And to clean up: -```bash -docker system prune -``` +- [Maintenance](#maintenance) ## Scripts -You now have the following scripts in your path: +Since you have [installed the Development Docker Images](docker_install.md), you now have the following scripts in your path. These scripts are intended to be executed directly on the Development System but are used to *interact* with the Docker Container. Concrete examples of using the scripts are given in the next section. -### wexec +### wpull -Execute commands in a running docker container. +Pull (update to) the most recent version of the Development Environment docker image. You should already have done this once, but you can do it again if you want to check for (and download) a new version. + +The contents of this script: ```bash #!/bin/bash -docker exec -it lrsdevel "$@" +if [[ $(lsb_release -rs) == "18.04" ]]; then + echo "Pulling gitlab.liu.se:5000/lrs/devenv_docker_images/lrs-melodic:devel" + docker pull gitlab.liu.se:5000/lrs/devenv_docker_images/lrs-melodic:devel +fi + +if [[ $(lsb_release -rs) == "20.04" ]]; then + echo "Pulling gitlab.liu.se:5000/lrs/devenv_docker_images/lrs-noetic:devel" + docker pull gitlab.liu.se:5000/lrs/devenv_docker_images/lrs-noetic:devel +fi ``` ### wgrun Start a docker container named `lrsdevel` and run the commands there. Use this if you have NVIDIA graphics. + +The contents of this script: ```bash #!/bin/bash @@ -105,6 +79,8 @@ fi ### wrun Start a docker container named lrsdevel and run the command there. Use if you do not have NVIDIA graphics. + +The contents of this script: ```bash #!/bin/bash @@ -134,124 +110,129 @@ fi ``` -### wpull +### wexec + +Execute commands in an already running `lrsdevel` docker container. -Pull the image. +The contents of this script: ```bash #!/bin/bash -if [[ $(lsb_release -rs) == "18.04" ]]; then - echo "Pulling gitlab.liu.se:5000/lrs/devenv_docker_images/lrs-melodic:devel" - docker pull gitlab.liu.se:5000/lrs/devenv_docker_images/lrs-melodic:devel -fi - -if [[ $(lsb_release -rs) == "20.04" ]]; then - echo "Pulling gitlab.liu.se:5000/lrs/devenv_docker_images/lrs-noetic:devel" - docker pull gitlab.liu.se:5000/lrs/devenv_docker_images/lrs-noetic:devel -fi +docker exec -it lrsdevel "$@" ``` ## How to start different parts -### Pull the Image -Start by puling the image: -```bash -wpull -``` +### Start a roscore and the docker container -### Start a ros core and the docker container: +There are two ways of running the roscore: -Either run the roscore locally or in the docker container. +- Directly on the Development System: -Local roscore: -```bash -roscore -wgrun bash -``` + ```bash + # Start the roscore here + roscore + # Start the Development Environment and make it run a simple bash shell + wgrun bash + ``` -Roscore in docker container: -```bash -wgrun roscore -``` +- Inside the Docker container + + ```bash + # Start the Development Environment and make it run the roscore + wgrun roscore + ``` + +++++++++++++ Options, options.... When do we want to run the roscore where? ### Loading config files for units -Assume we want to use unit /dji0 in Gränsö. The do: +Assume we want to use unit /dji0 in Gränsö. Then do: ```bash wexec roslaunch lrs_launch config.launch location:=granso no_airspace_booking:=true ns:=/dji0 ``` -### Start gazebo using docker (optionally) +### Starting Gazebo using Docker (optionally) -If you have a NVIDIA graphics card and support for that in docker then -you can if needed start gazebo (and if the container was started with wgrun): +If you have an NVIDIA graphics card and support for that in docker, then you can if needed start gazebo (assuming that the container was already started with wgrun): ```bash +# Run roslaunch inside the docker container wexec roslaunch lrs_wara_gazebo gazebo.launch ``` Load the dji model in gazebo: ```bash +# Run roslaunch inside the docker container wexec roslaunch lrs_wara_gazebo dji_to_gazebo.launch name:=dji0 with_laser:=true x:=0 ``` -### dji 0 +### Starting a simulator for dji0 + +Begin simulating a DJI Matrice, `dji0`: ```bash wexec roslaunch lrs_launch djisimtst.launch dynamics:=true publish_pose:=true mpc:=true ns:=/dji0 ``` -In ONE roscore mode the following holds: -- opunit.launch will start a program thet convert from geopose to pose for all units. +In single-roscore mode the following holds: + +- opunit.launch will start a program that converts from geopose to pose for all units. - So the flag publish_pose should only be set to true if you run opunit.launch. -In multiple roscore mode only geopose is sent to the op unit so there -we can choose freely if we want to generate the pose or not. +In multiple roscore mode, only geopose is sent to the op unit, so there we can choose freely if we want to generate the pose or not. -### Start tstdisplayserver +### Starting tstdisplayserver to show TSTs + +Show TSTs graphically (when they are created/delegated): ```bash wexec rosrun lrs_util_tst tstdisplayserver.py __ns:=/dji0 ``` -### RVIZ +### Starting rviz -Gränsö: +Use rviz to show the environment in Gränsö: ```bash wexec roslaunch lrs_dji_sim rviz_granso.launch ``` -Geneneral, uses the location given to config. Currently only Gränsö orthophoto installed. +Use rviz to show another location specified in the config. Currently only Gränsö has an orthophoto installed, though. ```bash wexec roslaunch lrs_launch rviz_outside.launch ``` -### Test the dji0 +### Testing the dji0 -On the local machine do: +On the Development System: Watch the geopose: ```bash rostopic echo /dji0/geopose ``` -Takeoff +Try a Takeoff TST ```bash wexec rosrun lrs_tst tstcommand.py --takeoff --exec __ns:=/dji0 --disp --op /dji0 ``` -Flyto +Try a Flyto TST ```bash wexec rosrun lrs_tst tstcommand.py --fly -x 100 -y 100 -z 12 --speed 3 --exec __ns:=/dji0 --disp --op /dji0 ``` ## Flying with Gamepad -For this case it is more convenient to run the roscore on the local machine: +To fly with a Gamepad, it is more convenient to run the roscore on the local machine. + +These instructions assume that you haven't already started the Docker container. If you have, stop it first. + +On the development system: + ```bash roscore ``` @@ -263,13 +244,13 @@ wgrun bash On the local machine run the joy ros node: -Set the variable: +Set the variable according to your particular Gamepad. Example: ```bash echo $JOY_EXTRA0 usb-Logitech_Wireless_Gamepad_F710_2CAE9E79-joystick ``` -To get the id for the Gamepad do: +To get the ID for the Gamepad do: ```bash tompe@philo:~$ ls /dev/input/by-id/ usb-046d_C922_Pro_Stream_Webcam_B16031EF-event-if00 @@ -288,7 +269,7 @@ Start the ROS driver for a joystick: rosrun joy joy_node _dev:=/dev/input/by-id/${JOY_EXTRA0} _deadzone:=0.05 _autorepeat_rate:=50 _coalesce_interval:=0.1 __ns:=/extra0 ``` -Setup the simulation: +Set up the simulation: ```bash wexec roslaunch lrs_launch config.launch location:=granso no_airspace_booking:=true ns:=/dji0 wexec roslaunch lrs_launch djisimtst.launch dynamics:=true publish_pose:=true mpc:=true inair:=true ns:=/dji0 @@ -300,7 +281,7 @@ wexec rosrun lrs_dji_sim joypose.py __ns:=/dji0 ``` -Rviz: +Start rviz: ```bash wexec roslaunch lrs_launch rviz_outside.launch ``` @@ -308,3 +289,18 @@ wexec roslaunch lrs_launch rviz_outside.launch On the GamePad: - Green Button: Manual Mode, fly with gamepad - Red Button: Auto + +## Maintenance + +If you have ended up with a lot of running containers that interfere with each other you can stop all running containers with: + +```bash +docker stop $(docker container ls -q) +``` + +And to clean up: +```bash +docker system prune +``` + +[Portainer](https://www.portainer.io/) is a useful tool if you want to manage your running containers.