Skip to content

Commit

Permalink
Fixed compilation issues on linux and some tests issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
aangerma committed Feb 26, 2019
1 parent f7c8447 commit bddee0d
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 84 deletions.
4 changes: 3 additions & 1 deletion include/librealsense2/h/rs_option.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ extern "C" {
RS2_OPTION_EMITTER_ON_OFF, /**< When supported, this option make the camera to switch the emitter state every frame. 0 for disabled, 1 for enabled */
RS2_OPTION_ZERO_ORDER_POINT_X, /**< Zero order point x*/
RS2_OPTION_ZERO_ORDER_POINT_Y, /**< Zero order point y*/
RS2_OPTION_LLD_TEMPERATURE,
RS2_OPTION_LLD_TEMPERATURE, /**< LLD temperature*/
RS2_OPTION_MC_TEMPERATURE, /**< MC temperature*/
RS2_OPTION_MA_TEMPERATURE, /**< MA temperature*/
RS2_OPTION_COUNT /**< Number of enumeration values. Not a valid input: intended to be used in for-loops. */
} rs2_option;

Expand Down
15 changes: 15 additions & 0 deletions include/librealsense2/hpp/rs_frame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -996,5 +996,20 @@ namespace rs2
private:
size_t _size;
};

template<class T>
class frame_callback : public rs2_frame_callback
{
T on_frame_function;
public:
explicit frame_callback(T on_frame) : on_frame_function(on_frame) {}

void on_frame(rs2_frame* fref) override
{
on_frame_function(frame{ fref });
}

void release() override { delete this; }
};
}
#endif // LIBREALSENSE_RS2_FRAME_HPP
2 changes: 1 addition & 1 deletion include/librealsense2/hpp/rs_options.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.
// Copyright(c) 2019 Intel Corporation. All Rights Reserved.

#ifndef LIBREALSENSE_RS2_OPTIONS_HPP
#define LIBREALSENSE_RS2_OPTIONS_HPP
Expand Down
15 changes: 0 additions & 15 deletions include/librealsense2/hpp/rs_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,6 @@ struct rs2_playback_status_changed_callback

namespace rs2
{
template<class T>
class frame_callback : public rs2_frame_callback
{
T on_frame_function;
public:
explicit frame_callback(T on_frame) : on_frame_function(on_frame) {}

void on_frame(rs2_frame* fref) override
{
on_frame_function(frame{ fref });
}

void release() override { delete this; }
};

class error : public std::runtime_error
{
std::string function, args;
Expand Down
8 changes: 4 additions & 4 deletions src/l500/l500.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@ namespace librealsense
rs2_intrinsics intrinsics;
intrinsics.width = profile.width;
intrinsics.height = profile.height;
intrinsics.fx = std::abs(intr[0]);
intrinsics.fy = std::abs(intr[1]);
intrinsics.ppx = std::abs(intr[2]);
intrinsics.ppy = std::abs(intr[3]);
intrinsics.fx = std::fabs(intr[0]);
intrinsics.fy = std::fabs(intr[1]);
intrinsics.ppx = std::fabs(intr[2]);
intrinsics.ppy = std::fabs(intr[3]);
return intrinsics;
}

Expand Down
2 changes: 1 addition & 1 deletion src/media/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ target_sources(${LRS_TARGET}
"${CMAKE_CURRENT_LIST_DIR}/playback/playback_sensor.h"
"${CMAKE_CURRENT_LIST_DIR}/ros/ros_reader.h"
"${CMAKE_CURRENT_LIST_DIR}/ros/ros_writer.h"
"${CMAKE_CURRENT_LIST_DIR}/ros/ros_reader.cpp"
"${CMAKE_CURRENT_LIST_DIR}/ros/ros_reader.cpp"
"${CMAKE_CURRENT_LIST_DIR}/ros/ros_writer.cpp"
"${CMAKE_CURRENT_LIST_DIR}/ros/ros_file_format.h"
)
35 changes: 3 additions & 32 deletions src/media/ros/ros_reader.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.
// Copyright(c) 2019 Intel Corporation. All Rights Reserved.

#pragma once
#include "ros_reader.h"
Expand Down Expand Up @@ -239,21 +239,6 @@ namespace librealsense
return m_file_path;
}

