Skip to content

Commit

Permalink
Minor updates
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Tudela <ajtudela@gmail.com>
  • Loading branch information
ajtudela committed Apr 18, 2024
1 parent b4d74bf commit 1710b01
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 77 deletions.
11 changes: 1 addition & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,4 @@ jobs:
files: ros_ws/lcov/total_coverage.info,ros_ws/coveragepy/.coverage
flags: unittests
name: codecov-umbrella
slug: grupo-avispa/scitos2
- name: Upload cpp coverage to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.COVERALLS_REPO_TOKEN }}
fail-on-error: true
flag-name: unittests
debug: true
files: ros_ws/lcov/total_coverage.info,ros_ws/coveragepy/.coverage
format: lcov
slug: grupo-avispa/scitos2
122 changes: 73 additions & 49 deletions scitos2_common/cmake/mira_package.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,73 +4,97 @@
# @public
#
macro(find_mira_path)
message(STATUS "Detecting MIRA root directory")

# Examines each path in MIRA_PATH in order to find the MIRA root directory, which
# is identified by the file "make/Insource.make"
SET(ENV{MIRA_PATH} "$ENV{MIRA_PATH}:/opt/mira:${CMAKE_SOURCE_DIR}")
SET(FORCE_USE_QT5 1)

set(FindMIRARoot_MIRA_PATH "$ENV{MIRA_PATH}")
if(UNIX)
# note: the "" around "${MIRA_PATH}" are very important !
string(REPLACE ":" ";" FindMIRARoot_MIRA_PATH "${FindMIRARoot_MIRA_PATH}")
endif()

set(FOUND_MIRA_ROOT_DIR 0)
set(MIRA_ROOT_DIR "")
FOREACH(path ${FindMIRARoot_MIRA_PATH})
GET_FILENAME_COMPONENT(pathComponent ${path} ABSOLUTE)
# strip any trailing slashes from every path in MIRA_PATH env
MESSAGE(STATUS "Examining ${pathComponent}")

if(EXISTS "${pathComponent}/mira.root")
MESSAGE(STATUS "found valid ${pathComponent}")
set(FOUND_MIRA_ROOT_DIR 1)
set(MIRA_ROOT_DIR ${pathComponent})
endif()
ENDFOREACH(path)
MESSAGE(STATUS "MIRA_ROOT_DIR=${MIRA_ROOT_DIR}")
MESSAGE(STATUS "FOUND_MIRA_ROOT_DIR=${FOUND_MIRA_ROOT_DIR}")

