Skip to content

Commit

Permalink
Use buildsystem info to get the ros_package_name (#1062)
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
  • Loading branch information
ahcorde authored Sep 13, 2023
1 parent fecc6bc commit 909f637
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 10 deletions.
4 changes: 3 additions & 1 deletion rviz_rendering/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ else()
set(SKIP_DISPLAY_TESTS "SKIP_TEST")
endif()

find_package(ament_cmake REQUIRED)
find_package(ament_cmake_ros REQUIRED)

# do find_package(rviz_ogre_vendor) first to make sure the custom OGRE is found
find_package(rviz_ogre_vendor REQUIRED)
Expand Down Expand Up @@ -169,6 +169,8 @@ if(BUILD_TESTING)
test/rviz_rendering/ogre_testing_environment.cpp
test/rviz_rendering/scene_graph_introspection.cpp
)
target_compile_definitions(rviz_rendering_test_utils PRIVATE
"TEST_RVIZ_RENDERING_BUILDING_LIBRARY")
target_link_libraries(rviz_rendering_test_utils
PUBLIC
rviz_ogre_vendor::OgreMain
Expand Down
2 changes: 1 addition & 1 deletion rviz_rendering/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<author email="[email protected]">Michael Jeronimo</author>
<author email="[email protected]">William Woodall</author>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ament_cmake_ros</buildtool_depend>
<buildtool_depend>eigen3_cmake_module</buildtool_depend>

<buildtool_export_depend>eigen3_cmake_module</buildtool_export_depend>
Expand Down
2 changes: 0 additions & 2 deletions rviz_rendering/src/rviz_rendering/mesh_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@
#include "mesh_loader_helpers/stl_loader.hpp"
#include "rviz_rendering/logging.hpp"

#define ROS_PACKAGE_NAME "rviz_rendering"

namespace rviz_rendering
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@

#include "rviz_rendering/logging.hpp"

#define ROS_PACKAGE_NAME "rviz_rendering"
namespace rviz_rendering
{
class AssimpLoader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@

#include "rviz_rendering/logging.hpp"

#define ROS_PACKAGE_NAME "rviz_rendering"

namespace rviz_rendering
{

Expand Down
3 changes: 0 additions & 3 deletions rviz_rendering/src/rviz_rendering/objects/shape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@
#include "rviz_rendering/logging.hpp"
#include "rviz_rendering/material_manager.hpp"

// TODO(wjwwood): replace this with info from buildsystem
#define ROS_PACKAGE_NAME "rviz_rendering"

namespace rviz_rendering
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#ifndef RVIZ_RENDERING__OGRE_TESTING_ENVIRONMENT_HPP_
#define RVIZ_RENDERING__OGRE_TESTING_ENVIRONMENT_HPP_

#include "./visibility_control.hpp"

namespace rviz_rendering
{
class OgreTestingEnvironment
Expand All @@ -41,12 +43,16 @@ class OgreTestingEnvironment
* @param: bool debug, if true, all logging of Ogre is send to std::out, if false no logging
* occurs. Since the logging pollutes the test output, it defaults to false
*/
TEST_RVIZ_RENDERING_PUBLIC
void setUpOgreTestEnvironment(bool debug = false);

TEST_RVIZ_RENDERING_PUBLIC
void setUpRenderSystem();

TEST_RVIZ_RENDERING_PUBLIC
int getGlslVersion() const;

TEST_RVIZ_RENDERING_PUBLIC
~OgreTestingEnvironment();
};

Expand Down
12 changes: 12 additions & 0 deletions rviz_rendering/test/rviz_rendering/scene_graph_introspection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,35 @@
#include "rviz_rendering/objects/point_cloud.hpp"
#include "rviz_rendering/objects/movable_text.hpp"

#include "./visibility_control.hpp"

namespace rviz_rendering
{
TEST_RVIZ_RENDERING_PUBLIC
std::vector<Ogre::SceneNode *> findAllArrows(Ogre::SceneNode * scene_node);

TEST_RVIZ_RENDERING_PUBLIC
std::vector<Ogre::SceneNode *> findAllAxes(Ogre::SceneNode * scene_node);

TEST_RVIZ_RENDERING_PUBLIC
std::vector<Ogre::Entity *> findAllEntitiesByMeshName(
Ogre::SceneNode * scene_node, const Ogre::String & resource_name);
TEST_RVIZ_RENDERING_PUBLIC
Ogre::Entity * findEntityByMeshName(
Ogre::SceneNode * scene_node, const Ogre::String & resource_name);

TEST_RVIZ_RENDERING_PUBLIC
std::vector<Ogre::Entity *> findAllSpheres(Ogre::SceneNode * scene_node);
TEST_RVIZ_RENDERING_PUBLIC
std::vector<Ogre::Entity *> findAllCones(Ogre::SceneNode * scene_node);

TEST_RVIZ_RENDERING_PUBLIC
std::vector<Ogre::Entity *> findAllCylinders(Ogre::SceneNode * scene_node);

TEST_RVIZ_RENDERING_PUBLIC
std::vector<rviz_rendering::PointCloud *> findAllPointClouds(Ogre::SceneNode * scene_node);

TEST_RVIZ_RENDERING_PUBLIC
Ogre::BillboardChain * findOneBillboardChain(Ogre::SceneNode * scene_node);

template<typename OgreType>
Expand Down
58 changes: 58 additions & 0 deletions rviz_rendering/test/rviz_rendering/visibility_control.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2023 Open Source Robotics Foundation, Inc.
//
// 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.

#ifndef TEST_RVIZ_RENDERING__VISIBILITY_CONTROL_HPP_ // NOLINT
#define TEST_RVIZ_RENDERING__VISIBILITY_CONTROL_HPP_ // NOLINT

#ifdef __cplusplus
extern "C"
{
#endif

// This logic was borrowed (then namespaced) from the examples on the gcc wiki:
// https://gcc.gnu.org/wiki/Visibility

#if defined _WIN32 || defined __CYGWIN__
#ifdef __GNUC__
#define TEST_RVIZ_RENDERING_EXPORT __attribute__ ((dllexport))
#define TEST_RVIZ_RENDERING_IMPORT __attribute__ ((dllimport))
#else
#define TEST_RVIZ_RENDERING_EXPORT __declspec(dllexport)
#define TEST_RVIZ_RENDERING_IMPORT __declspec(dllimport)
#endif
#ifdef TEST_RVIZ_RENDERING_BUILDING_LIBRARY
#define TEST_RVIZ_RENDERING_PUBLIC TEST_RVIZ_RENDERING_EXPORT
#else
#define TEST_RVIZ_RENDERING_PUBLIC TEST_RVIZ_RENDERING_IMPORT
#endif
#define TEST_RVIZ_RENDERING_PUBLIC_TYPE TEST_RVIZ_RENDERING_PUBLIC
#define TEST_RVIZ_RENDERING_LOCAL
#else
#define TEST_RVIZ_RENDERING_EXPORT __attribute__ ((visibility("default")))
#define TEST_RVIZ_RENDERING_IMPORT
#if __GNUC__ >= 4
#define TEST_RVIZ_RENDERING_PUBLIC __attribute__ ((visibility("default")))
#define TEST_RVIZ_RENDERING_LOCAL __attribute__ ((visibility("hidden")))
#else
#define TEST_RVIZ_RENDERING_PUBLIC
#define TEST_RVIZ_RENDERING_LOCAL
#endif
#define TEST_RVIZ_RENDERING_PUBLIC_TYPE
#endif

#ifdef __cplusplus
}
#endif

#endif // TEST_RVIZ_RENDERING__VISIBILITY_CONTROL_HPP_ // NOLINT

0 comments on commit 909f637

Please sign in to comment.