template <typename ROS_TYPE>
typename ROS_TYPE::ConstPtr ros_reader::instantiate_msg(const rosbag::MessageInstance& msg)
{
typename ROS_TYPE::ConstPtr msg_instnance_ptr = msg.instantiate<ROS_TYPE>();
if (msg_instnance_ptr == nullptr)
{
throw io_exception(to_string()
<< "Invalid file format, expected "
<< rs2rosinternal::message_traits::DataType<ROS_TYPE>::value()
<< " message but got: " << msg.getDataType()
<< "(Topic: " << msg.getTopic() << ")");
}
return msg_instnance_ptr;
}

std::shared_ptr<serialized_frame> ros_reader::create_frame(const rosbag::MessageInstance& msg)
{
auto next_msg_topic = msg.getTopic();
Expand Down Expand Up @@ -357,21 +342,6 @@ namespace librealsense
}
}

template <typename T>
static bool ros_reader::safe_convert(const std::string& key, T& val)
{
try
{
convert(key, val);
}
catch (const std::exception& e)
{
LOG_ERROR(e.what());
return false;
}
return true;
}

std::map<std::string, std::string> ros_reader::get_frame_metadata(const rosbag::Bag& bag,
const std::string& topic,
const device_serializer::stream_identifier& stream_id,
Expand Down Expand Up @@ -921,7 +891,8 @@ namespace librealsense
}
throw io_exception("Unrecognized sensor name");
}
throw io_exception("Unrecognized device");
//Unrecognized sensor
return std::make_shared<recommended_proccesing_blocks_snapshot>(processing_blocks{});
}

std::shared_ptr<recommended_proccesing_blocks_snapshot> ros_reader::read_proccesing_blocks(const rosbag::Bag& file, device_serializer::sensor_identifier sensor_id, const nanoseconds& timestamp,
Expand Down
30 changes: 28 additions & 2 deletions src/media/ros/ros_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,20 @@ namespace librealsense
private:

template <typename ROS_TYPE>
static typename ROS_TYPE::ConstPtr instantiate_msg(const rosbag::MessageInstance& msg);
static typename ROS_TYPE::ConstPtr instantiate_msg(const rosbag::MessageInstance& msg)
{
typename ROS_TYPE::ConstPtr msg_instnance_ptr = msg.instantiate<ROS_TYPE>();
if (msg_instnance_ptr == nullptr)
{
throw io_exception(to_string()
<< "Invalid file format, expected "
<< rs2rosinternal::message_traits::DataType<ROS_TYPE>::value()
<< " message but got: " << msg.getDataType()
<< "(Topic: " << msg.getTopic() << ")");
}
return msg_instnance_ptr;
}

std::shared_ptr<serialized_frame> create_frame(const rosbag::MessageInstance& msg);
static nanoseconds get_file_duration(const rosbag::Bag& file, uint32_t version);
static void get_legacy_frame_metadata(const rosbag::Bag& bag,
Expand All @@ -36,7 +49,20 @@ namespace librealsense
frame_additional_data& additional_data);

template <typename T>
static bool safe_convert(const std::string& key, T& val);
static bool safe_convert(const std::string& key, T& val)
{
try
{
convert(key, val);
}
catch (const std::exception& e)
{
LOG_ERROR(e.what());
return false;
}
return true;
}

static std::map<std::string, std::string> get_frame_metadata(const rosbag::Bag& bag,
const std::string& topic,
const device_serializer::stream_identifier& stream_id,
Expand Down
26 changes: 1 addition & 25 deletions src/media/ros/ros_writer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.
// Copyright(c) 2019 Intel Corporation. All Rights Reserved.

#pragma once
#include "proc/decimation-filter.h"
Expand Down Expand Up @@ -370,16 +370,6 @@ namespace librealsense
write_extension_snapshot(device_id, sensor_id, timestamp, type, snapshot, false);
}

template <rs2_extension E>
std::shared_ptr<typename ExtensionToType<E>::type> ros_writer::SnapshotAs(std::shared_ptr<librealsense::extension_snapshot> snapshot)
{
auto as_type = As<typename ExtensionToType<E>::type>(snapshot);
if (as_type == nullptr)
{
throw invalid_value_exception(to_string() << "Failed to cast snapshot to \"" << E << "\" (as \"" << ExtensionToType<E>::to_string() << "\")");
}
return as_type;
}
void ros_writer::write_extension_snapshot(uint32_t device_id, uint32_t sensor_id, const nanoseconds& timestamp, rs2_extension type, std::shared_ptr<librealsense::extension_snapshot> snapshot, bool is_device)
{
switch (type)
Expand Down Expand Up @@ -547,20 +537,6 @@ namespace librealsense
}
}

