|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
26 inline
int checkResponse(
bool ok, const
yarp::os::
Bottle& response)
59 double tmpDT=
now-prev;
82 getEnvelope(newStamp);
85 if (lastStamp.isValid()==
false)
158 return (
int)lastVector.size();
167 std::size_t found = name.find(
'/');
169 if (found == std::string::npos)
175 yCDebug(ANALOGSENSORCLIENT) <<
"found is " << found <<
"; length is : " << name.length();
177 if( (found == 0) || (found == name.length()-1 ) )
186 yCDebug(ANALOGSENSORCLIENT) << name;
191 std::string carrier = config.
check(
"carrier",
Value(
"udp"),
"default carrier for streaming robot state").asString();
201 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error you have to provide valid local name");
206 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error you have to provide valid remote name\n");
210 std::string local_rpc = local;
211 local_rpc +=
"/rpc:o";
212 std::string remote_rpc = remote;
213 remote_rpc +=
"/rpc:i";
215 if (!inputPort.open(local))
217 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error could not open port %s, check network", local.c_str());
220 inputPort.useCallback();
222 if (!rpcPort.open(local_rpc))
224 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error could not open rpc port %s, check network", local_rpc.c_str());
228 bool ok=Network::connect(remote.c_str(), local.c_str(), carrier.c_str());
231 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error could not connect to %s", remote.c_str());
235 ok=Network::connect(local_rpc, remote_rpc);
238 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error could not connect to %s\n", remote_rpc.c_str());
254 return inputPort.getLast(out, lastTs);
265 return inputPort.getChannels();
273 bool ok = rpcPort.write(cmd, response);
274 return checkResponse(ok, response);
283 for (
int i = 0; i < this->getChannels(); i++)
285 bool ok = rpcPort.write(cmd, response);
286 return checkResponse(ok, response);
295 bool ok = rpcPort.write(cmd, response);
296 return checkResponse(ok, response);
306 bool ok = rpcPort.write(cmd, response);
307 return checkResponse(ok, response);
A simple collection of objects that can be described and transmitted in a portable way.
A base class for nested structures that can be searched.
#define YARP_LOG_COMPONENT(name,...)
int getState(int ch) override
Check the state value of a given channel.
void addFloat64(yarp::conf::float64_t x)
Places a 64-bit floating point number in the bottle, at the end of the list.
double now()
Return the current time in seconds, relative to an arbitrary starting point.
An interface for the device drivers.
int getChannels() override
Get the number of channels of the sensor.
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
bool close() override
Close the DeviceDriver.
double getTime() const
Get the time stamp.
virtual std::string asString() const
Get string value.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
yarp::os::Stamp getLastInputStamp() override
Get the time stamp for the last read data.
void addInt32(std::int32_t x)
Places a 32-bit integer in the bottle, at the end of the list.
int calibrateSensor() override
Calibrates the whole sensor.
void addVocab(int x)
Places a vocabulary item in the bottle, at the end of the list.
int calibrateChannel(int ch) override
Calibrates one single channel.
An abstraction for a time stamp and/or sequence number.
#define yCError(component,...)
virtual std::int32_t asInt32() const
Get 32-bit integer value.
void removeLeadingTrailingSlashesOnly(std::string &name)
An interface to the operating system, including Port based communication.
#define yCDebug(component,...)
The main, catch-all namespace for YARP.
int read(yarp::sig::Vector &out) override
Read a vector from the sensor.
A single value (typically within a Bottle).
constexpr yarp::conf::vocab32_t VOCAB_IANALOG
constexpr yarp::conf::vocab32_t VOCAB_CALIBRATE_CHANNEL
constexpr yarp::conf::vocab32_t VOCAB_CALIBRATE
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
virtual bool isInt32() const
Checks if value is a 32-bit integer.