Skip to content

Commit

Permalink
add project name and root frame paramter to direct dump
Browse files Browse the repository at this point in the history
  • Loading branch information
jarkenau authored and Mark-Niemeyer committed Dec 13, 2022
1 parent e0ce4f8 commit db5a70d
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 5 deletions.
4 changes: 4 additions & 0 deletions examples/cpp/ROS/launch/hdf5-node.launch
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
<arg name="topics" default="['/image']"/>
<arg name="path" default="/seerep/seerep-data/"/>
<arg name="filename" default="3e2a9b3a-2ab0-48a7-87c2-7bf1ea6392a8"/>
<arg name="project_root_frame" default="map"/>
<arg name="project_name" default="testproject"/>
<node name="seerep_ros_examples_hdf5_node" pkg="seerep_ros_examples" type="seerep_ros_examples_hdf5_node" output="screen">
<rosparam param="topics" subst_value="True">$(arg topics)</rosparam>
<rosparam param="path" subst_value="True">$(arg path)</rosparam>
<rosparam param="filename" subst_value="True">$(arg filename)</rosparam>
<rosparam param="project_root_frame" subst_value="True">$(arg project_root_frame)</rosparam>
<rosparam param="project_name" subst_value="True">$(arg project_name)</rosparam>
</node>
</launch>
14 changes: 13 additions & 1 deletion examples/cpp/ROS/src/hdf5-node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,19 @@ Hdf5Node::Hdf5Node(const ros::NodeHandle& nodeHandle, const ros::NodeHandle& pri
ROS_WARN_STREAM("Filename is an invalid UUID, using generated UUID instead");
}

hdf5Access_ = std::make_unique<seerep_hdf5_ros::Hdf5Ros>(path, filename);
std::string projectName;
if (!privateNodeHandle_.getParam("project_name", projectName))
{
throw std::runtime_error("No project name specified");
}

std::string rootFrameId;
if (!privateNodeHandle_.getParam("project_root_frame", rootFrameId))
{
throw std::runtime_error("No root frame specified");
}

hdf5Access_ = std::make_unique<seerep_hdf5_ros::Hdf5Ros>(path, filename, rootFrameId, projectName);

std::vector<std::string> topics;
if (!privateNodeHandle_.getParam("topics", topics))
Expand Down
18 changes: 17 additions & 1 deletion seerep-hdf5/seerep-hdf5-ros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,42 @@ find_package(catkin REQUIRED
sensor_msgs
)

find_package(SeerepHdf5Core REQUIRED)

include(cmake/FindHighFive.cmake)
find_package(HighFive REQUIRED)

set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
add_definitions(-DBOOST_LOG_DYN_LINK)

catkin_package(
INCLUDE_DIRS include
LIBRARIES seerep_hdf5_ros
CATKIN_DEPENDS std_msgs geometry_msgs sensor_msgs
DEPENDS HighFive
DEPENDS HighFive SeerepHdf5Core
)

include_directories(
include
${HighFive_INCLUDE_DIRS}
${SeerepHdf5Core_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
)

add_library(${PROJECT_NAME}
src/hdf5-ros.cpp
)

target_link_libraries(${PROJECT_NAME}
${HighFive_LIBRARIES}
${Boost_LIBRARIES}
${SeerepHdf5Core_LIBRARIES}
${catkin_LIBRARIES}
)

add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

install(TARGETS ${PROJECT_NAME}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef SEEREP_HDF5_ROS_H_
#define SEEREP_HDF5_ROS_H_

// std
// Std
#include <mutex>
#include <string>

// HighFive
Expand All @@ -17,13 +18,17 @@
#include "sensor_msgs/Image.h"
#include "std_msgs/Header.h"

// Seerep
#include "seerep-hdf5-core/hdf5-core-general.h"

namespace seerep_hdf5_ros
{
class Hdf5Ros
{
public:
Hdf5Ros() = delete;
Hdf5Ros(const std::string& path, const std::string& filename);
Hdf5Ros(const std::string& path, const std::string& filename, const std::string& projectFrameId,
const std::string& projectName);

bool dumpImage(const sensor_msgs::Image& image) const;
bool dumpHeader(const std_msgs::Header& header, const std::string& datasetPath) const;
Expand Down
1 change: 1 addition & 0 deletions seerep-hdf5/seerep-hdf5-ros/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<depend>sensor_msgs</depend>
<depend>std_msgs</depend>
<depend>geometry_msgs</depend>
<depend>seerep-hdf5-core</depend>

<buildtool_depend>catkin</buildtool_depend>
</package>
8 changes: 7 additions & 1 deletion seerep-hdf5/seerep-hdf5-ros/src/hdf5-ros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

namespace seerep_hdf5_ros
{
Hdf5Ros::Hdf5Ros(const std::string& path, const std::string& filename) : path_{ path }, filename_{ filename }
Hdf5Ros::Hdf5Ros(const std::string& path, const std::string& filename, const std::string& projectFrameId,
const std::string& projectName)
: path_{ path }, filename_{ filename }
{
auto write_mtx = std::make_shared<std::mutex>();
hdf5File_ =
std::make_shared<HighFive::File>(path_ + filename_ + ".h5", HighFive::File::ReadWrite | HighFive::File::Create);
auto ioGeneral = seerep_hdf5_core::Hdf5CoreGeneral(hdf5File_, write_mtx);
ioGeneral.writeProjectFrameId(projectFrameId);
ioGeneral.writeProjectname(projectName);
}

bool Hdf5Ros::dumpImage(const sensor_msgs::Image& image) const
Expand Down

0 comments on commit db5a70d

Please sign in to comment.