31bool SimulatedWorld_nws_yarp::attach(
PolyDriver* driver)
39 driver->
view(m_Isim_p);
40 if (
nullptr == m_Isim_p)
45 m_msgsImpl = std::make_unique<ISimulatedWorldMsgsImpl>(m_Isim_p);
50bool SimulatedWorld_nws_yarp::detach()
58 if (!connection.
isValid()) {
return false;}
59 if (!m_msgsImpl) {
return false;}
61 bool b = m_msgsImpl->read(connection);
77 m_rpcPortName =
m_name +
"/rpc:i";
79 if (!m_rpcPort.
open(m_rpcPortName.c_str()))
99 std::lock_guard <std::mutex>
lg(m_mutex);
100 auto ret = m_iSim->
attach(
id, link_name);
110 std::lock_guard <std::mutex>
lg(m_mutex);
121 std::lock_guard <std::mutex>
lg(m_mutex);
132 std::lock_guard <std::mutex>
lg(m_mutex);
143 std::lock_guard <std::mutex>
lg(m_mutex);
154 std::lock_guard <std::mutex>
lg(m_mutex);
165 std::lock_guard <std::mutex>
lg(m_mutex);
166 auto ret = m_iSim->
setPose(
id, pose, frame_name);
176 std::lock_guard <std::mutex>
lg(m_mutex);
177 auto ret = m_iSim->
makeSphere(id_name, radius, pose, color, frame_name, gravity_enable, collision_enable);
187 std::lock_guard <std::mutex>
lg(m_mutex);
188 auto ret = m_iSim->
makeBox(id_name, width, height, thickness, pose, color, frame_name, gravity_enable, collision_enable);
198 std::lock_guard <std::mutex>
lg(m_mutex);
199 auto ret = m_iSim->
makeCylinder(id_name, radius, length, pose, color, frame_name, gravity_enable, collision_enable);
209 std::lock_guard <std::mutex>
lg(m_mutex);
210 auto ret = m_iSim->
makeFrame(id_name, size, pose, color, frame_name, gravity_enable, collision_enable);
220 std::lock_guard <std::mutex>
lg(m_mutex);
221 auto ret = m_iSim->
makeModel(id_name, filename, pose, frame_name, gravity_enable, collision_enable);
231 std::lock_guard <std::mutex>
lg(m_mutex);
242 std::lock_guard <std::mutex>
lg(m_mutex);
243 auto ret = m_iSim->
detach(
id);
253 std::lock_guard <std::mutex>
lg(m_mutex);
254 auto ret = m_iSim->
rename(old_name, new_name);
264 std::lock_guard <std::mutex>
lg(m_mutex);
267 std::vector<std::string> names;
268 auto ret = m_iSim->
getList(names);
284 std::lock_guard <std::mutex>
lg(m_mutex);
288 auto ret = m_iSim->
getPose(
id, pose, frame_name);
297 response.
pose = pose;
yarp::dev::ReturnValue enableCollision(const std::string &id, const bool enable) override
yarp::dev::ReturnValue makeBox(const std::string &id_name, const double width, const double height, const double thickness, const yarp::sig::Pose6D &pose, const yarp::sig::ColorRGB &color, const std::string &frame_name, const bool gravity_enable, const bool collision_enable) override
getPoseReturnValue getPose(const std::string &id, const std::string &frame_name) override
yarp::dev::ReturnValue makeSphere(const std::string &id_name, const double radius, const yarp::sig::Pose6D &pose, const yarp::sig::ColorRGB &color, const std::string &frame_name, const bool gravity_enable, const bool collision_enable) override
yarp::dev::ReturnValue rename(const std::string &old_name, const std::string &new_name) override
yarp::dev::ReturnValue makeModel(const std::string &id_name, const std::string &filename, const yarp::sig::Pose6D &pose, const std::string &frame_name, const bool gravity_enable, const bool collision_enable) override
yarp::dev::ReturnValue deleteObject(const std::string &id) override
yarp::dev::ReturnValue detach(const std::string &id) override
yarp::dev::ReturnValue setPose(const std::string &id, const yarp::sig::Pose6D &pose, const std::string &frame_name="") override
yarp::dev::ReturnValue changeColor(const std::string &id, const yarp::sig::ColorRGB &color) override
yarp::dev::ReturnValue enableGravity(const std::string &id, const bool enable) override
yarp::dev::ReturnValue makeFrame(const std::string &id_name, const double size, const yarp::sig::Pose6D &pose, const yarp::sig::ColorRGB &color, const std::string &frame_name, const bool gravity_enable, const bool collision_enable) override
yarp::dev::ReturnValue attach(const std::string &id, const std::string &link_name) override
yarp::dev::ReturnValue makeCylinder(const std::string &id_name, const double radius, const double length, const yarp::sig::Pose6D &pose, const yarp::sig::ColorRGB &color, const std::string &frame_name, const bool gravity_enable, const bool collision_enable) override
getListReturnValue getList() override
yarp::dev::ReturnValue makeActor(const std::string &id_name, const std::string &skin_filename, const std::string &actor_filename, const yarp::sig::Pose6D &pose) override
yarp::dev::ReturnValue deleteAll() override
ISimulatedWorldMsgsImpl(yarp::dev::ISimulatedWorld *iSim)
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
bool close() override
Close the DeviceDriver.
bool open(yarp::os::Searchable ¶ms) override
Open the DeviceDriver.
~SimulatedWorld_nws_yarp()
SimulatedWorld_nws_yarp()
yarp::dev::ReturnValue retVal
std::vector< std::string > listnames
yarp::dev::ReturnValue retVal
bool view(T *&x)
Get an interface to the device driver.
ISimulatedWorld Interface.
virtual yarp::dev::ReturnValue getPose(std::string id, yarp::sig::Pose6D &pose, std::string frame_name="")=0
Get object pose.
virtual yarp::dev::ReturnValue enableGravity(std::string id, bool enable)=0
Enable/disables gravity for an object.
virtual yarp::dev::ReturnValue enableCollision(std::string id, bool enable)=0
Enable/disables collision detection for an object.
virtual yarp::dev::ReturnValue getList(std::vector< std::string > &names)=0
List id of all objects that have been added to the world.
virtual yarp::dev::ReturnValue setPose(std::string id, yarp::sig::Pose6D pose, std::string frame_name="")=0
Set new object pose.
virtual yarp::dev::ReturnValue attach(std::string id, std::string link_name)=0
Attach an object to a link of another object.
virtual yarp::dev::ReturnValue makeCylinder(std::string id, double radius, double length, yarp::sig::Pose6D pose, yarp::sig::ColorRGB color, std::string frame_name="", bool gravity_enable=0, bool collision_enable=1)=0
Make a cylinder.
virtual yarp::dev::ReturnValue changeColor(std::string id, yarp::sig::ColorRGB color)=0
Change the color of an object.
virtual yarp::dev::ReturnValue makeFrame(std::string id, double size, yarp::sig::Pose6D pose, yarp::sig::ColorRGB color, std::string frame_name="", bool gravity_enable=0, bool collision_enable=1)=0
Make a reference frame (a 3D model with 3 arrows representing the axes)
virtual yarp::dev::ReturnValue deleteObject(std::string id)=0
Delete an object.
virtual yarp::dev::ReturnValue makeActor(std::string id, std::string skin_filename, std::string animation_filename, yarp::sig::Pose6D pose)=0
Create an actor.
virtual yarp::dev::ReturnValue makeModel(std::string id, std::string filename, yarp::sig::Pose6D pose, std::string frame_name="", bool gravity_enable=0, bool collision_enable=1)=0
Create a model from a file.
virtual yarp::dev::ReturnValue makeSphere(std::string id, double radius, yarp::sig::Pose6D pose, yarp::sig::ColorRGB color, std::string frame_name="", bool gravity_enable=0, bool collision_enable=1)=0
Make a sphere.
virtual yarp::dev::ReturnValue rename(std::string old_name, std::string new_name)=0
Change the names of an object.
virtual yarp::dev::ReturnValue makeBox(std::string id, double width, double height, double thickness, yarp::sig::Pose6D pose, yarp::sig::ColorRGB color, std::string frame_name="", bool gravity_enable=0, bool collision_enable=1)=0
Make a box.
virtual yarp::dev::ReturnValue deleteAll()=0
Delete all objects in the world.
virtual yarp::dev::ReturnValue detach(std::string id)=0
Detach a previously attached object.
A container for a device driver.
bool detachAll() final
Detach the object (you must have first called attach).
A mini-server for performing network communication in the background.
An interface for reading from a network connection.
virtual bool isValid() const =0
void setReader(PortReader &reader) override
Set an external reader for port data.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
A base class for nested structures that can be searched.
#define yCError(component,...)
#define yCTrace(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.