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

Eloquent migration #3

Open
wants to merge 5 commits into
base: eloquent
Choose a base branch
from
Open
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
197 changes: 133 additions & 64 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,90 +27,159 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

cmake_minimum_required(VERSION 3.5)

cmake_minimum_required(VERSION 2.8.3)
project(spencer_tracking_rviz_plugin)

find_package(catkin REQUIRED COMPONENTS rviz spencer_tracking_msgs spencer_human_attribute_msgs spencer_social_relation_msgs)
catkin_package()
include_directories(${catkin_INCLUDE_DIRS})
link_directories(${catkin_LIBRARY_DIRS})



## This plugin includes Qt widgets, so we must include Qt.
## We'll use the version that rviz used so they are compatible.
if(rviz_QT_VERSION VERSION_LESS "5")
message(STATUS "Using Qt4 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
find_package(Qt4 ${rviz_QT_VERSION} EXACT REQUIRED QtCore QtGui)
## pull in all required include dirs, define QT_LIBRARIES, etc.
include(${QT_USE_FILE})
qt4_wrap_cpp(MOC_FILES
src/detected_persons_display.h
src/tracked_persons_display.h
src/tracked_groups_display.h
src/social_relations_display.h
src/social_activities_display.h
src/human_attributes_display.h
src/person_display_common.h
src/additional_topic_subscriber.h
)
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic -Wnon-virtual-dtor -Woverloaded-virtual)
endif()

# Tests currently only run on OS X @ OSRF jenkins
# Enable on Linux by providing a display, enable on Windows via EnableDisplayTests=True
option(EnableDisplayTests "EnableDisplayTests")
set(DisplayTests "False" CACHE STRING "DisplayTestsVariable")

if(DEFINED ENV{DISPLAY})
set(DISPLAYPRESENT TRUE)
endif()

if(APPLE OR DISPLAYPRESENT OR EnableDisplayTests STREQUAL "True")
message(STATUS "Enabling tests requiring a display")
else()
message(STATUS "Using Qt5 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
find_package(Qt5 ${rviz_QT_VERSION} EXACT REQUIRED Core Widgets)
## make target_link_libraries(${QT_LIBRARIES}) pull in all required dependencies
set(QT_LIBRARIES Qt5::Widgets)
qt5_wrap_cpp(MOC_FILES
src/detected_persons_display.h
src/tracked_persons_display.h
src/tracked_groups_display.h
src/social_relations_display.h
src/social_activities_display.h
src/human_attributes_display.h
src/person_display_common.h
src/additional_topic_subscriber.h
)
set(SKIP_DISPLAY_TESTS "SKIP_TEST")
endif()

add_definitions(-DQT_NO_KEYWORDS)
# options and directories for visual tests (see visual_testing_framework documentation)
option(EnableVisualTests "decides whether or not to enable the tests")

add_definitions(-D_BUILD_DIR_PATH="${CMAKE_CURRENT_BINARY_DIR}")
add_definitions(-D_SRC_DIR_PATH="${CMAKE_CURRENT_SOURCE_DIR}")

file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test_images)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test/reference_images)

# Run visual tests only if "EnableVisualTests=True"
if(EnableVisualTests STREQUAL "True")
message(STATUS "Enabling visual tests")
else()
set(SKIP_VISUAL_TESTS "SKIP_TEST")
endif()

if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
endif()

