Skip to content

Commit

Permalink
Fix unit tests (nasa#47)
Browse files Browse the repository at this point in the history
Fix unit tests and run them in github continuous integration.

Co-authored-by: Katie Browne <[email protected]>
  • Loading branch information
marinagmoreira and kbrowne15 authored Sep 30, 2020
1 parent 11c49b2 commit e52c243
Show file tree
Hide file tree
Showing 42 changed files with 217 additions and 146 deletions.
35 changes: 0 additions & 35 deletions .github/workflows/CI-build.yml

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Docker Image CI

on:
push:
branches: [ 'master', 'develop' ]
pull_request:
branches: [ 'master', 'develop' ]

jobs:

build-kinetic:

runs-on: ubuntu-16.04

steps:
- uses: actions/checkout@v2

- name: Checkout submodule
run: git submodule update --init --depth 1 description/media

- name: Build code for Ubuntu 16
run: docker build . -f ./scripts/docker/astrobee_kinetic.Dockerfile -t astrobee/astrobee:latest-kinetic

- name: Test code
run: docker build . -f ./scripts/docker/test_astrobee_kinetic.Dockerfile -t test

build-melodic:

runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v2

- name: Checkout submodule
run: git submodule update --init --depth 1 description/media

- name: Build code for Ubuntu 18
run: docker build . -f ./scripts/docker/astrobee_melodic.Dockerfile -t astrobee/astrobee:latest-melodic

- name: Test code
run: docker build . -f ./scripts/docker/test_astrobee_melodic.Dockerfile -t test
2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ jobs:
git config user.email "$EMAIL"
git config user.name "$NAME"
git commit -m "Automatic update for $GITHUB_SHA."
git push origin gh-pages
{ git push origin gh-pages || true; }
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Check for lint errors
on: ['push', 'pull_request']

jobs:
build_and_push_docs:
lint_check:
runs-on: ubuntu-latest

steps:
Expand Down
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,13 @@ else (USE_CTC)
endif (USE_CTC)

# Bring in catkin
set(CATKIN_SKIP_TESTING ON CACHE BOOL "NO")
set(CATKIN_SKIP_TESTING OFF)
if (USE_CTC)
# Catkin brings in GTest as a dependency. We don't want it because
# we have our own ... on top of that it doesn't build correctly for
# ARM. Our own unit tests however will continue to
# work. (non-catkin)
set(CATKIN_ENABLE_TESTING OFF)
set(CATKIN_SKIP_TESTING OFF)
endif (USE_CTC)
if (USE_ROS)
set(ENV{ROS_LANG_DISABLE} "genlisp:gennodejs:geneus:$ENV{ROS_LANG_DISABLE}")
Expand Down
8 changes: 4 additions & 4 deletions astrobee/config/management/fault_table.config
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ subsystems={
}},
}},
{name="mobility", nodes={
--{name="mapper", faults={
--{id=41, warning=false, blocking=false, response=command("noOp"), key="HEARTBEAT_MISSING", description="No Heartbeat from Mapper", heartbeat={timeout_sec=1.1, misses=2.0}},
--{id=80, warning=false, blocking=false, response=command("unloadNodelet", "mapper", ""), key="INITIALIZATION_FAILED", description="Mapper Initialization Failed"},
--}},
{name="mapper", faults={
{id=41, warning=false, blocking=false, response=command("noOp"), key="HEARTBEAT_MISSING", description="No Heartbeat from Mapper", heartbeat={timeout_sec=1.1, misses=2.0}},
{id=80, warning=false, blocking=false, response=command("unloadNodelet", "mapper", ""), key="INITIALIZATION_FAILED", description="Mapper Initialization Failed"},
}},
{name="planner_qp", faults={
{id=39, warning=false, blocking=false, response=command("noOp"), key="HEARTBEAT_MISSING", description="No Heartbeat from QP Planner", heartbeat={timeout_sec=1.1, misses=5.0}},
{id=78, warning=false, blocking=false, response=command("unloadNodelet", "planner_qp", ""), key="INITIALIZATION_FAILED", description="QP Planner Initialization Failed"},
Expand Down
17 changes: 9 additions & 8 deletions astrobee/config/worlds/mgtf.config
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ require "rotations"
-- Location of the dock and berth tilt values (in degrees)
world_dock_berth1_tilt = math.rad(0) -- Tilt in body-frame Y
world_dock_berth2_tilt = math.rad(0) -- Tilt in body-frame Y
world_dock_transform = transform(0.0, 0.0, 0.0),
quat4(0.0, 0.0, 1.0, 1.0));
world_dock_transform = transform(
vec3(0.0, 0.0, 0.0), quat4(0.0, 0.0, 0.0, 1.0));

--------------------------
-- MOBILITY --
Expand Down Expand Up @@ -58,12 +58,13 @@ world_gravity_vector = vec3(0.0, 0.0, 9.80665);
--------------------------

-- Inertial Parameters
-- Default assumes freeflyer, no payloads, 4 batteries, measured EEl 2/26/2019
world_inertia_name = "default";
world_inertia_com = vec3(0.0, 0.0, 0.0); -- Center of mass
world_inertia_mass = 7.0; -- Platform mass
world_inertia_matrix = matrix{{.1083, 0, 0},
{0, .1083, 0},
{0, 0, .1083}}; -- Inertia matrix
world_inertia_com = vec3(0.003713818, -0.000326347, -0.002532192); -- Center of mass
world_inertia_mass = 9.583788668; -- Platform + 4 batteries
world_inertia_matrix = matrix{{0.153427995, 0, 0},
{0, 0.14271405, 0},
{0, 0, 0.162302759}}; -- Inertia matrix

--------------------------
-- FLIGHT MODES --
Expand Down Expand Up @@ -407,7 +408,7 @@ world_visualeyez_grounding = {
{ tcm=1, led=2, x=0.1835635587737848, y=-3.219100563007645, z=-0.2319006270806013 },
{ tcm=1, led=3, x=1.043904870248541, y=-3.219100563007645, z= 0.6628505519526655 },
{ tcm=1, led=4, x=1.110810070079649, y=-2.050167430479354, z=-0.2681018912672751 }
};
}

-- Visualeyez target matrix
world_visualeyez_targets = {
Expand Down
1 change: 0 additions & 1 deletion gnc/ctl/test/test_ctl.test
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

<launch>
<include file="$(find astrobee)/launch/sim.launch">
<arg name="gui" value="false"/>
<arg name="dds" value="false"/>
</include>
<test pkg="ctl" type="test_ctl" test-name="test_ctl" />
Expand Down
2 changes: 1 addition & 1 deletion gnc/ctl/test/test_ctl_nominal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void StateCallback(const ff_msgs::EkfStateConstPtr& state) {

// Holonomic test
TEST(ctl_nominal, Holonomic) {
// The default namespace is given by the group hierarchy in the luanch file
// The default namespace is given by the group hierarchy in the launch file
ros::NodeHandle nh;
// Wait for the servcer
ac = std::shared_ptr<actionlib::SimpleActionClient<ff_msgs::ControlAction>>(
Expand Down
12 changes: 12 additions & 0 deletions hardware/pico_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ create_library(TARGET ${PROJECT_NAME}
INC ${catkin_INCLUDE_DIRS} ${royale_INCLUDE_DIRS}
)

if(CATKIN_ENABLE_TESTING)
# Pico flexx initialization fault tester
add_rostest_gtest(test_init_pico_flexx
test/test_init_pico_flexx.test
test/test_init_pico_flexx.cc
)

target_link_libraries(test_init_pico_flexx
${catkin_LIBRARIES} config_reader ff_nodelet
)
endif()

create_tool_targets(DIR tools
LIBS ${catkin_LIBRARIES} ${royale_LIBRARIES} uvc
INC ${catkin_INCLUDE_DIRS} ${royale_INCLUDE_DIRS}
Expand Down
14 changes: 7 additions & 7 deletions localization/camera/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ set(INCLUDES
${Boost_INCLUDE_DIRS}
)

catkin_package(
INCLUDE_DIRS include
LIBRARIES camera
CATKIN_DEPENDS
# DEPENDS system_lib
)

create_library(TARGET camera
LIBS ${LIBS}
INC ${INCLUDES}
Expand All @@ -58,4 +51,11 @@ create_test_targets(DIR test
INC ${INCLUDES} ${CERES_INCLUDE_DIRS}
)

catkin_package(
INCLUDE_DIRS include
LIBRARIES camera
CATKIN_DEPENDS
# DEPENDS system_lib
)

set(CAMERA_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE)
14 changes: 7 additions & 7 deletions localization/interest_point/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ set(INCLUDES
${GLOG_INCLUDE_DIRS}
)

catkin_package(
INCLUDE_DIRS include
LIBRARIES interest_point
CATKIN_DEPENDS
# DEPENDS system_lib
)

create_library(TARGET interest_point
LIBS ${LIBS}
INC ${INCLUDES}
Expand All @@ -62,5 +55,12 @@ create_test_targets(DIR test
INC ${INCLUDES}
)

catkin_package(
INCLUDE_DIRS include
LIBRARIES interest_point
CATKIN_DEPENDS
# DEPENDS system_lib
)

set(INTEREST_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE)

5 changes: 1 addition & 4 deletions localization/marker_tracking/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,13 @@ create_library(TARGET marker_tracking
LIBS ${LIBS}
INC ${INCLUDES}
DEPS camera)

if (YAMLCPP_FOUND)
create_tool_targets(DIR tools
LIBS marker_tracking ${YAMLCPP_LIBRARIES}
INC ${INCLUDES})
endif (YAMLCPP_FOUND)
create_test_targets(DIR test
LIBS marker_tracking
INC ${INCLUDES})

if (USE_ROS)
add_subdirectory(ros)
endif (USE_ROS)

26 changes: 26 additions & 0 deletions localization/marker_tracking/ros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,32 @@ create_tool_targets(DIR tools
DEPS rosmarkertracking
)

if(CATKIN_ENABLE_TESTING)
find_package(rostest REQUIRED)
add_rostest_gtest(test_arxmlio test/test_arxmlio.test
test/test_arxmlio.cc
)
target_link_libraries(test_arxmlio
marker_tracking
)

find_package(rostest REQUIRED)
add_rostest_gtest(test_marker_config_loader test/test_marker_config_loader.test
test/test_marker_config_loader.cc
)
target_link_libraries(test_marker_config_loader
marker_tracking
)

find_package(rostest REQUIRED)
add_rostest_gtest(test_marker_detector test/test_marker_detector.test
test/test_marker_detector.cc
)
target_link_libraries(test_marker_detector
marker_tracking
)
endif()

install_launch_files()
install(FILES
tools/features_counter.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <string>

TEST(AR_XML_IO, Reading) {
std::string data_dir = std::string(TEST_DIR) + "/data/";
std::string data_dir = std::string(std::getenv("DATA_DIR"));

marker_tracking::ARTagMap ar_tags;
marker_tracking::LoadARTagLocation(data_dir + "ar_lab_tags.xml",
Expand Down
21 changes: 21 additions & 0 deletions localization/marker_tracking/ros/test/test_arxmlio.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- Copyright (c) 2017, United States Government, as represented by the -->
<!-- Administrator of the National Aeronautics and Space Administration. -->
<!-- -->
<!-- All rights reserved. -->
<!-- -->
<!-- The Astrobee platform is 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. -->

<launch>
<env name="DATA_DIR" value="$(find marker_tracking)/test/data/" />
<test pkg="marker_tracking" type="test_arxmlio" test-name="test_arxmlio" />
</launch>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <string>

TEST(MarkerDetector, ConfigLoader) {
std::string data_dir = std::string(TEST_DIR) + std::string("/data/");
std::string data_dir = std::string(std::getenv("DATA_DIR"));
std::string filename = std::string("markers_sample.config");
config_reader::ConfigReader config;
config.AddFile((data_dir + filename).c_str());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Copyright (c) 2017, United States Government, as represented by the -->
<!-- Administrator of the National Aeronautics and Space Administration. -->
<!-- -->
<!-- All rights reserved. -->
<!-- -->
<!-- The Astrobee platform is 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. -->

<launch>
<env name="ASTROBEE_CONFIG_DIR" value="$(find astrobee)/config/tests" />
<env name="DATA_DIR" value="$(find marker_tracking)/test/data/" />
<test pkg="marker_tracking" type="test_marker_config_loader" test-name="test_marker_config_loader" />
</launch>
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <vector>

TEST(MarkerDetector, TestDetection) {
std::string data_dir = std::string(TEST_DIR) + "/data/";
std::string data_dir = std::string(std::getenv("DATA_DIR"));

// Create a fake alvar camera for our work.
camera::CameraParameters cam(Eigen::Vector2i(816, 612),
Expand Down
21 changes: 21 additions & 0 deletions localization/marker_tracking/ros/test/test_marker_detector.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- Copyright (c) 2017, United States Government, as represented by the -->
<!-- Administrator of the National Aeronautics and Space Administration. -->
<!-- -->
<!-- All rights reserved. -->
<!-- -->
<!-- The Astrobee platform is 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. -->

<launch>
<env name="DATA_DIR" value="$(find marker_tracking)/test/data/" />
<test pkg="marker_tracking" type="test_marker_detector" test-name="test_marker_detector" />
</launch>
Loading

0 comments on commit e52c243

Please sign in to comment.