Skip to content

Commit

Permalink
Merge pull request #9 from usdot-fhwa-stol/release/RX7
Browse files Browse the repository at this point in the history
Release/rx7
  • Loading branch information
darrelld05 authored Jul 17, 2019
2 parents c8f89ba + 18a0740 commit 20727a9
Show file tree
Hide file tree
Showing 10 changed files with 425 additions and 0 deletions.
99 changes: 99 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
version: 2
# Copyright (C) 2018-2019 LEIDOS.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#

# Configuration file for Circle CI
# CI will report failure if any executed command returns and error status
# Operations performed are as follows
# Build source code
# Run unit tests for C++ and Java
# Run static code analyzer for SourceCloud
# Upload test results
# Every run command should start with source ${INIT_ENV} to ensure all default dependancies are available

jobs:
build:
# Pull docker image from docker hub
# XTERM used for better catkin_make output
docker:
- image: usdotfhwastol/carma-base-ci:2.8.4
user: carma
environment:
TERM: xterm # use xterm to get full display output from build
INIT_ENV: /home/carma/.base-image/init-env.sh
working_directory: "/opt/carma/"
# Execution steps
steps:
- run:
name: Create src folder
command: |
source ${INIT_ENV}
mkdir src
cd src
mkdir CARMAVelodyneLidarDriver
mkdir CARMAMsgs
- checkout:
path: src/CARMAVelodyneLidarDriver
- run:
name: Pull CARMAMsgs
command: |
source ${INIT_ENV}
git clone -b develop --depth 1 git@github.com:usdot-fhwa-stol/CARMAMsgs.git src/CARMAMsgs
- run:
name: Pull CARMADriverUtils
command: |
source ${INIT_ENV}
git clone -b develop --depth 1 git@github.com:usdot-fhwa-stol/CARMADriverUtils.git src/CARMADriverUtils
- run:
name: Build Driver
command: |
source ${INIT_ENV}
build-wrapper-linux-x86-64 --out-dir /opt/carma/bw-output bash make_with_coverage.bash -m -e /opt/carma/ -o ./coverage_reports/gcov
- run:
name: Run C++ Tests
command: |
source ${INIT_ENV}
bash make_with_coverage.bash -t -e /opt/carma/ -o ./coverage_reports/gcov
# Run SonarCloud analysis
# PR Branchs and number extracted from Circle variables and github api
# Circle CI seems to make a change to the base branch, so we must fetch --force to ensure correct git file change stats
# SONAR_SCANNER_TOKEN MUST be secured as an environment variable in Circle CI NOT in this file.
# The following sonar settings MUST be set in SonarCloud UI NOT in this file
# sonar.pullrequest.provider
# sonar.pullrequest.github.endpoint
# sonar.pullrequest.github.token.secured
# sonar.pullrequest.github.repository
# Use -X on sonar-scanner to enable debug output
- run:
name: Run Sonar Scanner
command: |
source ${INIT_ENV}
if [ -z "${CIRCLE_PULL_REQUEST}" ]; then
echo "Non-PR Build Detected. Running analysis on ${CIRCLE_BRANCH}"
cd src/CARMAVelodyneLidarDriver
sonar-scanner -Dproject.settings=.sonarqube/sonar-scanner.properties -Dsonar.login=${SONAR_SCANNER_TOKEN}
exit 0;
fi
echo "PR branch ${CIRCLE_BRANCH}"
echo "Repo name ${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}"
echo "URL ${CIRCLE_PULL_REQUEST}"
export PR_NUM=`echo ${CIRCLE_PULL_REQUEST} | cut -d'/' -f7`
echo "PR number ${PR_NUM}"
export BASE_BRANCH_URL="https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/pulls/${PR_NUM}"
export TARGET_BRANCH=$(curl "$BASE_BRANCH_URL" | jq '.base.ref' | tr -d '"')
echo "Target Branch = ${TARGET_BRANCH}"
cd src/CARMAVelodyneLidarDriver
git fetch --force origin ${TARGET_BRANCH}:${TARGET_BRANCH}
sonar-scanner -Dproject.settings=.sonarqube/sonar-scanner.properties -Dsonar.login=${SONAR_SCANNER_TOKEN} -Dsonar.pullrequest.base=${TARGET_BRANCH} -Dsonar.pullrequest.branch=${CIRCLE_BRANCH} -Dsonar.pullrequest.key=${PR_NUM}
27 changes: 27 additions & 0 deletions .sonarqube/sonar-scanner.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (C) 2018-2019 LEIDOS.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

# Configuration file for Sonar Scanner used for CI

sonar.projectKey=usdot-fhwa-stol_CARMAVelodyneLidarDriver
sonar.organization=usdot-fhwa-stol
sonar.cfamily.build-wrapper-output=/opt/carma/bw-output
sonar.host.url=https://sonarcloud.io
sonar.sources=velodyne_lidar_driver_wrapper/src/
# sonar.cfamily.gcov.reportsPath=/opt/carma/coverage_reports/gcov
# sonar.tests=velodyne_lidar_driver_wrapper/test/
# Set Git as SCM sensor
sonar.scm.disabled=false
sonar.scm.enabled=true
sonar.scm.provider=git
92 changes: 92 additions & 0 deletions velodyne_lidar_driver_wrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
cmake_minimum_required(VERSION 2.8.3)
project(velodyne_lidar_driver_wrapper)