set(SOURCE_FILES
# We specifically don't turn on CMAKE_AUTOMOC, since it generates one huge
# mocs_compilation.cpp file that takes a lot of memory to compile. Instead
# we create individual moc files that can be compiled separately.

find_package(ament_cmake REQUIRED)
find_package(rviz_common REQUIRED)
find_package(rviz_rendering REQUIRED)
find_package(rviz_default_plugins REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rviz_ogre_vendor REQUIRED)
find_package(spencer_tracking_msgs REQUIRED)
find_package(spencer_human_attribute_msgs REQUIRED)
find_package(spencer_social_relation_msgs REQUIRED)
find_package(Qt5 REQUIRED COMPONENTS Core Widgets)

set(spencer_tracking_rviz_plugin_headers_to_moc
include/spencer_tracking_rviz_plugin/detected_persons_display.hpp
include/spencer_tracking_rviz_plugin/tracked_persons_display.hpp
##include/spencer_tracking_rviz_plugin/tracked_groups_display.hpp
##include/spencer_tracking_rviz_plugin/social_relations_display.hpp
##include/spencer_tracking_rviz_plugin/social_activities_display.hpp
##include/spencer_tracking_rviz_plugin/human_attributes_display.hpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these left out?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @makokal ! I am working on the migration of these nodes, but I preferred do a small PR to easily the revision process.

include/spencer_tracking_rviz_plugin/person_display_common.hpp
##include/spencer_tracking_rviz_plugin/additional_topic_subscriber.hpp
)

foreach(header "${spencer_tracking_rviz_plugin_headers_to_moc}")
qt5_wrap_cpp(spencer_tracking_rviz_plugin_moc_files "${header}")
endforeach()

set(spencer_tracking_rviz_plugin_source_files
src/detected_persons_display.cpp
src/tracked_persons_display.cpp
src/tracked_groups_display.cpp
src/social_relations_display.cpp
src/social_activities_display.cpp
src/human_attributes_display.cpp
##src/tracked_groups_display.cpp
##src/social_relations_display.cpp
##src/social_activities_display.cpp
##src/human_attributes_display.cpp
src/person_display_common.cpp
src/tracked_persons_cache.cpp
##src/tracked_persons_cache.cpp
src/visuals/person_visual.cpp
${MOC_FILES}
)

add_library(spencer_tracking_rviz_plugin SHARED
${spencer_tracking_rviz_plugin_moc_files}
${spencer_tracking_rviz_plugin_source_files}
)

add_library(${PROJECT_NAME} ${SOURCE_FILES})
add_dependencies(${PROJECT_NAME} ${catkin_EXPORTED_TARGETS}) # for generation of message dependencies
target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${catkin_LIBRARIES})
target_include_directories(spencer_tracking_rviz_plugin PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
${Qt5Widgets_INCLUDE_DIRS}
)

target_link_libraries(spencer_tracking_rviz_plugin PUBLIC
rviz_ogre_vendor::OgreMain
rviz_ogre_vendor::OgreOverlay
)

# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(spencer_tracking_rviz_plugin PRIVATE "SPENCER_TRACKING_RVIZ_PLUGIN_BUILDING_LIBRARY")

