visual-tracking-control
VisualProprioception.h
Go to the documentation of this file.
1 #ifndef VISUALPROPRIOCEPTION_H
2 #define VISUALPROPRIOCEPTION_H
3 
4 #include <string>
5 
6 #include <BayesFilters/VisualObservationModel.h>
7 #include <iCub/iKin/iKinFwd.h>
8 #include <opencv2/core/core.hpp>
9 #include <SuperimposeMesh/SICAD.h>
10 #include <yarp/dev/GazeControl.h>
11 #include <yarp/dev/IAnalogSensor.h>
12 #include <yarp/dev/PolyDriver.h>
13 #include <yarp/os/Bottle.h>
14 #include <yarp/os/BufferedPort.h>
15 #include <yarp/os/ConstString.h>
16 #include <yarp/sig/Matrix.h>
17 #include <yarp/sig/Vector.h>
18 
19 
20 class VisualProprioception : public bfl::VisualObservationModel
21 {
22 public:
23  VisualProprioception(const bool use_thumb,
24  const bool use_forearm,
25  const int num_images,
26  const double resolution_ratio,
27  const yarp::os::ConstString& cam_sel,
28  const yarp::os::ConstString& laterality,
29  const yarp::os::ConstString& context);
30 
32 
33  VisualProprioception(VisualProprioception&& proprio) noexcept;
34 
35  ~VisualProprioception() noexcept;
36 
38 
40 
41  void observe(const Eigen::Ref<const Eigen::MatrixXf>& cur_states, cv::OutputArray observations) override;
42 
43  bool setProperty(const std::string property) override;
44 
45  int getOGLTilesNumber();
46  int getOGLTilesRows();
47  int getOGLTilesCols();
48 
49  unsigned int getCamWidth();
50  unsigned int getCamHeight();
51 
52  float getCamFx();
53  float getCamFy();
54  float getCamCx();
55  float getCamCy();
56 
57 protected:
58  yarp::os::ConstString log_ID_ = "[VisualProprioception]";
59 
60  /* ICUB */
61  yarp::os::ConstString laterality_;
62  yarp::dev::PolyDriver drv_gaze_;
63  yarp::dev::IGazeControl* itf_gaze_;
64  iCub::iKin::iCubArm icub_arm_;
65  iCub::iKin::iCubFinger icub_kin_finger_[3];
66  iCub::iKin::iCubEye icub_kin_eye_;
67  yarp::os::BufferedPort<yarp::os::Bottle> port_head_enc_;
68  yarp::os::BufferedPort<yarp::os::Bottle> port_torso_enc_;
69  yarp::os::BufferedPort<yarp::os::Bottle> port_arm_enc_;
70  yarp::dev::PolyDriver drv_right_hand_analog_;
71  yarp::dev::IAnalogSensor * itf_right_hand_analog_;
72  yarp::sig::Matrix right_hand_analogs_bounds_;
73 
74  yarp::sig::Matrix getInvertedH(const double a, const double d, const double alpha, const double offset, const double q);
75 
76  bool openGazeController();
77 
78  bool openAnalogs();
79  bool closeAnalogs();
80  bool analogs_ = false;
81 
82  bool setiCubParams();
83 
84  void setArmJoints(const yarp::sig::Vector& q);
85 
86  void setArmJoints(const yarp::sig::Vector& q, const yarp::sig::Vector& analogs, const yarp::sig::Matrix& analog_bounds);
87 
88  void getModelPose(const Eigen::Ref<const Eigen::MatrixXf>& cur_states, std::vector<Superimpose::ModelPoseContainer>& hand_poses);
89 
90  yarp::sig::Vector readArmEncoders();
91  yarp::sig::Vector readTorso();
92  yarp::sig::Vector readRootToFingers();
93  yarp::sig::Vector readRootToEye(const yarp::os::ConstString cam_sel);
94  /* **** */
95 
96  yarp::os::ConstString cam_sel_;
97  double cam_x_[3];
98  double cam_o_[4];
99  unsigned int cam_width_;
100  unsigned int cam_height_;
101  float cam_fx_;
102  float cam_cx_;
103  float cam_fy_;
104  float cam_cy_;
106 
109  SICAD::ModelPathContainer cad_obj_;
110  SICAD* si_cad_;
113 
114  bool file_found(const yarp::os::ConstString& file);
115 
116 };
117 
118 #endif /* VISUALPROPRIOCEPTION_H */
yarp::dev::IGazeControl * itf_gaze_
bool setProperty(const std::string property) override
yarp::sig::Vector readRootToFingers()
iCub::iKin::iCubEye icub_kin_eye_
yarp::sig::Matrix right_hand_analogs_bounds_
yarp::os::ConstString laterality_
void observe(const Eigen::Ref< const Eigen::MatrixXf > &cur_states, cv::OutputArray observations) override
VisualProprioception & operator=(const VisualProprioception &proprio)
yarp::dev::PolyDriver drv_right_hand_analog_
iCub::iKin::iCubFinger icub_kin_finger_[3]
yarp::os::BufferedPort< yarp::os::Bottle > port_arm_enc_
SICAD::ModelPathContainer cad_obj_
yarp::sig::Vector readRootToEye(const yarp::os::ConstString cam_sel)
yarp::sig::Vector readArmEncoders()
void setArmJoints(const yarp::sig::Vector &q)
yarp::os::ConstString cam_sel_
yarp::sig::Matrix getInvertedH(const double a, const double d, const double alpha, const double offset, const double q)
yarp::os::ConstString log_ID_
void getModelPose(const Eigen::Ref< const Eigen::MatrixXf > &cur_states, std::vector< Superimpose::ModelPoseContainer > &hand_poses)
yarp::os::BufferedPort< yarp::os::Bottle > port_head_enc_
bool file_found(const yarp::os::ConstString &file)
yarp::dev::PolyDriver drv_gaze_
yarp::dev::IAnalogSensor * itf_right_hand_analog_
yarp::os::BufferedPort< yarp::os::Bottle > port_torso_enc_
yarp::sig::Vector readTorso()
iCub::iKin::iCubArm icub_arm_
VisualProprioception(const bool use_thumb, const bool use_forearm, const int num_images, const double resolution_ratio, const yarp::os::ConstString &cam_sel, const yarp::os::ConstString &laterality, const yarp::os::ConstString &context)