IF(FOUND_MIRA_ROOT_DIR)
# return the final relative path; must use echo, as cmake does not provide
# mechanism to output to stdout :(
execute_process(COMMAND ${CMAKE_COMMAND} -E echo ${MIRA_ROOT_DIR})
ELSE()
message("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
message("Your MIRA_PATH environment variable is not set properly.\nPlease add the proper path to your MIRA directory.")
message("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
message(FATAL_ERROR)
ENDIF()
message(STATUS "Detecting MIRA root directory")

# Examines each path in MIRA_PATH in order to find the MIRA root directory, which
# is identified by the file "make/Insource.make"
SET(ENV{MIRA_PATH} "$ENV{MIRA_PATH}:/opt/mira:${CMAKE_SOURCE_DIR}")
SET(FORCE_USE_QT5 1)

set(FindMIRARoot_MIRA_PATH "$ENV{MIRA_PATH}")

if(UNIX)
# note: the "" around "${MIRA_PATH}" are very important !
string(REPLACE ":" ";" FindMIRARoot_MIRA_PATH "${FindMIRARoot_MIRA_PATH}")
endif()

set(FOUND_MIRA_ROOT_DIR 0)
set(MIRA_ROOT_DIR "")

FOREACH(path ${FindMIRARoot_MIRA_PATH})
GET_FILENAME_COMPONENT(pathComponent ${path} ABSOLUTE)

# strip any trailing slashes from every path in MIRA_PATH env
MESSAGE(STATUS "Examining ${pathComponent}")

if(EXISTS "${pathComponent}/mira.root")
MESSAGE(STATUS "found valid ${pathComponent}")
set(FOUND_MIRA_ROOT_DIR 1)
set(MIRA_ROOT_DIR ${pathComponent})
endif()
ENDFOREACH(path)

MESSAGE(STATUS "MIRA_ROOT_DIR=${MIRA_ROOT_DIR}")
MESSAGE(STATUS "FOUND_MIRA_ROOT_DIR=${FOUND_MIRA_ROOT_DIR}")

IF(FOUND_MIRA_ROOT_DIR)
# return the final relative path; must use echo, as cmake does not provide
# mechanism to output to stdout :(
execute_process(COMMAND ${CMAKE_COMMAND} -E echo ${MIRA_ROOT_DIR})
ELSE()
message("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
message("Your MIRA_PATH environment variable is not set properly.\nPlease add the proper path to your MIRA directory.")
message("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
message(FATAL_ERROR)
ENDIF()
endmacro()

##############################################################################
# #############################################################################

#
# Include MIRA packages
#
# @public
#
macro(include_mira_packages)
set(CMAKE_MODULE_PATH ${MIRA_ROOT_DIR}/make)
set(CMAKE_MODULE_PATH ${MIRA_ROOT_DIR}/make)

include(Prerequisites)
include(Dependencies)
include(Prerequisites)
include(Dependencies)

# Require MIRAFramework package
mira_require_package(MIRAFramework)
mira_require_package(RobotDataTypes)
# Require MIRAFramework package
mira_require_package(MIRAFramework)
mira_require_package(RobotDataTypes)
endmacro()

##############################################################################
# #############################################################################

#
# Target link for MIRA libraries
#
# @public
#
macro(target_link_mira_libraries target)
# For transitive linking link against all auto liked libraries
target_link_libraries(${target} ${MIRAAutoLinkLibraries} MIRAFramework)
# For transitive linking link against all auto liked libraries
target_link_libraries(${target} ${MIRAAutoLinkLibraries} MIRAFramework)

# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE)

# when building, don't use the install RPATH already
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)

SET(CMAKE_INSTALL_RPATH "${MIRA_ROOT_DIR}/lib")

# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# the RPATH to be used when installing, but only if it's not a system directory
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)

IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
ENDIF("${isSystemDir}" STREQUAL "-1")
endmacro()
5 changes: 4 additions & 1 deletion scitos2_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ if(NOT CMAKE_CXX_STANDARD)
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic -Werror -Wdeprecated -fPIC -Wshadow -Wnull-dereference)
# add_compile_options(-Wall -Wextra -Wpedantic -Werror -Wdeprecated -fPIC -Wshadow -Wnull-dereference)
add_compile_options(-Wall -Wextra -Wpedantic -Wdeprecated -fPIC -Wshadow -Wnull-dereference)
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-Wnon-virtual-dtor>")
endif()

Expand Down Expand Up @@ -65,6 +66,8 @@ include_directories(
include
)

include_mira_packages()

set(dependencies
rclcpp
rclcpp_components
Expand Down
27 changes: 11 additions & 16 deletions scitos2_core/include/scitos2_core/module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class Module
virtual void deactivate() = 0;

protected:
// Skip this method from coverage report because it only calls MIRA services
// LCOV_EXCL_START
/**
* @brief Call a MIRA service with a timeout of 1 second.
*
Expand All @@ -85,8 +87,7 @@ class Module
// Check if the authority is valid or if the service exists
if (!sharedAuthority->isValid() || !sharedAuthority->existsService("/robot/Robot")) {
RCLCPP_ERROR_ONCE(
rclcpp::get_logger("MIRA"),
"MIRA authority is not valid or service does not exist");
rclcpp::get_logger("MIRA"), "MIRA authority is not valid or service does not exist");
return false;
}

Expand All @@ -97,8 +98,7 @@ class Module
RCLCPP_DEBUG(rclcpp::get_logger("MIRA"), "service_name: %i", true);
} catch (mira::XRPC & e) {
RCLCPP_WARN(
rclcpp::get_logger("MIRA"),
"MIRA RPC error caught when calling the service: %s", e.what() );
rclcpp::get_logger("MIRA"), "MIRA RPC error caught when calling the service: %s", e.what());
return false;
}
return true;
Expand Down Expand Up @@ -126,8 +126,7 @@ class Module
// Check if the authority is valid or if the service exists
if (!sharedAuthority->isValid() || !sharedAuthority->existsService("/robot/Robot")) {
RCLCPP_ERROR_ONCE(
rclcpp::get_logger("MIRA"),
"MIRA authority is not valid or service does not exist");
rclcpp::get_logger("MIRA"), "MIRA authority is not valid or service does not exist");
return false;
}

Expand All @@ -143,8 +142,7 @@ class Module
RCLCPP_DEBUG(rclcpp::get_logger("MIRA"), "service_name: %i", true);
} catch (mira::XRPC & e) {
RCLCPP_WARN(
rclcpp::get_logger("MIRA"),
"MIRA RPC error caught when calling the service: %s", e.what() );
rclcpp::get_logger("MIRA"), "MIRA RPC error caught when calling the service: %s", e.what());
return false;
}
return true;
Expand All @@ -171,8 +169,7 @@ class Module
// Check if the authority is valid or if the service exists
if (!sharedAuthority->isValid() || !sharedAuthority->existsService("/robot/Robot")) {
RCLCPP_ERROR_ONCE(
rclcpp::get_logger("MIRA"),
"MIRA authority is not valid or service does not exist");
rclcpp::get_logger("MIRA"), "MIRA authority is not valid or service does not exist");
return false;
}

Expand All @@ -183,8 +180,7 @@ class Module
rpc.get();
} catch (mira::XRPC & e) {
RCLCPP_WARN(
rclcpp::get_logger("MIRA"),
"MIRA RPC error caught when setting parameter: %s", e.what() );
rclcpp::get_logger("MIRA"), "MIRA RPC error caught when setting parameter: %s", e.what());
return false;
}
return true;
Expand All @@ -210,8 +206,7 @@ class Module
// Check if the authority is valid or if the service exists
if (!sharedAuthority->isValid() || !sharedAuthority->existsService("/robot/Robot")) {
RCLCPP_ERROR_ONCE(
rclcpp::get_logger("MIRA"),
"MIRA authority is not valid or service does not exist");
rclcpp::get_logger("MIRA"), "MIRA authority is not valid or service does not exist");
return "";
}

Expand All @@ -222,11 +217,11 @@ class Module
return rpc.get();
} catch (mira::XRPC & e) {
RCLCPP_WARN(
rclcpp::get_logger("MIRA"),
"MIRA RPC error caught when getting parameter: %s", e.what() );
rclcpp::get_logger("MIRA"), "MIRA RPC error caught when getting parameter: %s", e.what());
return "";
}
}
// LCOV_EXCL_STOP
};

} // namespace scitos2_core
Expand Down
2 changes: 2 additions & 0 deletions scitos2_core/include/scitos2_core/sink_logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "rclcpp/rclcpp.hpp"

// LCOV_EXCL_START
namespace scitos2_core
{

Expand Down Expand Up @@ -70,5 +71,6 @@ class SinkLogger : public mira::LogSink
};

} // namespace scitos2_core
// LCOV_EXCL_STOP

#endif // SCITOS2_CORE__SINK_LOGGER_HPP_
1 change: 0 additions & 1 deletion scitos2_core/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<test_depend>ament_cmake_gtest</test_depend>

<export>
<build_type>ament_cmake</build_type>
Expand Down

0 comments on commit 1710b01

Please sign in to comment.