|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
33 if (m_local_name ==
"")
35 yCError(ROBOTDESCRIPTIONSERVER,
"open(): Invalid local name");
39 std::string local_rpc = m_local_name;
42 if (!m_rpc_port.open(local_rpc))
44 yCError(ROBOTDESCRIPTIONSERVER,
"open(): Could not open rpc port %s, check network", local_rpc.c_str());
48 m_rpc_port.setReader(*
this);
54 std::lock_guard<std::mutex> guard(m_external_mutex);
55 for (
int i = 0; i < p.
size(); i++)
57 yCTrace(ROBOTDESCRIPTIONSERVER) << p[i]->poly->getOptions().toString();
58 yCTrace(ROBOTDESCRIPTIONSERVER) << p[i]->poly->getValue(
"device").toString();
59 yCTrace(ROBOTDESCRIPTIONSERVER) << p[i]->poly->getValue(
"name").toString();
61 dev.
device_name = p[i]->poly->getValue(
"name").toString();
62 dev.
device_type = p[i]->poly->getValue(
"device").toString();
63 if (this->add_device(dev) ==
false)
65 yCError(ROBOTDESCRIPTIONSERVER) <<
"attachAll(): Something strange happened here";
74 std::lock_guard<std::mutex> guard(m_external_mutex);
75 m_robot_devices.clear();
87 std::lock_guard<std::mutex> guard(m_internal_mutex);
88 for (
auto& m_robot_device : m_robot_devices)
92 yCWarning(ROBOTDESCRIPTIONSERVER) <<
"add_device(): Device" << dev.
device_name <<
"already exists, skipping";
96 m_robot_devices.push_back(dev);
102 std::lock_guard<std::mutex> guard(m_internal_mutex);
103 for (
auto it = m_robot_devices.begin(); it != m_robot_devices.end(); it++)
107 m_robot_devices.erase(it);
116 std::lock_guard<std::mutex> guard(m_external_mutex);
122 bool ok = in.
read(connection);
123 if (!ok)
return false;
139 for (
auto& m_robot_device : m_robot_devices)
151 for (
auto& m_robot_device : m_robot_devices)
153 if (m_robot_device.device_type == type)
164 yCError(ROBOTDESCRIPTIONSERVER,
"Invalid vocab received");
176 bool b_rem = this->remove_device(dev);
179 yCError(ROBOTDESCRIPTIONSERVER) <<
"remove_device failed";
190 yCError(ROBOTDESCRIPTIONSERVER,
"Invalid vocab received");
201 bool b_add = this->add_device(desc);
204 yCError(ROBOTDESCRIPTIONSERVER) <<
"add_device failed";
215 yCError(ROBOTDESCRIPTIONSERVER,
"Invalid vocab received");
221 yCError(ROBOTDESCRIPTIONSERVER,
"Invalid vocab received");
227 yCError(ROBOTDESCRIPTIONSERVER,
"Invalid vocab received");
238 if (returnToSender !=
nullptr)
240 out.
write(*returnToSender);
constexpr yarp::conf::vocab32_t VOCAB_IROBOT_BY_TYPE
A simple collection of objects that can be described and transmitted in a portable way.
virtual std::int32_t asVocab() const
Get vocabulary identifier as an integer.
void clear()
Empties the bottle of any objects it contains.
bool attachAll(const yarp::dev::PolyDriverList &l) override
Attach to a list of objects.
A base class for nested structures that can be searched.
constexpr yarp::conf::vocab32_t VOCAB_IROBOT_DEVICE
#define yCWarning(component,...)
#define YARP_LOG_COMPONENT(name,...)
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool detachAll() override
Detach the object (you must have first called attach).
An interface for the device drivers.
constexpr yarp::conf::vocab32_t VOCAB_IROBOT_DESCRIPTION
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
bool write(ConnectionWriter &writer) const override
Output a representation of the bottle to a network connection.
constexpr yarp::conf::vocab32_t VOCAB_IROBOT_SET
An interface for writing to a network connection.
virtual std::string asString() const
Get string value.
constexpr yarp::conf::vocab32_t VOCAB_FAILED
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual ConnectionWriter * getWriter()=0
Gets a way to reply to the message, if possible.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
constexpr yarp::conf::vocab32_t VOCAB_IROBOT_DELETE
void addVocab(int x)
Places a vocabulary item in the bottle, at the end of the list.
An interface for reading from a network connection.
constexpr yarp::conf::vocab32_t VOCAB_IROBOT_GET
#define yCError(component,...)
An interface to the operating system, including Port based communication.
bool close() override
Close the DeviceDriver.
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
constexpr yarp::conf::vocab32_t VOCAB_IROBOT_ALL
#define yCTrace(component,...)
constexpr yarp::conf::vocab32_t VOCAB_OK