Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROS 2 port of fuse_viz #301

Merged
merged 5 commits into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions fuse_constraints/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ install(DIRECTORY include/
DESTINATION include/${PROJECT_NAME}
)

install(DIRECTORY cmake DESTINATION share/${PROJECT_NAME})

pluginlib_export_plugin_description_file(fuse_core fuse_plugins.xml)

ament_export_targets(${PROJECT_NAME}-export HAS_LIBRARY_TARGET)
Expand Down
2 changes: 1 addition & 1 deletion fuse_constraints/fuse_plugins.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<library path="lib/libfuse_constraints">
<library path="fuse_constraints">
<class type="fuse_constraints::AbsoluteAccelerationAngular2DStampedConstraint" base_class_type="fuse_core::Constraint">
<description>
A constraint that represents either prior information about a 2D angular acceleration, or a direct measurement of
Expand Down
3 changes: 3 additions & 0 deletions fuse_constraints/suitesparse-extras.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

if(DEFINED fuse_constraints_DIR)
list(APPEND CMAKE_MODULE_PATH "${fuse_constraints_DIR}")
endif()
find_package(SUITESPARSE REQUIRED COMPONENTS CCOLAMD)
2 changes: 1 addition & 1 deletion fuse_variables/fuse_plugins.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<library path="lib/libfuse_variables">
<library path="fuse_variables">
<class type="fuse_variables::AccelerationAngular2DStamped" base_class_type="fuse_core::Variable">
<description>
Variable representing a 2D angular acceleration at a specific time, with a specific piece of hardware.
Expand Down
121 changes: 45 additions & 76 deletions fuse_viz/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,50 +1,33 @@
cmake_minimum_required(VERSION 3.0.2)
cmake_minimum_required(VERSION 3.16)
project(fuse_viz)

set(build_depends
fuse_constraints
fuse_core
fuse_msgs
fuse_variables
geometry_msgs
rviz
tf2_geometry_msgs
)
# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CXX_STANDARD_REQUIRED YES)
endif()

