iCub-main
Loading...
Searching...
No Matches
CamCalibModule.h
Go to the documentation of this file.
1// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2
3/*
4 * Copyright (C) 2007 Jonas Ruesch
5 * CopyPolicy: Released under the terms of the GNU GPL v2.0.
6 *
7 */
8
9#ifndef __CAMCALIBMODULE__
10#define __CAMCALIBMODULE__
11
12// std
13#include <mutex>
14#include <stdio.h>
15#include <map>
16
17// opencv
18#include <opencv2/core/core_c.h>
19
20// yarp
21#include <yarp/os/all.h>
22#include <yarp/sig/all.h>
23
24// iCub
25#include <iCub/PinholeCalibTool.h>
26#include <iCub/SphericalCalibTool.h>
27#include <iCub/CalibToolFactory.h>
28#include <iCub/ICalibTool.h>
29
35class CamCalibPort : public yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgb> >
36{
37private:
38 yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgb> > *portImgOut;
39 ICalibTool *calibTool;
40
41 bool verbose;
42 double t0;
43 double currSat;
44 double roll;
45 double pitch;
46 double yaw;
47 std::mutex m;
48 bool leftEye; // true for left eye, false for right eye
49 double maxDelay;
50
51 std::map<double, yarp::os::Bottle> m_h_encs_map;
52 std::map<double, yarp::os::Bottle> m_t_encs_map;
53 std::map<double, yarp::os::Bottle> m_imu_map;
54 yarp::os::Bottle m_last_h_encs;
55 yarp::os::Bottle m_last_t_encs;
56 yarp::os::Bottle m_last_imu;
57 yarp::os::Bottle m_curr_h_encs;
58 yarp::os::Bottle m_curr_t_encs;
59 yarp::os::Bottle m_curr_imu;
60 bool useIMU;
61 bool useTorso;
62 bool useEyes;
63 bool useLast;
64
65 bool updatePose(double time);
66 bool selectBottleFromMap(double time,
67 std::map<double, yarp::os::Bottle> *datamap,
68 yarp::os::Bottle *bottle,
69 bool verbose = false);
70 virtual void onRead(yarp::sig::ImageOf<yarp::sig::PixelRgb> &yrpImgIn);
71public:
73 double cf1;
74 double cf2;
75 double r_xv[2];
76 double p_xv[2];
77 double y_xv[2];
78 double r_yv[2];
79 double p_yv[2];
80 double y_yv[2];
81
82public:
84
85 void setSaturation(double satVal);
86 void setPointers(yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgb> > *_portImgOut, ICalibTool *_calibTool);
87 void setVerbose(const bool sw) { verbose=sw; }
88 void setLeftEye(bool eye) { leftEye = eye; }
89 void setMaxDelay(double delay) { maxDelay = delay; }
90
91 void setTorsoEncoders(double time, const yarp::os::Bottle &t_encs) { m.lock(); m_last_t_encs = t_encs; m_t_encs_map[time] = t_encs; m.unlock(); }
92 void setHeadEncoders(double time, const yarp::os::Bottle &h_encs) { m.lock(); m_last_h_encs = h_encs; m_h_encs_map[time] = h_encs; m.unlock(); }
93 void setImuData(double time, const yarp::os::Bottle &imu) { m.lock(); m_last_imu = imu; m_imu_map[time] = imu; m.unlock(); }
94 void setUseIMU(bool useIMU) { this->useIMU = useIMU; }
95 void setUseTorso(bool useTorso) { this->useTorso = useTorso; }
96 void setUseEyes(bool useEyes) { this->useEyes = useEyes; }
97 void setUseLast(bool useLast) { this->useLast = useLast; }
98
99 yarp::os::BufferedPort<yarp::os::Bottle> rpyPort;
100};
101
102
103class TorsoEncoderPort : public yarp::os::BufferedPort<yarp::os::Bottle> {
104private:
105 virtual void onRead(yarp::os::Bottle &t_encs);
106public:
108};
109
110class HeadEncoderPort : public yarp::os::BufferedPort<yarp::os::Bottle> {
111private:
112 virtual void onRead(yarp::os::Bottle &h_encs);
113public:
115};
116
117class ImuPort : public yarp::os::BufferedPort<yarp::os::Bottle> {
118private:
119 virtual void onRead(yarp::os::Bottle &imu);
120public:
123};
124
125
133class CamCalibModule : public yarp::os::RFModule {
134
135private:
136
137 CamCalibPort _prtImgIn;
138 yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgb> > _prtImgOut;
139 yarp::os::Port _configPort;
140 TorsoEncoderPort _prtTEncsIn;
141 HeadEncoderPort _prtHEncsIn;
142 ImuPort _prtImuIn;
143 ICalibTool * _calibTool;
144 std::string strGroup;
145
146public:
147
150
152 virtual bool configure(yarp::os::ResourceFinder &rf);
153 virtual bool close();
154 virtual bool interruptModule();
155 virtual bool updateModule();
156 virtual bool respond(const yarp::os::Bottle& command, yarp::os::Bottle& reply);
157 virtual double getPeriod();
158};
159
160
161#endif
Camera Calibration Module class.
virtual bool interruptModule()
virtual double getPeriod()
virtual bool close()
virtual bool respond(const yarp::os::Bottle &command, yarp::os::Bottle &reply)
virtual bool updateModule()
virtual bool configure(yarp::os::ResourceFinder &rf)
Passes config on to CalibTool.
Camera Calibration Port class.
void setUseLast(bool useLast)
double p_xv[2]
yarp::os::BufferedPort< yarp::os::Bottle > rpyPort
void setLeftEye(bool eye)
void setUseIMU(bool useIMU)
double p_yv[2]
void setSaturation(double satVal)
double r_xv[2]
void setTorsoEncoders(double time, const yarp::os::Bottle &t_encs)
void setUseTorso(bool useTorso)
void setImuData(double time, const yarp::os::Bottle &imu)
void setVerbose(const bool sw)
void setUseEyes(bool useEyes)
double r_yv[2]
void setPointers(yarp::os::BufferedPort< yarp::sig::ImageOf< yarp::sig::PixelRgb > > *_portImgOut, ICalibTool *_calibTool)
void setHeadEncoders(double time, const yarp::os::Bottle &h_encs)
void setMaxDelay(double delay)
double y_xv[2]
double y_yv[2]
CamCalibPort * _prtImgIn
Interface to calibrate and project input image based on camera's internal parameters and projection m...
Definition ICalibTool.h:19
CamCalibPort * _prtImgIn
CamCalibPort * _prtImgIn
degrees time
Definition sine.m:5