23 inline
int checkResponse(
bool ok, const
yarp::os::
Bottle& response)
56 double tmpDT=
now-prev;
58 if (tmpDT > deltaTMax) {
61 if (tmpDT < deltaTMin) {
81 getEnvelope(newStamp);
84 if (lastStamp.isValid()==
false)
157 return (
int)lastVector.size();
168 if (found == std::string::npos)
174 yCDebug(ANALOGSENSORCLIENT) <<
"found is " << found <<
"; length is : " << name.length();
176 if( (found == 0) || (found == name.length()-1 ) )
185 yCDebug(ANALOGSENSORCLIENT) << name;
190 yCWarning(ANALOGSENSORCLIENT) <<
"The 'inertial' device is deprecated in favour of 'multipleanalogsensorsclient'";
191 yCWarning(ANALOGSENSORCLIENT) <<
"The old device is no longer supported, and it will be deprecated in YARP 3.6 and removed in YARP 4.";
192 yCWarning(ANALOGSENSORCLIENT) <<
"Please update your scripts.";
194 std::string carrier = config.
check(
"carrier",
Value(
"udp"),
"default carrier for streaming robot state").asString();
204 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error you have to provide valid local name");
209 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error you have to provide valid remote name\n");
213 std::string local_rpc = local;
214 local_rpc +=
"/rpc:o";
215 std::string remote_rpc = remote;
216 remote_rpc +=
"/rpc:i";
218 if (!inputPort.open(local))
220 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error could not open port %s, check network", local.c_str());
223 inputPort.useCallback();
225 if (!rpcPort.open(local_rpc))
227 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error could not open rpc port %s, check network", local_rpc.c_str());
231 bool ok=Network::connect(remote.c_str(), local.c_str(), carrier.c_str());
234 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error could not connect to %s", remote.c_str());
238 ok=Network::connect(local_rpc, remote_rpc);
241 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error could not connect to %s\n", remote_rpc.c_str());
257 return inputPort.getLast(out, lastTs);
268 return inputPort.getChannels();
276 bool ok = rpcPort.write(cmd, response);
277 return checkResponse(ok, response);
286 for (
int i = 0; i < this->getChannels(); i++) {
289 bool ok = rpcPort.write(cmd, response);
290 return checkResponse(ok, response);
299 bool ok = rpcPort.write(cmd, response);
300 return checkResponse(ok, response);
310 bool ok = rpcPort.write(cmd, response);
311 return checkResponse(ok, response);
constexpr yarp::conf::vocab32_t VOCAB_IANALOG
constexpr yarp::conf::vocab32_t VOCAB_CALIBRATE
constexpr yarp::conf::vocab32_t VOCAB_CALIBRATE_CHANNEL
void removeLeadingTrailingSlashesOnly(std::string &name)
yarp::os::Stamp getLastInputStamp() override
Get the time stamp for the last read data.
bool close() override
Close the DeviceDriver.
int calibrateChannel(int ch) override
Calibrates one single channel.
int calibrateSensor() override
Calibrates the whole sensor.
int read(yarp::sig::Vector &out) override
Read a vector from the sensor.
int getState(int ch) override
Check the state value of a given channel.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
int getChannels() override
Get the number of channels of the sensor.
A simple collection of objects that can be described and transmitted in a portable way.
void addVocab32(yarp::conf::vocab32_t x)
Places a vocabulary item in the bottle, at the end of the list.
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
void addFloat64(yarp::conf::float64_t x)
Places a 64-bit floating point number in the bottle, at the end of the list.
void addInt32(std::int32_t x)
Places a 32-bit integer in the bottle, at the end of the list.
A base class for nested structures that can be searched.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
An abstraction for a time stamp and/or sequence number.
double getTime() const
Get the time stamp.
A single value (typically within a Bottle).
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual bool isInt32() const
Checks if value is a 32-bit integer.
virtual std::string asString() const
Get string value.
#define yCError(component,...)
#define yCWarning(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
An interface for the device drivers.
double now()
Return the current time in seconds, relative to an arbitrary starting point.
An interface to the operating system, including Port based communication.
The main, catch-all namespace for YARP.