YARP
Yet Another Robot Platform
DepthVisualParams_Forwarder.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
7#include "CameraVocabs.h"
8
10
11DepthVisualParams_Forwarder::DepthVisualParams_Forwarder(yarp::os::Port& port) :
12 m_port(port)
13{
14};
15
17{
19 yarp::os::Bottle response;
23 m_port.write(cmd, response);
24 return response.get(3).asInt32();
25}
26
28{
30 yarp::os::Bottle response;
34 m_port.write(cmd, response);
35 return response.get(3).asInt32();
36}
37
39{
41 yarp::os::Bottle response;
45 cmd.addInt32(width);
46 cmd.addInt32(height);
47 m_port.write(cmd, response);
48 return response.get(2).asBool();
49}
50
51bool DepthVisualParams_Forwarder::getDepthFOV(double& horizontalFov, double& verticalFov)
52{
54 yarp::os::Bottle response;
58 m_port.write(cmd, response);
59
60 // Minimal check on response, we suppose the response is always correctly formatted
61 if ((response.get(0).asVocab32()) == VOCAB_FAILED) {
62 horizontalFov = 0;
63 verticalFov = 0;
64 return false;
65 }
66 horizontalFov = response.get(3).asFloat64();
67 verticalFov = response.get(4).asFloat64();
68 return true;
69}
70
71bool DepthVisualParams_Forwarder::setDepthFOV(double horizontalFov, double verticalFov)
72{
74 yarp::os::Bottle response;
78 cmd.addFloat64(horizontalFov);
79 cmd.addFloat64(verticalFov);
80 m_port.write(cmd, response);
81 return response.get(2).asBool();
82}
83
85{
87 yarp::os::Bottle response;
91 m_port.write(cmd, response);
92 return response.get(3).asFloat64();
93}
94
96{
98 yarp::os::Bottle response;
102 cmd.addFloat64(accuracy);
103 m_port.write(cmd, response);
104 return response.get(2).asBool();
105}
106
107bool DepthVisualParams_Forwarder::getDepthClipPlanes(double& nearPlane, double& farPlane)
108{
110 yarp::os::Bottle response;
114 m_port.write(cmd, response);
115
116 // Minimal check on response, we suppose the response is always correctly formatted
117 if ((response.get(0).asVocab32()) == VOCAB_FAILED) {
118 nearPlane = 0;
119 farPlane = 0;
120 return false;
121 }
122 nearPlane = response.get(3).asFloat64();
123 farPlane = response.get(4).asFloat64();
124 return true;
125}
126
127bool DepthVisualParams_Forwarder::setDepthClipPlanes(double nearPlane, double farPlane)
128{
130 yarp::os::Bottle response;
134 cmd.addFloat64(nearPlane);
135 cmd.addFloat64(farPlane);
136 m_port.write(cmd, response);
137 return response.get(2).asBool();
138}
139
141{
143 yarp::os::Bottle response;
147 m_port.write(cmd, response);
148
149 // Minimal check on response, we suppose the response is always correctly formatted
150 if ((response.get(0).asVocab32()) == VOCAB_FAILED) {
151 intrinsic.clear();
152 return false;
153 }
154
155 yarp::os::Property::copyPortable(response.get(3), intrinsic); // will it really work??
156 return true;
157}
158
160{
162 yarp::os::Bottle response;
166 m_port.write(cmd, response);
167 if ((response.get(0).asVocab32()) == VOCAB_FAILED) {
168 return false;
169 }
170 mirror = response.get(3).asBool();
171 return true;
172}
173
175{
177 yarp::os::Bottle response;
181 cmd.addInt32(mirror);
182 m_port.write(cmd, response);
183 return response.get(2).asBool();
184}
constexpr yarp::conf::vocab32_t VOCAB_DEPTH_VISUAL_PARAMS
Definition: CameraVocabs.h:19
constexpr yarp::conf::vocab32_t VOCAB_CLIP_PLANES
Definition: CameraVocabs.h:111
constexpr yarp::conf::vocab32_t VOCAB_RESOLUTION
Definition: CameraVocabs.h:104
constexpr yarp::conf::vocab32_t VOCAB_MIRROR
Definition: CameraVocabs.h:101
constexpr yarp::conf::vocab32_t VOCAB_FOV
Definition: CameraVocabs.h:105
constexpr yarp::conf::vocab32_t VOCAB_ACCURACY
Definition: CameraVocabs.h:110
constexpr yarp::conf::vocab32_t VOCAB_INTRINSIC_PARAM
Definition: CameraVocabs.h:106
constexpr yarp::conf::vocab32_t VOCAB_WIDTH
Definition: GenericVocabs.h:41
constexpr yarp::conf::vocab32_t VOCAB_GET
Definition: GenericVocabs.h:13
constexpr yarp::conf::vocab32_t VOCAB_FAILED
Definition: GenericVocabs.h:16
constexpr yarp::conf::vocab32_t VOCAB_SET
Definition: GenericVocabs.h:12
constexpr yarp::conf::vocab32_t VOCAB_HEIGHT
Definition: GenericVocabs.h:42
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:64
void addVocab32(yarp::conf::vocab32_t x)
Places a vocabulary item in the bottle, at the end of the list.
Definition: Bottle.cpp:164
void addFloat64(yarp::conf::float64_t x)
Places a 64-bit floating point number in the bottle, at the end of the list.
Definition: Bottle.cpp:158
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition: Bottle.cpp:246
void addInt32(std::int32_t x)
Places a 32-bit integer in the bottle, at the end of the list.
Definition: Bottle.cpp:140
A mini-server for network communication.
Definition: Port.h:46
bool write(const PortWriter &writer, const PortWriter *callback=nullptr) const override
Write an object to the port.
Definition: Port.cpp:436
static bool copyPortable(const PortWriter &writer, PortReader &reader)
Copy one portable to another, via writing and reading.
Definition: Portable.cpp:16
A class for storing options and configuration information.
Definition: Property.h:33
void clear()
Remove all associations.
Definition: Property.cpp:1057
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
Definition: Value.cpp:222
virtual yarp::conf::vocab32_t asVocab32() const
Get vocabulary identifier as an integer.
Definition: Value.cpp:228
virtual bool asBool() const
Get boolean value.
Definition: Value.cpp:186
virtual std::int32_t asInt32() const
Get 32-bit integer value.
Definition: Value.cpp:204
bool setDepthMirroring(bool mirror) override
Set the mirroring setting of the sensor.
bool setDepthFOV(double horizontalFov, double verticalFov) override
Set the field of view (FOV) of the depth camera.
bool getDepthClipPlanes(double &nearPlane, double &farPlane) override
Get the clipping planes of the sensor.
bool setDepthClipPlanes(double nearPlane, double farPlane) override
Set the clipping planes of the sensor.
int getDepthWidth() override
Return the height of each frame.
bool getDepthMirroring(bool &mirror) override
Get the mirroring setting of the sensor.
bool setDepthResolution(int width, int height) override
Set the resolution of the depth image from the camera.
double getDepthAccuracy() override
Get the minimum detectable variation in distance [meter].
bool getDepthFOV(double &horizontalFov, double &verticalFov) override
Get the field of view (FOV) of the depth camera.
bool setDepthAccuracy(double accuracy) override
Set the minimum detectable variation in distance [meter] when possible.
bool getDepthIntrinsicParam(yarp::os::Property &intrinsic) override
Get the intrinsic parameters of the depth camera.
int getDepthHeight() override
Return the height of each frame.