YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
RgbVisualParams_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
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}
38{
40 yarp::os::Bottle response;
44 m_port.write(cmd, response);
45
46 if ((response.get(0).asVocab32()) == VOCAB_FAILED) {
47 configurations.clear();
48 return false;
49 }
50 configurations.resize(response.get(3).asInt32());
51 for (int i = 0; i < response.get(3).asInt32(); i++) {
52 configurations[i].width = response.get(4 + i * 4).asInt32();
53 configurations[i].height = response.get(4 + i * 4 + 1).asInt32();
54 configurations[i].framerate = response.get(4 + i * 4 + 2).asFloat64();
55 configurations[i].pixelCoding = static_cast<YarpVocabPixelTypesEnum>(response.get(4 + i * 4 + 3).asVocab32());
56 }
57 return true;
58}
60{
62 yarp::os::Bottle response;
66 m_port.write(cmd, response);
67
68 // Minimal check on response, we suppose the response is always correctly formatted
69 if ((response.get(0).asVocab32()) == VOCAB_FAILED) {
70 width = 0;
71 height = 0;
72 return false;
73 }
74 width = response.get(3).asInt32();
75 height = response.get(4).asInt32();
76 return true;
77}
78
80{
82 yarp::os::Bottle response;
86 cmd.addInt32(width);
87 cmd.addInt32(height);
88 m_port.write(cmd, response);
89 return response.get(2).asBool();
90}
91
92bool RgbVisualParams_Forwarder::getRgbFOV(double& horizontalFov, double& verticalFov)
93{
95 yarp::os::Bottle response;
99 m_port.write(cmd, response);
100
101 // Minimal check on response, we suppose the response is always correctly formatted
102 if ((response.get(0).asVocab32()) == VOCAB_FAILED) {
103 horizontalFov = 0;
104 verticalFov = 0;
105 return false;
106 }
107 horizontalFov = response.get(3).asFloat64();
108 verticalFov = response.get(4).asFloat64();
109 return true;
110}
111
112bool RgbVisualParams_Forwarder::setRgbFOV(double horizontalFov, double verticalFov)
113{
115 yarp::os::Bottle response;
119 cmd.addFloat64(horizontalFov);
120 cmd.addFloat64(verticalFov);
121 m_port.write(cmd, response);
122 return response.get(2).asBool();
123}
124
126{
128 yarp::os::Bottle response;
132 m_port.write(cmd, response);
133
134 // Minimal check on response, we suppose the response is always correctly formatted
135 if ((response.get(0).asVocab32()) == VOCAB_FAILED) {
136 intrinsic.clear();
137 return false;
138 }
139 bool ret;
140 ret = yarp::os::Property::copyPortable(response.get(3), intrinsic);
141 if (!response.get(4).isNull()) {
142 yarp::os::Property& p = intrinsic.addGroup("right");
143 ret &= yarp::os::Property::copyPortable(response.get(4), p);
144 return ret;
145 }
146 return ret;
147}
148
150{
152 yarp::os::Bottle response;
156 m_port.write(cmd, response);
157 if ((response.get(0).asVocab32()) == VOCAB_FAILED) {
158 return false;
159 }
160 mirror = response.get(3).asBool();
161 return true;
162}
163
165{
167 yarp::os::Bottle response;
171 cmd.addInt32(mirror);
172 m_port.write(cmd, response);
173 return response.get(2).asBool();
174}
constexpr yarp::conf::vocab32_t VOCAB_RGB_VISUAL_PARAMS
constexpr yarp::conf::vocab32_t VOCAB_RESOLUTION
constexpr yarp::conf::vocab32_t VOCAB_MIRROR
constexpr yarp::conf::vocab32_t VOCAB_FOV
constexpr yarp::conf::vocab32_t VOCAB_INTRINSIC_PARAM
constexpr yarp::conf::vocab32_t VOCAB_SUPPORTED_CONF
constexpr yarp::conf::vocab32_t VOCAB_WIDTH
constexpr yarp::conf::vocab32_t VOCAB_GET
constexpr yarp::conf::vocab32_t VOCAB_FAILED
constexpr yarp::conf::vocab32_t VOCAB_SET
constexpr yarp::conf::vocab32_t VOCAB_HEIGHT
YarpVocabPixelTypesEnum
Definition Image.h:40
bool ret
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.
Property & addGroup(const std::string &key)
Add a nested group.
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 isNull() const override
Checks if the object is invalid.
Definition Value.cpp:380
bool getRgbSupportedConfigurations(yarp::sig::VectorOf< yarp::dev::CameraConfig > &configurations) override
Get the possible configurations of the camera.
bool getRgbMirroring(bool &mirror) override
Get the mirroring setting of the sensor.
bool setRgbFOV(double horizontalFov, double verticalFov) override
Set the field of view (FOV) of the rgb camera.
bool setRgbResolution(int width, int height) override
Set the resolution of the rgb image from the camera.
int getRgbHeight() override
Return the height of each frame.
bool getRgbIntrinsicParam(yarp::os::Property &intrinsic) override
Get the intrinsic parameters of the rgb camera.
bool getRgbFOV(double &horizontalFov, double &verticalFov) override
Get the field of view (FOV) of the rgb camera.
int getRgbWidth() override
Return the width of each frame.
bool getRgbResolution(int &width, int &height) override
Get the resolution of the rgb image from the camera.
bool setRgbMirroring(bool mirror) override
Set the mirroring setting of the sensor.
void resize(size_t size) override
Resize the vector.
Definition Vector.h:221