Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
asherikov committed Jan 3, 2025
1 parent 5819d23 commit c19b109
Show file tree
Hide file tree
Showing 12 changed files with 507 additions and 69 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/ws_2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,25 @@ jobs:
- uses: actions/checkout@v4
with:
path: src/ariles_ws
- run: mv src/ariles_ws/demo/plain/package.xml.disable package.xml
- run: make bp_install_build BUILD_PROFILE=reldebug
- run: make dep_install PKG=ariles2_plain_demo
- run: make ariles2_plain_demo
- run: make dep_install PKG=ariles2_ros2param_ws
- run: make ariles2_ros2param_ws

noble_ccws:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
repository: asherikov/ccws
- uses: actions/checkout@v4
with:
path: src/ariles_ws
- run: mv src/ariles_ws/demo/plain/package.xml.disable package.xml
- run: make bp_install_build BUILD_PROFILE=reldebug
- run: make dep_install PKG=ariles2_plain_demo
- run: make ariles2_plain_demo
- run: make dep_install PKG=ariles2_ros2param_ws
- run: make ariles2_ros2param_ws
2 changes: 1 addition & 1 deletion .make/ariles.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ VERSION?="XXX__version_not_set__XXX"


REPO=https://github.com/asherikov/ariles.git
DEPENDENCY_PATH=./demo
DEPENDENCY_PATH=./demo/
DEBIAN_SYSTEM_DEPENDENCIES=libeigen3-dev octave libyaml-cpp-dev rapidjson-dev libpugixml-dev libboost-all-dev


Expand Down
11 changes: 5 additions & 6 deletions .make/ros.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ WS_PKGS= \
ariles2_rosparam_ws \
ariles2_pugixml_ws

CATKIN_DEPENDENCY_TEST_PKG=ariles2_ws_demo
CATKIN_DEPENDENCY_TEST_PKG=ariles2_catkin_demo
CATKIN_ARGS=--cmake-args -DARILES_ROS_ENABLE_TESTS=ON
CATKIN_TARGETS=all test

Expand Down Expand Up @@ -76,7 +76,7 @@ catkin_test_deb: clean
echo ${WS_PKGS} | tr " " "\n" | xargs -I {} ${MAKE} catkin_test_deb_pkg PKG="{}" ROS_DISTRO=${ROS_DISTRO}
bash -c 'source /opt/ros/${ROS_DISTRO}/setup.bash; \
cd build/dependency_test; \
cmake ../../${DEPENDENCY_PATH}/; \
cmake ../../${DEPENDENCY_PATH}/plain_ros1; \
${MAKE} ${MAKE_FLAGS}'


Expand Down Expand Up @@ -105,7 +105,7 @@ catkin_old_deb: catkin_prepare_workspace
${MAKE} catkin_test_deb
${MAKE} catkin_prepare_workspace
cd ${CATKIN_PKGS_PATH}/; ls -1A | grep -v demo | xargs rm -Rf
cd ${CATKIN_PKGS_PATH}/demo; mv package.xml.disable package.xml
cd ${DEPENDENCY_PATH}/catkin; mv package.xml.disable package.xml
cd ${CATKIN_WORKING_DIR}/src; catkin_init_workspace
cd ${CATKIN_WORKING_DIR}; catkin_make_isolated --pkg ${CATKIN_DEPENDENCY_TEST_PKG}
sudo ${MAKE} clean_deb clean_rosdep
Expand All @@ -116,15 +116,15 @@ catkin_new_build: catkin_prepare_workspace
cd ${CATKIN_WORKING_DIR}; catkin build -i --verbose --summary ${WS_PKGS} --make-args ${CATKIN_TARGETS} ${CATKIN_ARGS}

catkin_new_build_with_dependent: catkin_prepare_workspace
cd ${CATKIN_PKGS_PATH}/demo; mv package.xml.disable package.xml
cd ${DEPENDENCY_PATH}/catkin; mv package.xml.disable package.xml
cd ${CATKIN_WORKING_DIR}; catkin init
cd ${CATKIN_WORKING_DIR}; catkin build -i --verbose --summary ${CATKIN_DEPENDENCY_TEST_PKG}

