Skip to content

Commit

Permalink
removed usage of sensor_from_frame() from rs-data-collect.
Browse files Browse the repository at this point in the history
add unit-test "get_sensor_from_frame"
  • Loading branch information
doronhi committed May 16, 2019
1 parent 4c37bbe commit 755a251
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
3 changes: 1 addition & 2 deletions tools/data-collect/rs-data-collect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void data_collector::save_data_to_file(const string& out_filename)

for (const auto& elem : data_collection)
{
csv << "\n\nStream Type,Index,F#,HW Timestamp (ms),Host Timestamp(ms), SerialNumber"
csv << "\n\nStream Type,Index,F#,HW Timestamp (ms),Host Timestamp(ms)"
<< (val_in_range(elem.first.first, { RS2_STREAM_GYRO,RS2_STREAM_ACCEL }) ? ",3DOF_x,3DOF_y,3DOF_z" : "")
<< (val_in_range(elem.first.first, { RS2_STREAM_POSE }) ? ",t_x,t_y,t_z,r_x,r_y,r_z,r_w" : "")
<< std::endl;
Expand Down Expand Up @@ -161,7 +161,6 @@ void data_collector::collect_frame_attributes(rs2::frame f, std::chrono::time_po
rec._params = { pose.translation.x, pose.translation.y, pose.translation.z,
pose.rotation.x,pose.rotation.y,pose.rotation.z,pose.rotation.w };
}
rec._dev_serial_no = sensor_from_frame(f)->get_info(RS2_CAMERA_INFO_SERIAL_NUMBER);

data_collection[stream_uid].emplace_back(rec);
}
Expand Down
8 changes: 2 additions & 6 deletions tools/data-collect/rs-data-collect.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,14 @@ namespace rs_data_collect
frame_record(unsigned long long frame_number, double frame_ts, double host_ts,
rs2_timestamp_domain domain, rs2_stream stream_type,int stream_index,
double _p1=0., double _p2=0., double _p3=0.,
double _p4=0., double _p5=0., double _p6=0., double _p7=0.,
std::string dev_serial=std::string("")):
double _p4=0., double _p5=0., double _p6=0., double _p7=0.):
_frame_number(frame_number),
_ts(frame_ts),
_arrival_time(host_ts),
_domain(domain),
_stream_type(stream_type),
_stream_idx(stream_index),
_params({_p1,_p2,_p3,_p4,_p5,_p6,_p7}),
_dev_serial_no(dev_serial)
_params({_p1,_p2,_p3,_p4,_p5,_p6,_p7})
{};

std::string to_string() const
Expand All @@ -224,7 +222,6 @@ namespace rs_data_collect
for (auto i=0; i<specific_attributes; i++)
ss << "," << _params[i];

ss << "," << _dev_serial_no;
return ss.str().c_str();
}

Expand All @@ -235,7 +232,6 @@ namespace rs_data_collect
rs2_stream _stream_type;
int _stream_idx;
std::array<double,7> _params; // |The parameters are optional and sensor specific
std::string _dev_serial_no;
};

private:
Expand Down
37 changes: 37 additions & 0 deletions unit-tests/unit-tests-live.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5549,3 +5549,40 @@ TEST_CASE("Wheel_Odometry_API", "[live]")
}
}
}


TEST_CASE("get_sensor_from_frame", "[live][using_pipeline]")
{
// Require at least one device to be plugged in
rs2::context ctx;
if (make_context(SECTION_FROM_TEST_NAME, &ctx, "2.13.0"))
{
std::vector<sensor> list;
REQUIRE_NOTHROW(list = ctx.query_all_sensors());
REQUIRE(list.size() > 0);

pipeline pipe(ctx);
device dev;
// Configure all supported streams to run at 30 frames per second

rs2::config cfg;
rs2::pipeline_profile profile;
REQUIRE_NOTHROW(profile = cfg.resolve(pipe));
REQUIRE(profile);
REQUIRE_NOTHROW(dev = profile.get_device());
REQUIRE(dev);
disable_sensitive_options_for(dev);

// Test sequence
REQUIRE_NOTHROW(pipe.start(cfg));
std::string dev_serial_no = dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER);
for (auto i = 0; i < 5; i++)
{
rs2::frameset data = pipe.wait_for_frames(); // Wait for next set of frames from the camera
auto frame = data.get_color_frame();
std::string frame_serail_no = sensor_from_frame(frame)->get_info(RS2_CAMERA_INFO_SERIAL_NUMBER);
REQUIRE(dev_serial_no == frame_serail_no);
}
REQUIRE_NOTHROW(pipe.stop());
}
}

0 comments on commit 755a251

Please sign in to comment.