install(TARGETS
${PROJECT_NAME}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# prevent pluginlib from using boost
target_compile_definitions(spencer_tracking_rviz_plugin PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS")

pluginlib_export_plugin_description_file(rviz_common plugins_description.xml)

ament_target_dependencies(spencer_tracking_rviz_plugin
PUBLIC
spencer_tracking_msgs
spencer_human_attribute_msgs
spencer_social_relation_msgs
rviz_common
rviz_rendering
rviz_default_plugins
)

ament_export_include_directories(include)
ament_export_interfaces(spencer_tracking_rviz_plugin HAS_LIBRARY_TARGET)
ament_export_dependencies(
Qt5
rviz_common
rviz_rendering
rviz_default_plugins
rviz_ogre_vendor
spencer_tracking_msgs
spencer_human_attribute_msgs
spencer_social_relation_msgs
)

install(FILES
plugin_description.xml
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
install(
TARGETS spencer_tracking_rviz_plugin
EXPORT spencer_tracking_rviz_plugin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)

install(DIRECTORY media/
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/media)
install(DIRECTORY include DESTINATION include)
install(DIRECTORY media DESTINATION share/${PROJECT_NAME})

install(DIRECTORY icons/
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/icons)
install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/icons"
DESTINATION "share/${PROJECT_NAME}"
)

install(PROGRAMS scripts/send_test_msgs.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
ament_package()
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
RViz plugins for visualization of detected and tracked persons, groups, social relations, activities and human attributes
-------------------------------------------------------------------------------------------------------------------------
Author: ©2013-2018 Timm Linder, Social Robotics Laboratory, Albert-Ludwigs-University Freiburg, Germany

## **_WARNING_**: _The migration to ROS2 eloquent is in progress. Please, [check the migrated nodes and the ones still to be migrated](#migration-progress)._

Author: ©2013-2015 Timm Linder, Social Robotics Laboratory, Albert-Ludwigs-University Freiburg, Germany

E-mail: [email protected]

Expand Down Expand Up @@ -37,7 +40,12 @@ Rviz may crash with a segfault when exiting. This usually can be ignored.
Person visuals in the tracked groups and human attributes display do not support walking animations.
However, these displays can be combined with the tracked persons display (which does support animations) by disabling their person visuals.

Related work
------------
This Rviz plugin has been developed as part of the larger [SPENCER people tracking](https://github.com/spencer-project/spencer_people_tracking/) project and is provided here in a separate repository as a convenience for users that do not require the full human detection and tracking functionality (e.g. when using the PedSim simulator). We will try to keep this repository up-to-date with the upstream repository as far as possible. The original repository also contains references for citing
this work.

## Migration progress
- [x] Detected persons
- [x] Tracked persons. _(There is a warning log with the covariance and the Person Meshes style causes rviz2 crashed.)_
- [ ] Tracked groups
- [ ] Social relations
- [ ] Social activities
- [ ] Human attributes
- [ ] Python send msgs test
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,25 @@

#ifndef Q_MOC_RUN
#include <map>
#include <iomanip>
#include <iostream>
#include <boost/circular_buffer.hpp>
#include <spencer_tracking_msgs/DetectedPersons.h>
#include "person_display_common.h"
#include <spencer_tracking_msgs/msg/detected_persons.hpp>
#include "spencer_tracking_rviz_plugin/person_display_common.hpp"
#include "rviz_common/logging.hpp"
#endif

namespace spencer_tracking_rviz_plugin
{
/// The visual of a tracked person.
struct DetectedPersonVisual
{
boost::shared_ptr<Ogre::SceneNode> sceneNode;
std::shared_ptr<Ogre::SceneNode> sceneNode;

boost::shared_ptr<PersonVisual> personVisual;
boost::shared_ptr<TextNode> detectionIdText, confidenceText, modalityText;
boost::shared_ptr<rviz::Arrow> orientationArrow;
boost::shared_ptr<CovarianceVisual> covarianceVisual;
std::shared_ptr<PersonVisual> personVisual;
std::shared_ptr<TextNode> detectionIdText, confidenceText, modalityText;
std::shared_ptr<rviz_rendering::Arrow> orientationArrow;
std::shared_ptr<CovarianceVisual> covarianceVisual;

float confidence;
bool hasValidOrientation;
Expand All @@ -57,7 +60,7 @@ namespace spencer_tracking_rviz_plugin

// The DetectedPersonsDisplay class itself just implements a circular buffer,
// editable parameters, and Display subclass machinery.
class DetectedPersonsDisplay: public PersonDisplayCommon<spencer_tracking_msgs::DetectedPersons>
class DetectedPersonsDisplay: public PersonDisplayCommon<spencer_tracking_msgs::msg::DetectedPersons>
{
Q_OBJECT
public:
Expand All @@ -73,40 +76,41 @@ namespace spencer_tracking_rviz_plugin
// and broken.

virtual void onInitialize();
// Function to handle an incoming ROS message.
void processMessage(spencer_tracking_msgs::msg::DetectedPersons::ConstSharedPtr msg) override;

protected:
// A helper to clear this display back to the initial state.
virtual void reset();

// Must be implemented by derived classes because MOC doesn't work in templates
virtual rviz::DisplayContext* getContext() {
virtual rviz_common::DisplayContext* getContext() {
return context_;
}

private Q_SLOTS:
void personVisualTypeChanged();

// Called whenever one of the properties in PersonDisplayCommonProperties has been changed
virtual void stylesChanged();

private:
// Function to handle an incoming ROS message.
void processMessage(const spencer_tracking_msgs::DetectedPersons::ConstPtr& msg);



// All currently active tracks, with unique track ID as map key
vector<boost::shared_ptr<DetectedPersonVisual> > m_previousDetections;
vector<std::shared_ptr<DetectedPersonVisual> > m_previousDetections;

// Properties
rviz::BoolProperty* m_render_covariances_property;
rviz::BoolProperty* m_render_detection_ids_property;
rviz::BoolProperty* m_render_confidences_property;
rviz::FloatProperty* m_low_confidence_threshold_property;
rviz::FloatProperty* m_low_confidence_alpha_property;
rviz::BoolProperty* m_render_orientations_property;
rviz::BoolProperty* m_render_modality_text_property;

rviz::FloatProperty* m_text_spacing_property;
rviz::FloatProperty* m_covariance_line_width_property;
rviz_common::properties::BoolProperty* m_render_covariances_property;
rviz_common::properties::BoolProperty* m_render_detection_ids_property;
rviz_common::properties::BoolProperty* m_render_confidences_property;
rviz_common::properties::FloatProperty* m_low_confidence_threshold_property;
rviz_common::properties::FloatProperty* m_low_confidence_alpha_property;
rviz_common::properties::BoolProperty* m_render_orientations_property;
rviz_common::properties::BoolProperty* m_render_modality_text_property;

rviz_common::properties::FloatProperty* m_text_spacing_property;
rviz_common::properties::FloatProperty* m_covariance_line_width_property;
};

} // end namespace spencer_tracking_rviz_plugin
Expand Down
Loading