catkin_new_deb:
${MAKE} catkin_test_deb
${MAKE} catkin_prepare_workspace
cd ${CATKIN_PKGS_PATH}; ls -1A | grep -v demo | xargs rm -Rf
cd ${CATKIN_PKGS_PATH}/demo; mv package.xml.disable package.xml
cd ${DEPENDENCY_PATH}/catkin; mv package.xml.disable package.xml
cd ${CATKIN_WORKING_DIR}; catkin init
cd ${CATKIN_WORKING_DIR}; catkin build -i --verbose --summary ${CATKIN_DEPENDENCY_TEST_PKG}
sudo ${MAKE} clean_deb
Expand Down Expand Up @@ -162,7 +162,6 @@ ros_prerelease: ros_prerelease_deps
cd ./build/ros_prerelease; sed -i "s|\(-e=TRAVIS\)|-eCCACHE_DIR=./.ccache/ \1|" *.sh
cd ./build/ros_prerelease; env ABORT_ON_TEST_FAILURE=1 CCACHE_DIR=`pwd`/.ccache ./prerelease.sh


# docker
#----------------------------------------------
ros_make_docker:
Expand Down
61 changes: 0 additions & 61 deletions demo/CMakeLists.txt

This file was deleted.

38 changes: 38 additions & 0 deletions demo/catkin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
cmake_minimum_required(VERSION 2.8.12)

set(CMAKE_VERBOSE_MAKEFILE ON)

project(ariles2_catkin_demo)

find_package(catkin REQUIRED
ariles2_core_ws
ariles2_rosparam_ws
ariles2_rapidjson_ws
ariles2_yamlcpp_ws
ariles2_octave_ws
ariles2_pugixml_ws
)

catkin_package(DEPENDS
ariles2_core_ws
ariles2_rosparam_ws
ariles2_rapidjson_ws
ariles2_yamlcpp_ws
ariles2_octave_ws
ariles2_pugixml_ws
)

include_directories(
include
SYSTEM ${catkin_INCLUDE_DIRS}
)

add_executable(demo demo.cpp)

target_link_libraries(demo ${catkin_LIBRARIES})

install(TARGETS demo
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<package format="2">
<name>ariles2_ws_demo</name>
<name>ariles2_catkin_demo</name>
<version>0.0.0</version>
<description>ariles2 demo / dependency test</description>

Expand Down
22 changes: 22 additions & 0 deletions demo/plain/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 2.8.12)

set(CMAKE_VERBOSE_MAKEFILE ON)


project(ariles2_plain_demo)

find_package(ariles2-core REQUIRED)
find_package(ariles2-rapidjson REQUIRED)
find_package(ariles2-yaml-cpp REQUIRED)
find_package(ariles2-octave REQUIRED)
find_package(ariles2-pugixml REQUIRED)


add_executable(demo demo.cpp)
target_link_libraries(demo
ariles2::core
ariles2::rapidjson
ariles2::yaml-cpp
ariles2::octave
ariles2::pugixml
)
175 changes: 175 additions & 0 deletions demo/plain/demo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
/**
@file
@author Alexander Sherikov
@copyright 2018 Alexander Sherikov, Licensed under the Apache License, Version 2.0.
(see @ref LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
@brief
*/


// ============================================================================
// HEADER INCLUSION
// ============================================================================

// `visitor` is an Ariles component which provides integration with a particular
// 3rd party library.
#include <ariles2/visitors/yaml_cpp.h>
#include <ariles2/visitors/octave.h>
#include <ariles2/visitors/pugixml.h>

// `adapter` is an Ariles component which adds support for serialization of
// certain type(s), e.g. Eigen types or Boost pointers.
#include <ariles2/adapters/basic.h>
#include <ariles2/adapters/eigen.h>
#include <ariles2/adapters/std_vector.h>
#include <ariles2/ariles.h>



