Skip to content

Commit

Permalink
Merge PR #54 (RIP v0.1) from utk-robotics-2017/dev
Browse files Browse the repository at this point in the history
RIP v0.1 merge. More hardware testing & bugfixes are likely necessary.
  • Loading branch information
Parker Mitchell authored Feb 22, 2018
2 parents 8b3a29a + 9871b68 commit 51cfc06
Show file tree
Hide file tree
Showing 440 changed files with 39,064 additions and 6,465 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build
.travis.yml
.git
15 changes: 15 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,18 @@
[submodule "external/serial"]
path = external/serial
url = [email protected]:utk-robotics-2017/serial.git
[submodule "external/eigen"]
path = external/eigen
url = [email protected]:utk-robotics-2017/eigen.git
[submodule "external/g2o"]
path = external/g2o
url = [email protected]:utk-robotics-2017/g2o.git
[submodule "external/suitesparse"]
path = external/suitesparse
url = [email protected]:utk-robotics-2017/suitesparse.git
[submodule "external/optional-lite"]
path = external/optional-lite
url = [email protected]:utk-robotics-2017/optional-lite.git
[submodule "external/args"]
path = external/args
url = [email protected]:utk-robotics-2017/args.git
39 changes: 20 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
dist: trusty

sudo: false
sudo: required

services:
- docker

language: cpp

compiler:
- gcc
- clang

install:
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi

addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.9
- gcc-4.9
- clang
- cppcheck
- cmake
- lcov
- libssh2-1-dev

- docker pull utkrobotics/rip_deps

before_script:
- ./travis/before_script.sh $TRAVIS_BRANCH $TRAVIS_PULL_REQUEST $TRAVIS_PULL_REQUEST_BRANCH
# get cached images from
- docker build --tag rip_ci .
# - ./travis/before_script.sh $TRAVIS_BRANCH $TRAVIS_PULL_REQUEST $TRAVIS_PULL_REQUEST_BRANCH
# - ./travis/compile_g2o.sh
# start the container persistence:
- ci_env=`bash <(curl -s https://codecov.io/env)`
- docker run --name rip_ci $ci_env -t -d rip_ci zsh -l
# run setup in container:
- docker exec -t rip_ci zsh -c "./travis/before_script.sh $TRAVIS_BRANCH $TRAVIS_PULL_REQUEST $TRAVIS_PULL_REQUEST_BRANCH"
- docker start rip_ci

script:
- ./travis/script.sh $TRAVIS_BRANCH $TRAVIS_PULL_REQUEST $TRAVIS_PULL_REQUEST_BRANCH
- docker exec -t rip_ci zsh -c "./travis/script.sh $TRAVIS_BRANCH $TRAVIS_PULL_REQUEST $TRAVIS_PULL_REQUEST_BRANCH"

after_script:
- ./travis/after_script.sh $TRAVIS_BRANCH $TRAVIS_PULL_REQUEST $TRAVIS_PULL_REQUEST_BRANCH
# - ./travis/after_script.sh $TRAVIS_BRANCH $TRAVIS_PULL_REQUEST $TRAVIS_PULL_REQUEST_BRANCH
- docker exec -t rip_ci zsh -c "./travis/after_script.sh $TRAVIS_BRANCH $TRAVIS_PULL_REQUEST $TRAVIS_PULL_REQUEST_BRANCH"
- docker stop rip_ci
- docker rm rip_ci
73 changes: 12 additions & 61 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,76 +1,27 @@
cmake_minimum_required(VERSION 3.1)
project(rip)
message(building)
# Get the current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Can remove this if found to be not needed - was required on some machines
# to correctly compile the codebase despite this line being in the
# downstream CMake files.
set (CMAKE_CXX_STANDARD 11)

message("Git branch: ${GIT_BRANCH}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}-fdiagnostics-color=always")

LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)

option(ENABLE_TESTING "Enable module testing" OFF)

add_subdirectory(external)
add_subdirectory(core)
add_subdirectory(appendages)
add_subdirectory(arduino_gen)