template <typename T>
void ros_writer::write_message(std::string const& topic, nanoseconds const& time, T const& msg)
{
try
{
m_bag.write(topic, to_rostime(time), msg);
LOG_DEBUG("Recorded: \"" << topic << "\" . TS: " << time.count());
}
catch (rosbag::BagIOException& e)
{
throw io_exception(to_string() << "Ros Writer failed to write topic: \"" << topic << "\" to file. (Exception message: " << e.what() << ")");
}
}

uint8_t ros_writer::is_big_endian()
{
int num = 1;
Expand Down
25 changes: 23 additions & 2 deletions src/media/ros/ros_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,16 @@ namespace librealsense
void write_extension_snapshot(uint32_t device_id, uint32_t sensor_id, const nanoseconds& timestamp, rs2_extension type, std::shared_ptr<librealsense::extension_snapshot> snapshot);

template <rs2_extension E>
std::shared_ptr<typename ExtensionToType<E>::type> SnapshotAs(std::shared_ptr<librealsense::extension_snapshot> snapshot);
std::shared_ptr<typename ExtensionToType<E>::type> SnapshotAs(std::shared_ptr<librealsense::extension_snapshot> snapshot)
{
auto as_type = As<typename ExtensionToType<E>::type>(snapshot);
if (as_type == nullptr)
{
throw invalid_value_exception(to_string() << "Failed to cast snapshot to \"" << E << "\" (as \"" << ExtensionToType<E>::to_string() << "\")");
}
return as_type;
}

void write_extension_snapshot(uint32_t device_id, uint32_t sensor_id, const nanoseconds& timestamp, rs2_extension type, std::shared_ptr<librealsense::extension_snapshot> snapshot, bool is_device);
void write_vendor_info(const std::string& topic, nanoseconds timestamp, std::shared_ptr<info_interface> info_snapshot);
void write_sensor_option(device_serializer::sensor_identifier sensor_id, const nanoseconds& timestamp, rs2_option type, const librealsense::option& option);
Expand All @@ -48,7 +57,19 @@ namespace librealsense
void write_sensor_processing_blocks(device_serializer::sensor_identifier sensor_id, const nanoseconds& timestamp, std::shared_ptr<recommended_proccesing_blocks_interface> proccesing_blocks);

template <typename T>
void write_message(std::string const& topic, nanoseconds const& time, T const& msg);
void write_message(std::string const& topic, nanoseconds const& time, T const& msg)
{
try
{
m_bag.write(topic, to_rostime(time), msg);
LOG_DEBUG("Recorded: \"" << topic << "\" . TS: " << time.count());
}
catch (rosbag::BagIOException& e)
{
throw io_exception(to_string() << "Ros Writer failed to write topic: \"" << topic << "\" to file. (Exception message: " << e.what() << ")");
}
}

static uint8_t is_big_endian();
std::map<stream_identifier, geometry_msgs::Transform> m_extrinsics_msgs;
std::string m_file_path;
Expand Down
2 changes: 1 addition & 1 deletion src/proc/zero-order.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.
// Copyright(c) 2019 Intel Corporation. All Rights Reserved.

#include "zero-order.h"
#include <iomanip>
Expand Down
2 changes: 2 additions & 0 deletions src/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ namespace librealsense
CASE(ZERO_ORDER_POINT_X)
CASE(ZERO_ORDER_POINT_Y)
CASE(LLD_TEMPERATURE)
CASE(MC_TEMPERATURE)
CASE(MA_TEMPERATURE)
default: assert(!is_valid(value)); return UNKNOWN_VALUE;
}
#undef CASE
Expand Down

0 comments on commit bddee0d

Please sign in to comment.