// ===============================================================
// DEFINING TYPES
// ===============================================================
namespace demo
{
class ArilesBaseClass
// must inherit from ariles2::DefaultBase
: public ariles2::DefaultBase
{
// Declare entries, in this case two numbers
#define ARILES2_ENTRIES(v) \
ARILES2_TYPED_ENTRY(v, real_member, double) \
ARILES2_TYPED_ENTRY_(v, integer_member, int)
// underscore ^ indicates that the name of the entry must be
// 'integer_member_' instead of 'integer_member', this is useful if your
// naming convention requires trailing underscores for member variables.

// Initialize ariles
#include ARILES2_INITIALIZE

public:
virtual ~ArilesBaseClass(){}; // added to suppress compiler warnings

// This method is called every time you deserialize a class. If
// omitted, the default automatically generated method is used.
void arilesVisit(const ariles2::Defaults & /*visitor*/, const ariles2::Defaults::Parameters & /*param*/)
{
real_member = 0.0;
integer_member_ = 12;
}
};


class NonArilesBaseClass
{
public:
// Eigen types are supported too, see below
Eigen::Vector3d eigen_vector_;
};


class MyClass : public ArilesBaseClass, // no need to inherit from ConfigurableBase directly.
public NonArilesBaseClass
{
// Declare entries, in this case we indicate inheritance from another
// Ariles class (ArilesBaseClass) and a member from a non-Ariles class
// (NonArilesBaseClass)
#define ARILES2_ENTRIES(v) \
ARILES2_PARENT(v, ArilesBaseClass) \
ARILES2_ENTRY_(v, eigen_vector)
// In this case ^ Ariles should not declare the inherited
// member, therefore we use 'ARILES2_ENTRY_' instead of 'ARILES2_TYPED_ENTRY_'.

#include ARILES2_INITIALIZE


public:
virtual ~MyClass(){}; // added to suppress compiler warnings


void arilesVisit(const ariles2::Defaults &visitor, const ariles2::Defaults::Parameters &param)
{
// If you use your own method to initialize member variables,
// it is up to you to properly initialize all entries and
// parent classes.
// all parents at once
arilesVisitParents(visitor, param);
// or one by one (either option is sufficient)
ArilesBaseClass::arilesVisit(visitor, param);

// custom default values for some members
real_member = 100.0;
eigen_vector_.setZero();
}
};


class MyContainerClass : public ariles2::DefaultBase
{
// Some of the standard containers can be used with Ariles types.
#define ARILES2_ENTRIES(v) ARILES2_TYPED_ENTRY_(v, my_class_vector, std::vector<MyClass>)
#include ARILES2_INITIALIZE
};
} // namespace demo


// ===============================================================
// SERIALIZATION & DESERIALIZATION
// ===============================================================

#include <iostream> // std::cout

int main()
{
demo::MyContainerClass my_container_class;

// access members as usual
my_container_class.my_class_vector_.size();
my_container_class.my_class_vector_.push_back(demo::MyClass());
ariles2::apply<ariles2::Defaults>(my_container_class.my_class_vector_[0]);


// YAML
/*
* When you serialize `my_container_class` to YAML you get the following:
* -----
MyContainerClass:
my_class_vector:
- real_member: 100
integer_member: 12
eigen_vector: [0, 0, 0]
* -----
* Note that the trailing underscores are omitted for all members. This
* applies to all supported representations.
*/
{
// You can read and write YAML configuration files as follows:
ariles2::apply<ariles2::yaml_cpp::Writer>("config.yaml", my_container_class);
ariles2::apply<ariles2::yaml_cpp::Reader>("config.yaml", my_container_class);

// Sometimes it may be useful to dump configuration to std::cout
ariles2::apply<ariles2::yaml_cpp::Writer>(std::cout, my_container_class);

// In some situations it is more convenient to instantiate Reader and
// Writer classes explicitly, e.g., if you keep configurations of several
// classes in the same file
ariles2::yaml_cpp::Writer writer("config.yaml");
ariles2::apply(writer, my_container_class);

ariles2::yaml_cpp::Reader reader("config.yaml");
ariles2::apply(reader, my_container_class);
}


// Octave
{
// Octave visitor supports only writing
ariles2::apply<ariles2::octave::Writer>("debug.m", my_container_class);
// the generated file can later be loaded in Octave with
// 'source debug.m' for debugging
}


return (0);
}
Loading

0 comments on commit c19b109

Please sign in to comment.