if(GIT_BRANCH MATCHES "arduino_gen/.*")
add_subdirectory(core/utilities/exceptions_base)
add_subdirectory(arduino_gen)
add_subdirectory(gui)
else()
add_subdirectory(core)
add_subdirectory(appendages)
add_subdirectory(arduino_gen)

option(GUI "Build the GUI" OFF)
if(GUI)
message("Building the GUI")
add_subdirectory(gui)
endif()

#option(ALL "Build everything" OFF)
#
## RIP Modules
#option(RIP "Build all of RIP" OFF)
#option(COMMUNICATION "Build RIP's communication module" OFF)
#option(NAVIGATION "Build RIP's navigation module" OFF)
#option(NAVX "Build RIP's navx submodule" OFF)
#option(PATHFINDER "Build RIP's pathfinder submodule" OFF)
#option(VISION "Build RIP's vision module" OFF)
#option(FSM "Build RIP's fsm and action scheduler modules" OFF)
#
## Other Modules
#option(RIPCOM "Build RIPCOM" OFF)
#option(ARDUINO_GEN "Build ArduinoGen" OFF)
#
## Utilities
#option(ROBOCLAW "Build Roboclaw" OFF)
#option(PATHMAN "Build Pathman" OFF)
#option(CMD_MESENGER "Build CmdMessenger" OFF)
#
## Testing
#option(ENABLE_TESTING "Enable testing of the modules" OFF)
#
#add_subdirectory(external)
#
#if(ALL OR RIP OR CORE OR RIPCOM)
# message("Adding appendages")
# add_subdirectory(appendages)
#endif()
#
#if(ALL OR ARDUINO_GEN)
# message("Adding ArduinoGen")
# add_subdirectory(arduino_gen)
#endif()
#
#if(ALL OR RIP OR COMMUNICATION OR NAVIGATION OR NAVX OR PATHFINDER OR VISION OR FSM)
# message("Adding RIP Core")
# add_subdirectory(core)
#endif()
#
#if(ALL OR RIPCOM)
# message("Adding RIPCOM")
# add_subdirectory(ripcom)
38 changes: 38 additions & 0 deletions CMakeModules/FileOutputs.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#Macro: make_outputs
#Parameters: rootdir Used for making relative paths
# files Files to be copied
# outdir Destination directory for the files
#Returns: outputs Destination file paths
#
#Use in conjunction with a custom target and add_dependencies to copy files
# when they are changed.
#
#Example usage:
# make_outputs("/home/user/project/data"
# "${data_files}"
# ${CMAKE_CURRENT_BINARY_DIR}/data
# outputs)
# add_executable(my_exe ... ${outputs})
macro(make_outputs rootdir files outdir outputs)
set(_outputs "")
foreach(file ${files})
if((NOT (IS_ABSOLUTE ${file})) AND (EXISTS "${rootdir}/${file}"))
set(file "${rootdir}/${file}") #File is not absolute, but is relative to rootdir
elseif((NOT (IS_ABSOLUTE ${file})) AND (NOT (EXISTS "${rootdir}/${file}")))
message(SEND_ERROR "Filepath '${file}' is not absolute and is not relative to '${rootdir}'")
return()
endif()
file(RELATIVE_PATH file_name ${rootdir} ${file})

add_custom_command(
OUTPUT ${outdir}/${file_name}
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${file}
${outdir}/${file_name}
DEPENDS ${file}
COMMENT "Copying ${file_name}"
VERBATIM)
list(APPEND _outputs ${outdir}/${file_name})
endforeach()
set(${outputs} ${_outputs})
endmacro()
63 changes: 63 additions & 0 deletions Docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# RIP and Docker

How to use Docker to manage building and testing RIP.

## Installing Docker

You need to be using a Linux system in order to use Docker, on Ubuntu

If you're on Ubuntu there are docker packages available in the multiverse, but the CE version from [the official website](https://docs.docker.com/install/linux/docker-ce/ubuntu/) will perform much better and offers newer features.