find_package(catkin REQUIRED COMPONENTS
${build_depends}
)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake_ros REQUIRED)
find_package(fuse_constraints REQUIRED)
find_package(fuse_core REQUIRED)
find_package(fuse_msgs REQUIRED)
find_package(fuse_variables REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(rviz_common REQUIRED)
find_package(rviz_rendering REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)

find_package(Boost REQUIRED)
find_package(Eigen3 REQUIRED)

find_package(Qt5 COMPONENTS Core Widgets REQUIRED)
set(QT_INCLUDE_DIRS
${Qt5Core_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
)
set(QT_LIBRARIES
${Qt5Core_LIBRARIES}
${Qt5Widgets_LIBRARIES}
)

add_definitions(-DQT_NO_KEYWORDS)

###########
## Build ##
###########
add_compile_options(-Wall -Werror)

catkin_package(
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
CATKIN_DEPENDS
${build_depends}
DEPENDS
Boost
EIGEN3
QT
)

qt5_wrap_cpp(moc_files
include/fuse_viz/mapped_covariance_property.h
Expand All @@ -53,7 +36,7 @@ qt5_wrap_cpp(moc_files
include/fuse_viz/serialized_graph_display.h
)

set(source_files
add_library(${PROJECT_NAME} SHARED
src/mapped_covariance_property.cpp
src/mapped_covariance_visual.cpp
src/pose_2d_stamped_property.cpp
Expand All @@ -63,60 +46,46 @@ set(source_files
src/serialized_graph_display.cpp
${moc_files}
)

add_library(${PROJECT_NAME}
${source_files}
)
add_dependencies(${PROJECT_NAME}
${catkin_EXPORTED_TARGETS}
)
target_include_directories(${PROJECT_NAME}
PUBLIC
include
${Boost_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIRS}
${QT_INCLUDE_DIRS}
target_link_libraries(${PROJECT_NAME} PRIVATE
${fuse_msgs_TARGETS}
Eigen3::Eigen
fuse_constraints::fuse_constraints
fuse_core::fuse_core
fuse_variables::fuse_variables
rviz_common::rviz_common
rviz_rendering::rviz_rendering
tf2::tf2
)
target_link_libraries(${PROJECT_NAME}
${catkin_LIBRARIES}
${Boost_LIBRARIES}
${QT_LIBRARIES}
)
set_target_properties(${PROJECT_NAME}
PROPERTIES
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES

target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
${Qt5Widgets_INCLUDE_DIRS}
)

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

install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
install(DIRECTORY include/
DESTINATION include/${PROJECT_NAME}
)

install(
FILES rviz_plugins.xml
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
pluginlib_export_plugin_description_file(rviz_common rviz_plugins.xml)

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

if(CATKIN_ENABLE_TESTING)
find_package(roslint REQUIRED)

# Lint tests
set(ROSLINT_CPP_OPTS "--filter=-build/c++11,-runtime/references")
roslint_cpp()
roslint_add_test()
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()

ament_package()
Empty file removed fuse_viz/COLCON_IGNORE
Empty file.
6 changes: 3 additions & 3 deletions fuse_viz/include/fuse_viz/conversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@

#include <OgreColourValue.h>
#include <OgreQuaternion.h>
#include <OgreVector3.h>
#include <Ogre.h>

#include <boost/array.hpp>

#include <Eigen/Dense>

#include <array>
#include <stdexcept>

namespace tf2
Expand All @@ -63,7 +63,7 @@ namespace tf2
* @param[out] msg 6x6 covariance message, which is stored as a plain array with 36 elements.
*/
template <typename Derived>
inline void toMsg(const Eigen::MatrixBase<Derived>& covariance, boost::array<double, 36>& msg)
inline void toMsg(const Eigen::MatrixBase<Derived>& covariance, std::array<double, 36>& msg)
{
using Scalar = typename Derived::Scalar;
using Matrix6 = Eigen::Matrix<Scalar, 6, 6>;
Expand Down
46 changes: 23 additions & 23 deletions fuse_viz/include/fuse_viz/mapped_covariance_property.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,15 @@

#include <OgreColourValue.h>

#include <rviz/properties/bool_property.h>
#include <fuse_viz/mapped_covariance_visual.h>

#include <rviz_common/properties/bool_property.hpp>
#include <rviz_common/properties/color_property.hpp>
#include <rviz_common/properties/enum_property.hpp>
#include <rviz_common/properties/float_property.hpp>
#include <rviz_common/properties/property.hpp>

#include <memory>
#include <string>
#include <unordered_map>

Expand All @@ -47,26 +54,19 @@ class SceneNode;

} // namespace Ogre

namespace rviz
namespace fuse_viz
{

class Property;
class ColorProperty;
class FloatProperty;
class EnumProperty;
class MappedCovarianceVisual;

/**
* @brief Property specialized to provide getter for booleans.
*
* This is mostly a copy of CovarianceProperty from rviz/default_plugin/covariance_property.h that instead of using an
* std::deque to store the visuals, it uses an std::unordered_map, so the visuals can be indexed by their UUID.
*/
class MappedCovarianceProperty : public rviz::BoolProperty
class MappedCovarianceProperty : public rviz_common::properties::BoolProperty
{
Q_OBJECT
public:
typedef boost::shared_ptr<MappedCovarianceVisual> MappedCovarianceVisualPtr;
typedef std::shared_ptr<MappedCovarianceVisual> MappedCovarianceVisualPtr;

enum Frame
{
Expand All @@ -81,7 +81,7 @@ class MappedCovarianceProperty : public rviz::BoolProperty
};

MappedCovarianceProperty(const QString& name = "Covariance", bool default_value = false,
const QString& description = QString(), rviz::Property* parent = 0,
const QString& description = QString(), rviz_common::properties::Property* parent = 0,
const char* changed_slot = 0, QObject* receiver = 0);

virtual ~MappedCovarianceProperty();
Expand Down Expand Up @@ -111,17 +111,17 @@ private Q_SLOTS:

std::unordered_map<std::string, MappedCovarianceVisualPtr> covariances_;

rviz::BoolProperty* position_property_;
rviz::ColorProperty* position_color_property_;
rviz::FloatProperty* position_alpha_property_;
rviz::FloatProperty* position_scale_property_;
rviz::BoolProperty* orientation_property_;
rviz::EnumProperty* orientation_frame_property_;
rviz::EnumProperty* orientation_colorstyle_property_;
rviz::ColorProperty* orientation_color_property_;
rviz::FloatProperty* orientation_alpha_property_;
rviz::FloatProperty* orientation_offset_property_;
rviz::FloatProperty* orientation_scale_property_;
rviz_common::properties::BoolProperty* position_property_;
rviz_common::properties::ColorProperty* position_color_property_;
rviz_common::properties::FloatProperty* position_alpha_property_;
rviz_common::properties::FloatProperty* position_scale_property_;
rviz_common::properties::BoolProperty* orientation_property_;
rviz_common::properties::EnumProperty* orientation_frame_property_;
rviz_common::properties::EnumProperty* orientation_colorstyle_property_;
rviz_common::properties::ColorProperty* orientation_color_property_;
rviz_common::properties::FloatProperty* orientation_alpha_property_;
rviz_common::properties::FloatProperty* orientation_offset_property_;
rviz_common::properties::FloatProperty* orientation_scale_property_;
};

} // end namespace rviz
Expand Down
30 changes: 13 additions & 17 deletions fuse_viz/include/fuse_viz/mapped_covariance_visual.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,15 @@

#include <cmath>

#include <rviz/ogre_helpers/object.h>
#include <rviz_rendering/objects/object.hpp>
#include <rviz_rendering/objects/shape.hpp>

#include <boost/scoped_ptr.hpp>

#include <geometry_msgs/PoseWithCovariance.h>
#include <geometry_msgs/msg/pose_with_covariance.hpp>

#include <Eigen/Dense>

#include <OgreColourValue.h>
#include <OgreVector3.h>
#include <Ogre.h>

namespace Ogre
{
Expand All @@ -55,20 +54,17 @@ namespace Eigen
typedef Matrix<double, 6, 6> Matrix6d;
}

namespace rviz
namespace fuse_viz
{

class Shape;
class MappedCovarianceProperty;

/**
* \class MappedCovarianceVisual
* \brief MappedCovarianceVisual consisting in a ellipse for position and 2D ellipses along the axis for orientation.
*
* This is mostly a copy of CovarianceVisual from rviz/default_plugin/covariance_visual.h that allows
* MappedCovarianceProperty be a friend class of MappedCovarianceVisual, so it can call its constructor.
*/
class MappedCovarianceVisual : public rviz::Object
class MappedCovarianceVisual : public rviz_rendering::Object
{
public:
enum ShapeIndex
Expand Down Expand Up @@ -137,7 +133,7 @@ class MappedCovarianceVisual : public rviz::Object
* This effectively changes the orientation and scale of position and orientation
* covariance shapes
*/
virtual void setCovariance(const geometry_msgs::PoseWithCovariance& pose);
virtual void setCovariance(const geometry_msgs::msg::PoseWithCovariance& pose);

virtual const Ogre::Vector3& getPositionCovarianceScale();
virtual const Ogre::Quaternion& getPositionCovarianceOrientation();
Expand All @@ -164,7 +160,7 @@ class MappedCovarianceVisual : public rviz::Object
* \brief Get the shape used to display position covariance
* @return the shape used to display position covariance
*/
rviz::Shape* getPositionShape()
rviz_rendering::Shape* getPositionShape()
{
return position_shape_;
}
Expand All @@ -173,7 +169,7 @@ class MappedCovarianceVisual : public rviz::Object
* \brief Get the shape used to display orientation covariance in an especific axis
* @return the shape used to display orientation covariance in an especific axis
*/
rviz::Shape* getOrientationShape(ShapeIndex index);
rviz_rendering::Shape* getOrientationShape(ShapeIndex index);

/**
* \brief Sets user data on all ogre objects we own
Expand Down Expand Up @@ -225,8 +221,8 @@ class MappedCovarianceVisual : public rviz::Object
Ogre::SceneNode* orientation_root_node_;
Ogre::SceneNode* orientation_offset_node_[kNumOriShapes];

rviz::Shape* position_shape_; //!< Ellipse used for the position covariance
rviz::Shape* orientation_shape_[kNumOriShapes]; //!< Cylinders used for the orientation covariance
rviz_rendering::Shape* position_shape_; //!< Ellipse used for the position covariance
rviz_rendering::Shape* orientation_shape_[kNumOriShapes]; //!< Cylinders used for the orientation covariance

bool local_rotation_;

Expand All @@ -242,10 +238,10 @@ class MappedCovarianceVisual : public rviz::Object
private:
// Hide Object methods we don't want to expose
// NOTE: Apparently we still need to define them...
virtual void setScale(const Ogre::Vector3& scale)
virtual void setScale(const Ogre::Vector3&)
{
}
virtual void setColor(float r, float g, float b, float a)
virtual void setColor(float, float, float, float)
{
}
virtual const Ogre::Vector3& getPosition();
Expand Down
Loading