## Compile as C++11, supported in ROS Kinetic and newer
add_compile_options(-std=c++11)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
cav_driver_utils
cav_msgs
sensor_msgs
roscpp
)

###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if your package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
LIBRARIES ${PROJECT_NAME}
CATKIN_DEPENDS cav_driver_utils cav_msgs sensor_msgs roscpp
)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
include
${catkin_INCLUDE_DIRS}
)

## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
## The recommended prefix ensures that target names across packages don't collide
file(GLOB_RECURSE headers */*.hpp */*.h)
add_executable( ${PROJECT_NAME}_node
${headers}
src/main.cpp
src/velodyne_lidar_driver_wrapper.cpp)

## Specify libraries to link a library or executable target against
target_link_libraries( ${PROJECT_NAME}_node ${catkin_LIBRARIES})

#############
## Install ##
#############

# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html

## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# install(PROGRAMS
# scripts/my_python_script
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )

## Mark executables and/or libraries for installation
install(TARGETS ${PROJECT_NAME}_node
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

## Mark cpp header files for installation
install(DIRECTORY include/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn" EXCLUDE
)

## Mark other files for installation (e.g. launch and bag files, etc.)
install(DIRECTORY
launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

#############
## Testing ##
#############


2 changes: 2 additions & 0 deletions velodyne_lidar_driver_wrapper/config/parameters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Timeout threshold for point cloud message, in seconds
point_cloud_timeout: 0.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#pragma once

/*
* Copyright (C) 2019 LEIDOS.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

#include <driver_wrapper/driver_wrapper.h>
#include <sensor_msgs/PointCloud2.h>

class VelodyneLidarDriverWrapper : public cav::DriverWrapper
{

public:
VelodyneLidarDriverWrapper(int argc, char **argv, const std::string &name = "velodyne_lidar_driver_wrapper");
virtual ~VelodyneLidarDriverWrapper();

private:

ros::Subscriber point_cloud_sub_;
ros::Time last_update_time_;
double point_cloud_timeout_;

/**
* @brief Callback for handling point cloud message
*/
void point_cloud_cb(const sensor_msgs::PointCloud2ConstPtr& msg);

/**
* @brief Check lidar data output timeout
*/
void checkLidarTimeout();

//cav::DriverWrapper members
virtual void initialize();
virtual void pre_spin();
virtual void post_spin();
virtual void shutdown();

};
35 changes: 35 additions & 0 deletions velodyne_lidar_driver_wrapper/launch/velodyne_lidar_driver.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0"?>
<!--
Copyright (C) 2018-2019 LEIDOS.
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
-->
<!--
This file is used to launch a CARMA compatible lidar driver for velodyne VLP-32C
-->
<launch>

<arg name="frame_id" default="velodyne" doc="The frame id to use for the scan data"/>
<arg name="device_ip" default="192.168.1.201" doc="Ip address of velodyne device"/>

<!-- Launch Wrapper -->
<remap from="velodyne_points" to="lidar/points_raw"/>
<include file="$(find velodyne_lidar_driver_wrapper)/launch/velodyne_lidar_wrapper.launch"/>

<!-- Launch Wrapped Nodes -->
<include file="$(find velodyne_pointcloud)/launch/VLP-32C_points.launch">
<arg name="frame_id" value="$(arg frame_id)" />
<arg name="device_ip" value="$(arg device_ip)" />
</include>

</launch>
26 changes: 26 additions & 0 deletions velodyne_lidar_driver_wrapper/launch/velodyne_lidar_wrapper.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0"?>
<!--
Copyright (C) 2018-2019 LEIDOS.
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
-->
<!--
This file is used to launch a ros wrapper which can be combined with public velodyne drivers to make them CARMA compatible
-->
<launch>
<node name="velodyne_lidar_driver_wrapper" pkg="velodyne_lidar_driver_wrapper" type="velodyne_lidar_driver_wrapper_node" output="screen"/>
<rosparam command="load" file="$(find velodyne_lidar_driver_wrapper)/config/parameters.yaml" />

<node pkg="topic_tools" type="relay" name="relay_points_raw" args="/velodyne_points /lidar/points_raw" />
<node pkg="topic_tools" type="relay" name="relay_lidar_scan" args="/scan /lidar/scan" />
</launch>
14 changes: 14 additions & 0 deletions velodyne_lidar_driver_wrapper/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<package format="2">
<name>velodyne_lidar_driver_wrapper</name>
<version>0.0.1</version>
<description>CARMA velodyne lidar driver wrapper package</description>
<maintainer email="carma@todo.todo">carma</maintainer>
<license>Apache 2.0</license>
<author email="carma@todo.todo">carma</author>
<buildtool_depend>catkin</buildtool_depend>
<depend>cav_driver_utils</depend>
<depend>cav_msgs</depend>
<depend>sensor_msgs</depend>
<depend>roscpp</depend>
</package>
23 changes: 23 additions & 0 deletions velodyne_lidar_driver_wrapper/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (C) 2019 LEIDOS.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

#include "velodyne_lidar_driver_wrapper.h"

int main(int argc, char**argv)
{
VelodyneLidarDriverWrapper wrapper(argc,argv);
return wrapper.run();
}
Loading

0 comments on commit 20727a9

Please sign in to comment.