On MacOS, docker is available and will automatically run a Linux VM for you. On windows, you *can't* use the subsystem, since Docker depends on Linux kernel namespaces.

Once installed, be sure to do whatever group management to your account so that you can run docker without the need of sudo. (For CE, this is something like `adduser $USER docker` and then rebooting.)

## The Dependency Dockerfile

Right now there are two dockerfiles, one that builds the dependencies (onto an Ubuntu base), and one that copies the source code of RIP.

The dependency image is sourced from `external/Dockerfile` and is built automatically by dockerhub, as `utkrobotics/rip_deps`.

To pull the latest deps image:

```docker pull utkrobotics/rip_deps```

This includes g2o, eigen, suitesparse, etc, whatever is needed to build.

## The building / interactive Dockerfile

This is the Dockerfile in the root of the repo.

It's based off the `rip_deps` image so it will have everything needed to build already installed.

Upon building this container image, it will copy all the source code from your current directory into the container and set up an environment ready to run the build.

To build the interactive container:

```
docker build --tag utkrobotics/rip:$(git symbolic-ref HEAD|cut -d'/' -f3-|sed -e 's;/;_;') .
```

This will create an image `utkrobotics/rip:yourbranch` which we can then run and create an instance of:

```
# --rm : removes the container when you exit it
# -t -i : creates an interactive container
# zsh -l : the command to run inside the container (use whatever your preferred shell is)
docker run --rm -t -i utkrobotics/rip:$(git symbolic-ref HEAD|cut -d'/' -f3-|sed -e 's;/;_;') zsh -l
```

Now that you're inside the container, you can immediately build it, mess around, do whatever, because everything you do inside the container is removed when you exit it, and it never affects the code outside the container.

Normally, what I do is:

```
# build dat stuff
./build-linux.sh
# runs the built unit tests
./travis/script.sh
```

While you're in the container, feel free to do whatever you want, `rm -rf *`, or anything. Just remember if you make changes that you want to keep inside the container, you should make those same changes again outside the container on your local git repo.

If you've made changed to your local git repo, you should run the build command again to update the image with your new changes.
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM utkrobotics/rip_deps:latest
# $LUSER is user with 901:901 from home image

# copy in RIP source code
COPY . /home/${LUSER}/code/rip
RUN sudo chown -R 901:901 /home/${LUSER}/code/rip

WORKDIR /home/${LUSER}/code/rip
38 changes: 28 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
# RIP

