RobotsIO
Loading...
Searching...
No Matches
iCubCamera.h
1/*
2 * Copyright (C) 2019 Istituto Italiano di Tecnologia (IIT)
3 *
4 * This software may be modified and distributed under the terms of the
5 * BSD 3-Clause license. See the accompanying LICENSE file for details.
6 */
7
8#ifndef ROBOTSIO_ICUBCAMERA_H
9#define ROBOTSIO_ICUBCAMERA_H
10
11#include <RobotsIO/Camera/Camera.h>
12
13#include <Eigen/Dense>
14
15#include <iCub/iKin/iKinFwd.h>
16#include <iCub/learningMachine/LSSVMLearner.h>
17
18#include <opencv2/opencv.hpp>
19
20#include <string>
21
22#include <yarp/dev/GazeControl.h>
23#include <yarp/dev/IEncoders.h>
24#include <yarp/dev/PolyDriver.h>
25#include <yarp/os/Bottle.h>
26#include <yarp/os/BufferedPort.h>
27#include <yarp/os/Network.h>
28#include <yarp/sig/Image.h>
29
30namespace RobotsIO {
31 namespace Camera {
32 class iCubCamera;
33 }
34}
35
36
38{
39public:
40
41 iCubCamera(const std::string& robot_name, const std::string& laterality, const std::string& port_prefix, const bool& use_calibration = false, const std::string& calibration_path = "");
42
43 iCubCamera(const std::string& data_path, const std::string& laterality, const std::size_t& width, const std::size_t& height, const double& fx, const double& cx, const double& fy, const double& cy, const bool& load_encoders_data, const bool& use_calibration = false, const std::string& calibration_path = "");
44
46
52
53 yarp::dev::IGazeControl& controller();
54
59 std::pair<bool, Eigen::MatrixXf> depth(const bool& blocking) override;
60
61 std::pair<bool, Eigen::Transform<double, 3, Eigen::Affine>> pose(const bool& blocking) override;
62
63 std::pair<bool, cv::Mat> rgb(const bool& blocking) override;
64
65 std::pair<bool, double> time_stamp_rgb() const override;
66
67 std::pair<bool, double> time_stamp_depth() const override;
68
73 std::pair<bool, Eigen::VectorXd> auxiliary_data(const bool& blocking) override;
74
75 std::size_t auxiliary_data_size() const override;
76
77protected:
78 std::string laterality();
79
80 std::pair<bool, Eigen::Transform<double, 3, Eigen::Affine>> laterality_pose(const std::string& laterality, const bool& blocking);
81
82 void set_laterality(const std::string& laterality);
83
84private:
85 std::string laterality_;
86
87 yarp::os::Network yarp_;
88
93 yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelFloat>> port_depth_;
94
95 yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgb>> port_rgb_;
96
101 /* Gateway to iGazeControl::getLeftEyePose() and iGazeControl::getRightEyePose(). */
102 bool getLateralityEyePose(const std::string& laterality, yarp::sig::Vector& position, yarp::sig::Vector& orientation);
103
104 yarp::dev::PolyDriver driver_gaze_;
105
106 yarp::dev::IGazeControl* gaze_control_;
107
108 bool use_driver_gaze_ = true;
109
114 yarp::dev::PolyDriver drv_torso_;
115
116 yarp::dev::IEncoders *itorso_;
117
118 yarp::dev::PolyDriver drv_head_;
119
120 yarp::dev::IEncoders *ihead_;
121
122 iCub::iKin::iCubEye left_eye_kinematics_;
123
124 iCub::iKin::iCubEye right_eye_kinematics_;
125
126 /*
127 * Extrinsic calibration.
128 */
129
130 Eigen::Transform<double, 3, Eigen::Affine> exp_map(const Eigen::VectorXd& se3);
131
132 bool load_calibration_model(const std::string& model_path);
133
134 bool use_calibration_ = false;
135
136 iCub::learningmachine::LSSVMLearner calibration_;
137
138 /*
139 * Offline playback.
140 */
141
142 bool load_encoders_data_ = false;
143
148 double time_stamp_rgb_;
149
150 double time_stamp_depth_;
151
152 bool is_time_stamp_rgb_ = false;
153
154 bool is_time_stamp_depth_ = false;
155
160 const std::string log_name_ = "iCubCamera";
161};
162
163#endif /* ROBOTSIO_ICUBCAMERA_H */
std::pair< bool, Eigen::VectorXd > auxiliary_data(const bool &blocking) override
Definition: iCubCamera.cpp:369
std::pair< bool, Eigen::MatrixXf > depth(const bool &blocking) override
Definition: iCubCamera.cpp:259