[![codecov](https://codecov.io/gh/utk-robotics-2017/rip/branch/master/graph/badge.svg?token=KqhG5MRr9F)](https://codecov.io/gh/utk-robotics-2017/rip)

*Version 0.1*

The Robotics Integrated Platform is designed as an all encompassing library for small autonomous robots using a raspberry pi or beaglebone as the primary controller.

## Dependencies
There are two ways to deal with the dependencies of RIP.

1. Use the provided Docker.
2. Install the packages natively on your local machine.

### Docker
See the [Docker Readme](Docker.md).

### Native Install
RIP requires several dependencies -- namely Eigen 3, Suitesparse, G2O, CMake, and GCC/G++ 4.9+. RIP GUIs require QT5.

## How to Contribute
All contributions should be made through our [Git workflow](https://github.com/utk-robotics-2017/rip/wiki/Git-Workflow) and following our [coding standards](https://github.com/utk-robotics-2017/rip/wiki/Coding-Standards).

Once your contributions are ready to be reviewed, please open a pull request to the dev branch. Ideally, mark your PR with the associated issues and the target milestone/version of RIP.

## Quick Start

Expand All @@ -27,21 +46,20 @@ If you'll be working on Arduino Gen, you would switch to one of the `arduino_gen

### Setup CMake
1. Make a directory for the output files (i.e. `build` or `bin`), then go into it.
2. Build for what you're working on.
Replace `<TARGET>` with what you're building for. i.e. Arduino Gen is `ARDUINO_GEN`.
* Linux: `cmake -D <TARGET>=yes ..`
* Windows: `cmake -G "Unix Makefiles" -D <TARGET>=yes ..`
2. Build the project.
* Linux: `cmake ..`
* Windows: `cmake -G "Unix Makefiles" ..`

### Make
Type in `make` and you should start building rip, arduino_gen, etc.
Make can be sped up by passing `-j<N>`, where is `N` is the number of cores on your computer.

## Core

## ArduionGen
### Build Script
Optionally, rather than setting up the CMake build yourself, you may opt to use the included `build-linux.sh` script which will automatically build RIP in `build/` with testing enabled.

## Appendages
## License
**The RIP License (Revision 0.3)**

## Utilities
This software is available without warranty and without support. Use at your own risk. Literally. It might delete your filesystem or eat your cat. As long as you retain this notice, you can do whatever you want with this. If we meet some day, you owe me a beer.

## License
Go Vols!
55 changes: 24 additions & 31 deletions appendages/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,27 @@ target_link_libraries(${PROJECT_NAME}
cmd_messenger misc)
target_include_directories(${PROJECT_NAME} PUBLIC include)

# TODO(Anthony): Refactor to a function or macro
file(GLOB_RECURSE ${PROJECT_NAME}_XMLS "xml/*.xml")
set(copiedXmls "")
foreach(template ${${PROJECT_NAME}_XMLS})
file(RELATIVE_PATH name ${CMAKE_CURRENT_SOURCE_DIR} ${template})
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${name}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${template} ${CMAKE_CURRENT_BINARY_DIR}/${name}
DEPENDS ${template}
COMMENT "Copying ${name}"
VERBATIM)
list(APPEND copiedXmls ${CMAKE_CURRENT_BINARY_DIR}/${name})
endforeach()
add_custom_target(AppendageXmls SOURCES ${copiedXmls})

file(GLOB_RECURSE ${PROJECT_NAME}_JSONS "json/*.json")
set(copiedJsons "")
foreach(template ${${PROJECT_NAME}_JSONS})
file(RELATIVE_PATH name ${CMAKE_CURRENT_SOURCE_DIR} ${template})
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${name}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${template} ${CMAKE_CURRENT_BINARY_DIR}/${name}
DEPENDS ${template}
COMMENT "Copying ${name}"
VERBATIM)
list(APPEND copiedJsons ${CMAKE_CURRENT_BINARY_DIR}/${name})
endforeach()
add_custom_target(AppendageJsons SOURCES ${copiedJsons})

add_custom_target(AppendageTemplates)
add_dependencies(AppendageTemplates AppendageXmls AppendageJsons)
set_property(GLOBAL PROPERTY AppendageRoot ${CMAKE_CURRENT_SOURCE_DIR})

file(GLOB _AppendageXmls "xml/*.xml")
set_property(GLOBAL PROPERTY AppendageXmls ${_AppendageXmls})
file(GLOB _AppendageJsons "json/*.json")
set_property(GLOBAL PROPERTY AppendageJsons ${_AppendageJsons})

include(FileOutputs)

function(make_appendage_xml_outputs outdir xml_outputs)
get_property(_AppendageRoot GLOBAL PROPERTY AppendageRoot)
get_property(_AppendageXmls GLOBAL PROPERTY AppendageXmls)

make_outputs(${_AppendageRoot} "${_AppendageXmls}" ${outdir} _outputs)
set(${xml_outputs} ${_outputs} PARENT_SCOPE)
endfunction()

function(make_appendage_json_outputs outdir json_outputs)
get_property(_AppendageRoot GLOBAL PROPERTY AppendageRoot)
get_property(_AppendageJsons GLOBAL PROPERTY AppendageJsons)

make_outputs(${_AppendageRoot} "${_AppendageJsons}" ${outdir} _outputs)
set(${json_outputs} ${_outputs} PARENT_SCOPE)
endfunction()
Loading

0 comments on commit 51cfc06

Please sign in to comment.