diff --git a/plugins/clock/include/GazeboYarpPlugins/ClockServerImpl.h b/plugins/clock/include/GazeboYarpPlugins/ClockServerImpl.h index c35eb2813..c02ad14ca 100644 --- a/plugins/clock/include/GazeboYarpPlugins/ClockServerImpl.h +++ b/plugins/clock/include/GazeboYarpPlugins/ClockServerImpl.h @@ -27,6 +27,7 @@ class GazeboYarpPlugins::ClockServerImpl : public GazeboYarpPlugins::ClockServer virtual void resetSimulation(); virtual double getSimulationTime(); virtual double getStepSize(); + virtual void resetSimulationState(); private: diff --git a/plugins/clock/include/gazebo/Clock.hh b/plugins/clock/include/gazebo/Clock.hh index e60b96052..565d68b5b 100644 --- a/plugins/clock/include/gazebo/Clock.hh +++ b/plugins/clock/include/gazebo/Clock.hh @@ -101,6 +101,11 @@ public: */ void resetSimulationTime(); + /** + * Reset the simulation state back to initial state + */ + void resetSimulationState(); + /** * Reset the simulation time and state back to zero */ diff --git a/plugins/clock/src/Clock.cc b/plugins/clock/src/Clock.cc index 62cff254f..1fedbea36 100644 --- a/plugins/clock/src/Clock.cc +++ b/plugins/clock/src/Clock.cc @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -30,7 +31,6 @@ namespace gazebo , m_rpcPort(0) , m_clockServer(0) { - } GazeboYarpClock::~GazeboYarpClock() @@ -182,6 +182,12 @@ namespace gazebo m_world->Reset(); } + void GazeboYarpClock::resetSimulationState() + { + m_world->ResetEntities(gazebo::physics::Base::BASE); + event::Events::worldReset(); + } + common::Time GazeboYarpClock::getSimulationTime() { #if GAZEBO_MAJOR_VERSION >= 8 diff --git a/plugins/clock/src/ClockServerImpl.cpp b/plugins/clock/src/ClockServerImpl.cpp index 2b0373f1e..a52cceef5 100644 --- a/plugins/clock/src/ClockServerImpl.cpp +++ b/plugins/clock/src/ClockServerImpl.cpp @@ -52,4 +52,9 @@ namespace GazeboYarpPlugins { { return m_clock.getStepSize(); } + + void ClockServerImpl::resetSimulationState() + { + m_clock.resetSimulationState(); + } } diff --git a/thrift/clock/autogenerated/clock_rpc_thrift.cmake b/thrift/clock/autogenerated/clock_rpc_thrift.cmake index f39ac91f9..d161846b5 100644 --- a/thrift/clock/autogenerated/clock_rpc_thrift.cmake +++ b/thrift/clock/autogenerated/clock_rpc_thrift.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT) +# Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT) # All rights reserved. # # This software may be modified and distributed under the terms of the diff --git a/thrift/clock/autogenerated/include/ClockServer.h b/thrift/clock/autogenerated/include/ClockServer.h index 2aab41ecf..61f5c8beb 100644 --- a/thrift/clock/autogenerated/include/ClockServer.h +++ b/thrift/clock/autogenerated/include/ClockServer.h @@ -1,71 +1,92 @@ /* - * Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT) + * Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT) * All rights reserved. * * This software may be modified and distributed under the terms of the * BSD-3-Clause license. See the accompanying LICENSE file for details. */ +// Autogenerated by Thrift Compiler (0.12.0-yarped) +// // This is an automatically generated file. // It could get re-generated if the ALLOW_IDL_GENERATION flag is on. -#ifndef YARP_THRIFT_GENERATOR_ClockServer -#define YARP_THRIFT_GENERATOR_ClockServer +#ifndef YARP_THRIFT_GENERATOR_SERVICE_CLOCKSERVER_H +#define YARP_THRIFT_GENERATOR_SERVICE_CLOCKSERVER_H #include #include namespace GazeboYarpPlugins { - class ClockServer; -} - -class GazeboYarpPlugins::ClockServer : public yarp::os::Wire { +class ClockServer : + public yarp::os::Wire +{ public: - ClockServer(); - /** - * Pause the simulation if it was running - */ - virtual void pauseSimulation(); - /** - * Resume the simulation if it was paused - */ - virtual void continueSimulation(); - /** - * Steps the simulation for the provided number of steps. - * The input paramter is the number of steps, not the time (Usually 1 step = 1ms but this is not guaranteed) - * @note: this function (will be) not blocking, i.e. it will return immediately. Currently calling this function - * twice before the previous call actually ends its computation gives and undefined behavior. - * @param numberOfSteps number of steps to simulate - */ - virtual void stepSimulation(const std::int32_t numberOfSteps = 1); - /** - * Steps the simulation for the provided number of steps. - * The input paramter is the number of steps, not the time (Usually 1 step = 1ms but this is not guaranteed) - * @note: this function is blocking - * @param numberOfSteps number of steps to simulate - */ - virtual void stepSimulationAndWait(const std::int32_t numberOfSteps = 1); - /** - * Reset the simulation time back to zero - */ - virtual void resetSimulationTime(); - /** - * Get the current simulation time - * @return the simulation time. - */ - virtual double getSimulationTime(); - /** - * Get the current step size in seconds. - * @return the step size in seconds - */ - virtual double getStepSize(); - /** - * Reset the simulation state and time - */ - virtual void resetSimulation(); - virtual bool read(yarp::os::ConnectionReader& connection) override; - virtual std::vector help(const std::string& functionName="--all"); + // Constructor + ClockServer(); + + /** + * Pause the simulation if it was running + */ + virtual void pauseSimulation(); + + /** + * Resume the simulation if it was paused + */ + virtual void continueSimulation(); + + /** + * Steps the simulation for the provided number of steps. + * The input paramter is the number of steps, not the time (Usually 1 step = 1ms but this is not guaranteed) + * @note: this function (will be) not blocking, i.e. it will return immediately. Currently calling this function + * twice before the previous call actually ends its computation gives and undefined behavior. + * @param numberOfSteps number of steps to simulate + */ + virtual void stepSimulation(const std::int32_t numberOfSteps = 1); + + /** + * Steps the simulation for the provided number of steps. + * The input paramter is the number of steps, not the time (Usually 1 step = 1ms but this is not guaranteed) + * @note: this function is blocking + * @param numberOfSteps number of steps to simulate + */ + virtual void stepSimulationAndWait(const std::int32_t numberOfSteps = 1); + + /** + * Reset the simulation time back to zero + */ + virtual void resetSimulationTime(); + + /** + * Get the current simulation time + * @return the simulation time. + */ + virtual double getSimulationTime(); + + /** + * Get the current step size in seconds. + * @return the step size in seconds + */ + virtual double getStepSize(); + + /** + * Reset the simulation state and time + */ + virtual void resetSimulation(); + + /** + * Reset the simulation state back to initial pose + */ + virtual void resetSimulationState(); + + // help method + virtual std::vector help(const std::string& functionName = "--all"); + + // read from ConnectionReader + bool read(yarp::os::ConnectionReader& connection) override; }; -#endif +} // namespace GazeboYarpPlugins + +#endif // YARP_THRIFT_GENERATOR_SERVICE_CLOCKSERVER_H diff --git a/thrift/clock/autogenerated/src/ClockServer.cpp b/thrift/clock/autogenerated/src/ClockServer.cpp index cdbad17e8..442b8fd55 100644 --- a/thrift/clock/autogenerated/src/ClockServer.cpp +++ b/thrift/clock/autogenerated/src/ClockServer.cpp @@ -1,508 +1,715 @@ /* - * Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT) + * Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT) * All rights reserved. * * This software may be modified and distributed under the terms of the * BSD-3-Clause license. See the accompanying LICENSE file for details. */ +// Autogenerated by Thrift Compiler (0.12.0-yarped) +// // This is an automatically generated file. // It could get re-generated if the ALLOW_IDL_GENERATION flag is on. #include + #include namespace GazeboYarpPlugins { - -class ClockServer_pauseSimulation : public yarp::os::Portable { +class ClockServer_pauseSimulation : + public yarp::os::Portable +{ public: - void init(); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; + void init(); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; }; -class ClockServer_continueSimulation : public yarp::os::Portable { -public: - void init(); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; -}; +bool ClockServer_pauseSimulation::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeTag("pauseSimulation", 1, 1)) { + return false; + } + return true; +} -class ClockServer_stepSimulation : public yarp::os::Portable { +bool ClockServer_pauseSimulation::read(yarp::os::ConnectionReader& connection) +{ + YARP_UNUSED(connection); + return true; +} + +void ClockServer_pauseSimulation::init() +{ +} + +class ClockServer_continueSimulation : + public yarp::os::Portable +{ public: - std::int32_t numberOfSteps; - void init(const std::int32_t numberOfSteps); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; + void init(); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; }; -class ClockServer_stepSimulationAndWait : public yarp::os::Portable { +bool ClockServer_continueSimulation::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeTag("continueSimulation", 1, 1)) { + return false; + } + return true; +} + +bool ClockServer_continueSimulation::read(yarp::os::ConnectionReader& connection) +{ + YARP_UNUSED(connection); + return true; +} + +void ClockServer_continueSimulation::init() +{ +} + +class ClockServer_stepSimulation : + public yarp::os::Portable +{ public: - std::int32_t numberOfSteps; - void init(const std::int32_t numberOfSteps); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; + std::int32_t numberOfSteps; + void init(const std::int32_t numberOfSteps); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; }; -class ClockServer_resetSimulationTime : public yarp::os::Portable { +bool ClockServer_stepSimulation::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(2)) { + return false; + } + if (!writer.writeTag("stepSimulation", 1, 1)) { + return false; + } + if (!writer.writeI32(numberOfSteps)) { + return false; + } + return true; +} + +bool ClockServer_stepSimulation::read(yarp::os::ConnectionReader& connection) +{ + YARP_UNUSED(connection); + return true; +} + +void ClockServer_stepSimulation::init(const std::int32_t numberOfSteps) +{ + this->numberOfSteps = numberOfSteps; +} + +class ClockServer_stepSimulationAndWait : + public yarp::os::Portable +{ public: - void init(); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; + std::int32_t numberOfSteps; + void init(const std::int32_t numberOfSteps); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; }; -class ClockServer_getSimulationTime : public yarp::os::Portable { +bool ClockServer_stepSimulationAndWait::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(2)) { + return false; + } + if (!writer.writeTag("stepSimulationAndWait", 1, 1)) { + return false; + } + if (!writer.writeI32(numberOfSteps)) { + return false; + } + return true; +} + +bool ClockServer_stepSimulationAndWait::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { + return false; + } + return true; +} + +void ClockServer_stepSimulationAndWait::init(const std::int32_t numberOfSteps) +{ + this->numberOfSteps = numberOfSteps; +} + +class ClockServer_resetSimulationTime : + public yarp::os::Portable +{ public: - double _return; - void init(); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; + void init(); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; }; -class ClockServer_getStepSize : public yarp::os::Portable { +bool ClockServer_resetSimulationTime::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeTag("resetSimulationTime", 1, 1)) { + return false; + } + return true; +} + +bool ClockServer_resetSimulationTime::read(yarp::os::ConnectionReader& connection) +{ + YARP_UNUSED(connection); + return true; +} + +void ClockServer_resetSimulationTime::init() +{ +} + +class ClockServer_getSimulationTime : + public yarp::os::Portable +{ public: - double _return; - void init(); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; + double _return; + void init(); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; }; -class ClockServer_resetSimulation : public yarp::os::Portable { +bool ClockServer_getSimulationTime::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeTag("getSimulationTime", 1, 1)) { + return false; + } + return true; +} + +bool ClockServer_getSimulationTime::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { + return false; + } + if (!reader.readFloat64(_return)) { + reader.fail(); + return false; + } + return true; +} + +void ClockServer_getSimulationTime::init() +{ + _return = (double)0; +} + +class ClockServer_getStepSize : + public yarp::os::Portable +{ public: - void init(); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; + double _return; + void init(); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; }; -bool ClockServer_pauseSimulation::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(1)) return false; - if (!writer.writeTag("pauseSimulation",1,1)) return false; - return true; +bool ClockServer_getStepSize::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeTag("getStepSize", 1, 1)) { + return false; + } + return true; } -bool ClockServer_pauseSimulation::read(yarp::os::ConnectionReader& connection) { - YARP_UNUSED(connection); - return true; +bool ClockServer_getStepSize::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { + return false; + } + if (!reader.readFloat64(_return)) { + reader.fail(); + return false; + } + return true; } -void ClockServer_pauseSimulation::init() { +void ClockServer_getStepSize::init() +{ + _return = (double)0; } -bool ClockServer_continueSimulation::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(1)) return false; - if (!writer.writeTag("continueSimulation",1,1)) return false; - return true; -} +class ClockServer_resetSimulation : + public yarp::os::Portable +{ +public: + void init(); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; +}; -bool ClockServer_continueSimulation::read(yarp::os::ConnectionReader& connection) { - YARP_UNUSED(connection); - return true; +bool ClockServer_resetSimulation::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeTag("resetSimulation", 1, 1)) { + return false; + } + return true; } -void ClockServer_continueSimulation::init() { +bool ClockServer_resetSimulation::read(yarp::os::ConnectionReader& connection) +{ + YARP_UNUSED(connection); + return true; } -bool ClockServer_stepSimulation::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(2)) return false; - if (!writer.writeTag("stepSimulation",1,1)) return false; - if (!writer.writeI32(numberOfSteps)) return false; - return true; +void ClockServer_resetSimulation::init() +{ } -bool ClockServer_stepSimulation::read(yarp::os::ConnectionReader& connection) { - YARP_UNUSED(connection); - return true; +class ClockServer_resetSimulationState : + public yarp::os::Portable +{ +public: + void init(); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; +}; + +bool ClockServer_resetSimulationState::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeTag("resetSimulationState", 1, 1)) { + return false; + } + return true; } -void ClockServer_stepSimulation::init(const std::int32_t numberOfSteps) { - this->numberOfSteps = numberOfSteps; +bool ClockServer_resetSimulationState::read(yarp::os::ConnectionReader& connection) +{ + YARP_UNUSED(connection); + return true; } -bool ClockServer_stepSimulationAndWait::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(2)) return false; - if (!writer.writeTag("stepSimulationAndWait",1,1)) return false; - if (!writer.writeI32(numberOfSteps)) return false; - return true; +void ClockServer_resetSimulationState::init() +{ } -bool ClockServer_stepSimulationAndWait::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - return true; +// Constructor +ClockServer::ClockServer() +{ + yarp().setOwner(*this); } -void ClockServer_stepSimulationAndWait::init(const std::int32_t numberOfSteps) { - this->numberOfSteps = numberOfSteps; +void ClockServer::pauseSimulation() +{ + ClockServer_pauseSimulation helper; + helper.init(); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "void ClockServer::pauseSimulation()"); + } + yarp().write(helper); } -bool ClockServer_resetSimulationTime::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(1)) return false; - if (!writer.writeTag("resetSimulationTime",1,1)) return false; - return true; +void ClockServer::continueSimulation() +{ + ClockServer_continueSimulation helper; + helper.init(); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "void ClockServer::continueSimulation()"); + } + yarp().write(helper); } -bool ClockServer_resetSimulationTime::read(yarp::os::ConnectionReader& connection) { - YARP_UNUSED(connection); - return true; +void ClockServer::stepSimulation(const std::int32_t numberOfSteps) +{ + ClockServer_stepSimulation helper; + helper.init(numberOfSteps); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "void ClockServer::stepSimulation(const std::int32_t numberOfSteps)"); + } + yarp().write(helper); } -void ClockServer_resetSimulationTime::init() { +void ClockServer::stepSimulationAndWait(const std::int32_t numberOfSteps) +{ + ClockServer_stepSimulationAndWait helper; + helper.init(numberOfSteps); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "void ClockServer::stepSimulationAndWait(const std::int32_t numberOfSteps)"); + } + yarp().write(helper, helper); } -bool ClockServer_getSimulationTime::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(1)) return false; - if (!writer.writeTag("getSimulationTime",1,1)) return false; - return true; +void ClockServer::resetSimulationTime() +{ + ClockServer_resetSimulationTime helper; + helper.init(); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "void ClockServer::resetSimulationTime()"); + } + yarp().write(helper); } -bool ClockServer_getSimulationTime::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - if (!reader.readFloat64(_return)) { - reader.fail(); - return false; - } - return true; +double ClockServer::getSimulationTime() +{ + double _return = (double)0; + ClockServer_getSimulationTime helper; + helper.init(); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "double ClockServer::getSimulationTime()"); + } + bool ok = yarp().write(helper, helper); + return ok ? helper._return : _return; } -void ClockServer_getSimulationTime::init() { - _return = (double)0; +double ClockServer::getStepSize() +{ + double _return = (double)0; + ClockServer_getStepSize helper; + helper.init(); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "double ClockServer::getStepSize()"); + } + bool ok = yarp().write(helper, helper); + return ok ? helper._return : _return; } -bool ClockServer_getStepSize::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(1)) return false; - if (!writer.writeTag("getStepSize",1,1)) return false; - return true; +void ClockServer::resetSimulation() +{ + ClockServer_resetSimulation helper; + helper.init(); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "void ClockServer::resetSimulation()"); + } + yarp().write(helper); } -bool ClockServer_getStepSize::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - if (!reader.readFloat64(_return)) { - reader.fail(); - return false; - } - return true; -} - -void ClockServer_getStepSize::init() { - _return = (double)0; -} - -bool ClockServer_resetSimulation::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(1)) return false; - if (!writer.writeTag("resetSimulation",1,1)) return false; - return true; -} - -bool ClockServer_resetSimulation::read(yarp::os::ConnectionReader& connection) { - YARP_UNUSED(connection); - return true; -} - -void ClockServer_resetSimulation::init() { -} - -ClockServer::ClockServer() { - yarp().setOwner(*this); -} -void ClockServer::pauseSimulation() { - ClockServer_pauseSimulation helper; - helper.init(); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","void ClockServer::pauseSimulation()"); - } - yarp().write(helper); -} -void ClockServer::continueSimulation() { - ClockServer_continueSimulation helper; - helper.init(); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","void ClockServer::continueSimulation()"); - } - yarp().write(helper); -} -void ClockServer::stepSimulation(const std::int32_t numberOfSteps) { - ClockServer_stepSimulation helper; - helper.init(numberOfSteps); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","void ClockServer::stepSimulation(const std::int32_t numberOfSteps)"); - } - yarp().write(helper); -} -void ClockServer::stepSimulationAndWait(const std::int32_t numberOfSteps) { - ClockServer_stepSimulationAndWait helper; - helper.init(numberOfSteps); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","void ClockServer::stepSimulationAndWait(const std::int32_t numberOfSteps)"); - } - yarp().write(helper,helper); -} -void ClockServer::resetSimulationTime() { - ClockServer_resetSimulationTime helper; - helper.init(); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","void ClockServer::resetSimulationTime()"); - } - yarp().write(helper); -} -double ClockServer::getSimulationTime() { - double _return = (double)0; - ClockServer_getSimulationTime helper; - helper.init(); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","double ClockServer::getSimulationTime()"); - } - bool ok = yarp().write(helper,helper); - return ok?helper._return:_return; -} -double ClockServer::getStepSize() { - double _return = (double)0; - ClockServer_getStepSize helper; - helper.init(); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","double ClockServer::getStepSize()"); - } - bool ok = yarp().write(helper,helper); - return ok?helper._return:_return; -} -void ClockServer::resetSimulation() { - ClockServer_resetSimulation helper; - helper.init(); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","void ClockServer::resetSimulation()"); - } - yarp().write(helper); -} - -bool ClockServer::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - reader.expectAccept(); - if (!reader.readListHeader()) { reader.fail(); return false; } - std::string tag = reader.readTag(); - bool direct = (tag=="__direct__"); - if (direct) tag = reader.readTag(); - while (!reader.isError()) { - // TODO: use quick lookup, this is just a test - if (tag == "pauseSimulation") { - if (!direct) { - ClockServer_pauseSimulation helper; - helper.init(); - yarp().callback(helper,*this,"__direct__"); - } else { - pauseSimulation(); - } - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeOnewayResponse()) return false; - } - reader.accept(); - return true; - } - if (tag == "continueSimulation") { - if (!direct) { - ClockServer_continueSimulation helper; - helper.init(); - yarp().callback(helper,*this,"__direct__"); - } else { - continueSimulation(); - } - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeOnewayResponse()) return false; - } - reader.accept(); - return true; - } - if (tag == "stepSimulation") { - std::int32_t numberOfSteps; - if (!reader.readI32(numberOfSteps)) { - numberOfSteps = 1; - } - if (!direct) { - ClockServer_stepSimulation helper; - helper.init(numberOfSteps); - yarp().callback(helper,*this,"__direct__"); - } else { - stepSimulation(numberOfSteps); - } - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeOnewayResponse()) return false; - } - reader.accept(); - return true; - } - if (tag == "stepSimulationAndWait") { - std::int32_t numberOfSteps; - if (!reader.readI32(numberOfSteps)) { - numberOfSteps = 1; - } - stepSimulationAndWait(numberOfSteps); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(0)) return false; - } - reader.accept(); - return true; - } - if (tag == "resetSimulationTime") { - if (!direct) { - ClockServer_resetSimulationTime helper; - helper.init(); - yarp().callback(helper,*this,"__direct__"); - } else { - resetSimulationTime(); - } - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeOnewayResponse()) return false; - } - reader.accept(); - return true; - } - if (tag == "getSimulationTime") { - double _return; - _return = getSimulationTime(); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeFloat64(_return)) return false; - } - reader.accept(); - return true; - } - if (tag == "getStepSize") { - double _return; - _return = getStepSize(); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeFloat64(_return)) return false; - } - reader.accept(); - return true; - } - if (tag == "resetSimulation") { - if (!direct) { - ClockServer_resetSimulation helper; - helper.init(); - yarp().callback(helper,*this,"__direct__"); - } else { - resetSimulation(); - } - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeOnewayResponse()) return false; - } - reader.accept(); - return true; - } - if (tag == "help") { - std::string functionName; - if (!reader.readString(functionName)) { - functionName = "--all"; - } - std::vector _return=help(functionName); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(2)) return false; - if (!writer.writeTag("many",1, 0)) return false; - if (!writer.writeListBegin(BOTTLE_TAG_INT32, static_cast(_return.size()))) return false; - std::vector ::iterator _iterHelp; - for (_iterHelp = _return.begin(); _iterHelp != _return.end(); ++_iterHelp) - { - if (!writer.writeString(*_iterHelp)) return false; - } - if (!writer.writeListEnd()) return false; +void ClockServer::resetSimulationState() +{ + ClockServer_resetSimulationState helper; + helper.init(); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "void ClockServer::resetSimulationState()"); + } + yarp().write(helper); +} + +// help method +std::vector ClockServer::help(const std::string& functionName) +{ + bool showAll = (functionName == "--all"); + std::vector helpString; + if (showAll) { + helpString.emplace_back("*** Available commands:"); + helpString.emplace_back("pauseSimulation"); + helpString.emplace_back("continueSimulation"); + helpString.emplace_back("stepSimulation"); + helpString.emplace_back("stepSimulationAndWait"); + helpString.emplace_back("resetSimulationTime"); + helpString.emplace_back("getSimulationTime"); + helpString.emplace_back("getStepSize"); + helpString.emplace_back("resetSimulation"); + helpString.emplace_back("resetSimulationState"); + helpString.emplace_back("help"); + } else { + if (functionName == "pauseSimulation") { + helpString.emplace_back("void pauseSimulation() "); + helpString.emplace_back("Pause the simulation if it was running "); + } + if (functionName == "continueSimulation") { + helpString.emplace_back("void continueSimulation() "); + helpString.emplace_back("Resume the simulation if it was paused "); + } + if (functionName == "stepSimulation") { + helpString.emplace_back("void stepSimulation(const std::int32_t numberOfSteps = 1) "); + helpString.emplace_back("Steps the simulation for the provided number of steps. "); + helpString.emplace_back("The input paramter is the number of steps, not the time (Usually 1 step = 1ms but this is not guaranteed) "); + helpString.emplace_back("@note: this function (will be) not blocking, i.e. it will return immediately. Currently calling this function "); + helpString.emplace_back("twice before the previous call actually ends its computation gives and undefined behavior. "); + helpString.emplace_back("@param numberOfSteps number of steps to simulate "); + } + if (functionName == "stepSimulationAndWait") { + helpString.emplace_back("void stepSimulationAndWait(const std::int32_t numberOfSteps = 1) "); + helpString.emplace_back("Steps the simulation for the provided number of steps. "); + helpString.emplace_back("The input paramter is the number of steps, not the time (Usually 1 step = 1ms but this is not guaranteed) "); + helpString.emplace_back("@note: this function is blocking "); + helpString.emplace_back("@param numberOfSteps number of steps to simulate "); } - reader.accept(); - return true; - } - if (reader.noMore()) { reader.fail(); return false; } - std::string next_tag = reader.readTag(); - if (next_tag=="") break; - tag = tag + "_" + next_tag; - } - return false; -} - -std::vector ClockServer::help(const std::string& functionName) { - bool showAll=(functionName=="--all"); - std::vector helpString; - if(showAll) { - helpString.push_back("*** Available commands:"); - helpString.push_back("pauseSimulation"); - helpString.push_back("continueSimulation"); - helpString.push_back("stepSimulation"); - helpString.push_back("stepSimulationAndWait"); - helpString.push_back("resetSimulationTime"); - helpString.push_back("getSimulationTime"); - helpString.push_back("getStepSize"); - helpString.push_back("resetSimulation"); - helpString.push_back("help"); - } - else { - if (functionName=="pauseSimulation") { - helpString.push_back("void pauseSimulation() "); - helpString.push_back("Pause the simulation if it was running "); - } - if (functionName=="continueSimulation") { - helpString.push_back("void continueSimulation() "); - helpString.push_back("Resume the simulation if it was paused "); - } - if (functionName=="stepSimulation") { - helpString.push_back("void stepSimulation(const std::int32_t numberOfSteps = 1) "); - helpString.push_back("Steps the simulation for the provided number of steps. "); - helpString.push_back("The input paramter is the number of steps, not the time (Usually 1 step = 1ms but this is not guaranteed) "); - helpString.push_back("@note: this function (will be) not blocking, i.e. it will return immediately. Currently calling this function "); - helpString.push_back("twice before the previous call actually ends its computation gives and undefined behavior. "); - helpString.push_back("@param numberOfSteps number of steps to simulate "); - } - if (functionName=="stepSimulationAndWait") { - helpString.push_back("void stepSimulationAndWait(const std::int32_t numberOfSteps = 1) "); - helpString.push_back("Steps the simulation for the provided number of steps. "); - helpString.push_back("The input paramter is the number of steps, not the time (Usually 1 step = 1ms but this is not guaranteed) "); - helpString.push_back("@note: this function is blocking "); - helpString.push_back("@param numberOfSteps number of steps to simulate "); - } - if (functionName=="resetSimulationTime") { - helpString.push_back("void resetSimulationTime() "); - helpString.push_back("Reset the simulation time back to zero "); - } - if (functionName=="getSimulationTime") { - helpString.push_back("double getSimulationTime() "); - helpString.push_back("Get the current simulation time "); - helpString.push_back("@return the simulation time. "); - } - if (functionName=="getStepSize") { - helpString.push_back("double getStepSize() "); - helpString.push_back("Get the current step size in seconds. "); - helpString.push_back("@return the step size in seconds "); - } - if (functionName=="resetSimulation") { - helpString.push_back("void resetSimulation() "); - helpString.push_back("Reset the simulation state and time "); - } - if (functionName=="help") { - helpString.push_back("std::vector help(const std::string& functionName=\"--all\")"); - helpString.push_back("Return list of available commands, or help message for a specific function"); - helpString.push_back("@param functionName name of command for which to get a detailed description. If none or '--all' is provided, print list of available commands"); - helpString.push_back("@return list of strings (one string per line)"); - } - } - if ( helpString.empty()) helpString.push_back("Command not found"); - return helpString; -} -} // namespace + if (functionName == "resetSimulationTime") { + helpString.emplace_back("void resetSimulationTime() "); + helpString.emplace_back("Reset the simulation time back to zero "); + } + if (functionName == "getSimulationTime") { + helpString.emplace_back("double getSimulationTime() "); + helpString.emplace_back("Get the current simulation time "); + helpString.emplace_back("@return the simulation time. "); + } + if (functionName == "getStepSize") { + helpString.emplace_back("double getStepSize() "); + helpString.emplace_back("Get the current step size in seconds. "); + helpString.emplace_back("@return the step size in seconds "); + } + if (functionName == "resetSimulation") { + helpString.emplace_back("void resetSimulation() "); + helpString.emplace_back("Reset the simulation state and time "); + } + if (functionName == "resetSimulationState") { + helpString.emplace_back("void resetSimulationState() "); + helpString.emplace_back("Reset the simulation state back to initial pose "); + } + if (functionName == "help") { + helpString.emplace_back("std::vector help(const std::string& functionName = \"--all\")"); + helpString.emplace_back("Return list of available commands, or help message for a specific function"); + helpString.emplace_back("@param functionName name of command for which to get a detailed description. If none or '--all' is provided, print list of available commands"); + helpString.emplace_back("@return list of strings (one string per line)"); + } + } + if (helpString.empty()) { + helpString.emplace_back("Command not found"); + } + return helpString; +} + +// read from ConnectionReader +bool ClockServer::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + reader.expectAccept(); + if (!reader.readListHeader()) { + reader.fail(); + return false; + } + std::string tag = reader.readTag(); + bool direct = (tag == "__direct__"); + if (direct) { + tag = reader.readTag(); + } + while (!reader.isError()) { + if (tag == "pauseSimulation") { + if (!direct) { + ClockServer_pauseSimulation helper; + helper.init(); + yarp().callback(helper,*this, "__direct__"); + } else { + pauseSimulation(); + } + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeOnewayResponse()) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "continueSimulation") { + if (!direct) { + ClockServer_continueSimulation helper; + helper.init(); + yarp().callback(helper,*this, "__direct__"); + } else { + continueSimulation(); + } + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeOnewayResponse()) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "stepSimulation") { + std::int32_t numberOfSteps; + if (!reader.readI32(numberOfSteps)) { + numberOfSteps = 1; + } + if (!direct) { + ClockServer_stepSimulation helper; + helper.init(numberOfSteps); + yarp().callback(helper,*this, "__direct__"); + } else { + stepSimulation(numberOfSteps); + } + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeOnewayResponse()) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "stepSimulationAndWait") { + std::int32_t numberOfSteps; + if (!reader.readI32(numberOfSteps)) { + numberOfSteps = 1; + } + stepSimulationAndWait(numberOfSteps); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(0)) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "resetSimulationTime") { + if (!direct) { + ClockServer_resetSimulationTime helper; + helper.init(); + yarp().callback(helper,*this, "__direct__"); + } else { + resetSimulationTime(); + } + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeOnewayResponse()) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "getSimulationTime") { + double _return; + _return = getSimulationTime(); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeFloat64(_return)) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "getStepSize") { + double _return; + _return = getStepSize(); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeFloat64(_return)) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "resetSimulation") { + if (!direct) { + ClockServer_resetSimulation helper; + helper.init(); + yarp().callback(helper,*this, "__direct__"); + } else { + resetSimulation(); + } + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeOnewayResponse()) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "resetSimulationState") { + if (!direct) { + ClockServer_resetSimulationState helper; + helper.init(); + yarp().callback(helper,*this, "__direct__"); + } else { + resetSimulationState(); + } + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeOnewayResponse()) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "help") { + std::string functionName; + if (!reader.readString(functionName)) { + functionName = "--all"; + } + auto _return = help(functionName); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(2)) { + return false; + } + if (!writer.writeTag("many", 1, 0)) { + return false; + } + if (!writer.writeListBegin(BOTTLE_TAG_INT32, static_cast(_return.size()))) { + return false; + } + for (const auto& _ret : _return) { + if (!writer.writeString(_ret)) { + return false; + } + } + if (!writer.writeListEnd()) { + return false; + } + } + reader.accept(); + return true; + } + if (reader.noMore()) { + reader.fail(); + return false; + } + std::string next_tag = reader.readTag(); + if (next_tag == "") { + break; + } + tag.append("_").append(next_tag); + } + return false; +} +} // namespace GazeboYarpPlugins diff --git a/thrift/clock/clock_rpc.thrift b/thrift/clock/clock_rpc.thrift index 77ab2924f..adcb264d5 100644 --- a/thrift/clock/clock_rpc.thrift +++ b/thrift/clock/clock_rpc.thrift @@ -46,5 +46,10 @@ service ClockServer { * */ oneway void resetSimulation(); + + /** Reset the simulation state back to initial pose + * + */ + oneway void resetSimulationState(); } diff --git a/thrift/linkattacher/autogenerated/include/LinkAttacherServer.h b/thrift/linkattacher/autogenerated/include/LinkAttacherServer.h index c92f91086..d8ac98227 100644 --- a/thrift/linkattacher/autogenerated/include/LinkAttacherServer.h +++ b/thrift/linkattacher/autogenerated/include/LinkAttacherServer.h @@ -1,53 +1,64 @@ /* - * Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT) + * Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT) * All rights reserved. * * This software may be modified and distributed under the terms of the * BSD-3-Clause license. See the accompanying LICENSE file for details. */ +// Autogenerated by Thrift Compiler (0.12.0-yarped) +// // This is an automatically generated file. // It could get re-generated if the ALLOW_IDL_GENERATION flag is on. -#ifndef YARP_THRIFT_GENERATOR_LinkAttacherServer -#define YARP_THRIFT_GENERATOR_LinkAttacherServer +#ifndef YARP_THRIFT_GENERATOR_SERVICE_LINKATTACHERSERVER_H +#define YARP_THRIFT_GENERATOR_SERVICE_LINKATTACHERSERVER_H #include #include namespace GazeboYarpPlugins { - class LinkAttacherServer; -} - -class GazeboYarpPlugins::LinkAttacherServer : public yarp::os::Wire { +class LinkAttacherServer : + public yarp::os::Wire +{ public: - LinkAttacherServer(); - /** - * Enable/disables gravity for a model - * @param model_name name that identifies model in gazebo (that are already spawned in gazebo) - * @param enable 1 to enable gravity, 0 otherwise - * @return returns true or false on success failure - */ - virtual bool enableGravity(const std::string& model_name, const bool enable); - /** - * Attach any link of the models spawned in gazebo to a link of the robot. - * @param model_name name that identifies model in gazebo (that are already spawned in gazebo) - * @param model_link_name name of a the link in the model you want to attach to the robot - * @param robot_name name of the robot - * @param robot_link_name name of the robot link to which you want to attached the model link - * @return true if success, false otherwise - */ - virtual bool attachUnscoped(const std::string& model_name, const std::string& model_link_name, const std::string& robot_name, const std::string& robot_link_name); - /** - * Detach a previously attached model link. - * @param model_name name that identifies model in gazebo (that are already spawned in gazebo) - * @param model_link_name name of a the link in the model that is attached to the robot - * @return true if success, false otherwise - */ - virtual bool detachUnscoped(const std::string& model_name, const std::string& model_link_name); - virtual bool read(yarp::os::ConnectionReader& connection) override; - virtual std::vector help(const std::string& functionName="--all"); + // Constructor + LinkAttacherServer(); + + /** + * Enable/disables gravity for a model + * @param model_name name that identifies model in gazebo (that are already spawned in gazebo) + * @param enable 1 to enable gravity, 0 otherwise + * @return returns true or false on success failure + */ + virtual bool enableGravity(const std::string& model_name, const bool enable); + + /** + * Attach any link of the models spawned in gazebo to a link of the robot using a fixed joint. + * @param model_name name that identifies model in gazebo (that are already spawned in gazebo) + * @param model_link_name name of a the link in the model you want to attach to the robot + * @param robot_name name of the robot + * @param robot_link_name name of the robot link to which you want to attached the model link + * @return true if success, false otherwise + */ + virtual bool attachUnscoped(const std::string& model_name, const std::string& model_link_name, const std::string& robot_name, const std::string& robot_link_name); + + /** + * Detach the model link which was previously attached to the robot link through a fixed joint. + * @param model_name name that identifies model in gazebo (that are already spawned in gazebo) + * @param model_link_name name of a the link in the model that is attached to the robot + * @return true if success, false otherwise + */ + virtual bool detachUnscoped(const std::string& model_name, const std::string& model_link_name); + + // help method + virtual std::vector help(const std::string& functionName = "--all"); + + // read from ConnectionReader + bool read(yarp::os::ConnectionReader& connection) override; }; -#endif +} // namespace GazeboYarpPlugins + +#endif // YARP_THRIFT_GENERATOR_SERVICE_LINKATTACHERSERVER_H diff --git a/thrift/linkattacher/autogenerated/linkattacher_rpc_thrift.cmake b/thrift/linkattacher/autogenerated/linkattacher_rpc_thrift.cmake index 719169e0f..94d31abdb 100644 --- a/thrift/linkattacher/autogenerated/linkattacher_rpc_thrift.cmake +++ b/thrift/linkattacher/autogenerated/linkattacher_rpc_thrift.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT) +# Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT) # All rights reserved. # # This software may be modified and distributed under the terms of the diff --git a/thrift/linkattacher/autogenerated/src/LinkAttacherServer.cpp b/thrift/linkattacher/autogenerated/src/LinkAttacherServer.cpp index 2b612c78e..2e2ff4605 100644 --- a/thrift/linkattacher/autogenerated/src/LinkAttacherServer.cpp +++ b/thrift/linkattacher/autogenerated/src/LinkAttacherServer.cpp @@ -1,320 +1,413 @@ /* - * Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT) + * Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT) * All rights reserved. * * This software may be modified and distributed under the terms of the * BSD-3-Clause license. See the accompanying LICENSE file for details. */ +// Autogenerated by Thrift Compiler (0.12.0-yarped) +// // This is an automatically generated file. // It could get re-generated if the ALLOW_IDL_GENERATION flag is on. #include + #include namespace GazeboYarpPlugins { - -class LinkAttacherServer_enableGravity : public yarp::os::Portable { +class LinkAttacherServer_enableGravity : + public yarp::os::Portable +{ public: - std::string model_name; - bool enable; - bool _return; - void init(const std::string& model_name, const bool enable); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; + std::string model_name; + bool enable; + bool _return; + void init(const std::string& model_name, const bool enable); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; }; -class LinkAttacherServer_attachUnscoped : public yarp::os::Portable { -public: - std::string model_name; - std::string model_link_name; - std::string robot_name; - std::string robot_link_name; - bool _return; - void init(const std::string& model_name, const std::string& model_link_name, const std::string& robot_name, const std::string& robot_link_name); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; -}; - -class LinkAttacherServer_detachUnscoped : public yarp::os::Portable { -public: - std::string model_name; - std::string model_link_name; - bool _return; - void init(const std::string& model_name, const std::string& model_link_name); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; -}; - -bool LinkAttacherServer_enableGravity::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(3)) return false; - if (!writer.writeTag("enableGravity",1,1)) return false; - if (!writer.writeString(model_name)) return false; - if (!writer.writeBool(enable)) return false; - return true; -} - -bool LinkAttacherServer_enableGravity::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - if (!reader.readBool(_return)) { - reader.fail(); - return false; - } - return true; -} - -void LinkAttacherServer_enableGravity::init(const std::string& model_name, const bool enable) { - _return = false; - this->model_name = model_name; - this->enable = enable; +bool LinkAttacherServer_enableGravity::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(3)) { + return false; + } + if (!writer.writeTag("enableGravity", 1, 1)) { + return false; + } + if (!writer.writeString(model_name)) { + return false; + } + if (!writer.writeBool(enable)) { + return false; + } + return true; } -bool LinkAttacherServer_attachUnscoped::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(5)) return false; - if (!writer.writeTag("attachUnscoped",1,1)) return false; - if (!writer.writeString(model_name)) return false; - if (!writer.writeString(model_link_name)) return false; - if (!writer.writeString(robot_name)) return false; - if (!writer.writeString(robot_link_name)) return false; - return true; +bool LinkAttacherServer_enableGravity::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { + return false; + } + if (!reader.readBool(_return)) { + reader.fail(); + return false; + } + return true; } -bool LinkAttacherServer_attachUnscoped::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - if (!reader.readBool(_return)) { - reader.fail(); - return false; - } - return true; +void LinkAttacherServer_enableGravity::init(const std::string& model_name, const bool enable) +{ + _return = false; + this->model_name = model_name; + this->enable = enable; } -void LinkAttacherServer_attachUnscoped::init(const std::string& model_name, const std::string& model_link_name, const std::string& robot_name, const std::string& robot_link_name) { - _return = false; - this->model_name = model_name; - this->model_link_name = model_link_name; - this->robot_name = robot_name; - this->robot_link_name = robot_link_name; -} +class LinkAttacherServer_attachUnscoped : + public yarp::os::Portable +{ +public: + std::string model_name; + std::string model_link_name; + std::string robot_name; + std::string robot_link_name; + bool _return; + void init(const std::string& model_name, const std::string& model_link_name, const std::string& robot_name, const std::string& robot_link_name); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; +}; -bool LinkAttacherServer_detachUnscoped::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(3)) return false; - if (!writer.writeTag("detachUnscoped",1,1)) return false; - if (!writer.writeString(model_name)) return false; - if (!writer.writeString(model_link_name)) return false; - return true; +bool LinkAttacherServer_attachUnscoped::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(5)) { + return false; + } + if (!writer.writeTag("attachUnscoped", 1, 1)) { + return false; + } + if (!writer.writeString(model_name)) { + return false; + } + if (!writer.writeString(model_link_name)) { + return false; + } + if (!writer.writeString(robot_name)) { + return false; + } + if (!writer.writeString(robot_link_name)) { + return false; + } + return true; } -bool LinkAttacherServer_detachUnscoped::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - if (!reader.readBool(_return)) { - reader.fail(); - return false; - } - return true; +bool LinkAttacherServer_attachUnscoped::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { + return false; + } + if (!reader.readBool(_return)) { + reader.fail(); + return false; + } + return true; } -void LinkAttacherServer_detachUnscoped::init(const std::string& model_name, const std::string& model_link_name) { - _return = false; - this->model_name = model_name; - this->model_link_name = model_link_name; +void LinkAttacherServer_attachUnscoped::init(const std::string& model_name, const std::string& model_link_name, const std::string& robot_name, const std::string& robot_link_name) +{ + _return = false; + this->model_name = model_name; + this->model_link_name = model_link_name; + this->robot_name = robot_name; + this->robot_link_name = robot_link_name; } -LinkAttacherServer::LinkAttacherServer() { - yarp().setOwner(*this); -} -bool LinkAttacherServer::enableGravity(const std::string& model_name, const bool enable) { - bool _return = false; - LinkAttacherServer_enableGravity helper; - helper.init(model_name,enable); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","bool LinkAttacherServer::enableGravity(const std::string& model_name, const bool enable)"); - } - bool ok = yarp().write(helper,helper); - return ok?helper._return:_return; -} -bool LinkAttacherServer::attachUnscoped(const std::string& model_name, const std::string& model_link_name, const std::string& robot_name, const std::string& robot_link_name) { - bool _return = false; - LinkAttacherServer_attachUnscoped helper; - helper.init(model_name,model_link_name,robot_name,robot_link_name); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","bool LinkAttacherServer::attachUnscoped(const std::string& model_name, const std::string& model_link_name, const std::string& robot_name, const std::string& robot_link_name)"); - } - bool ok = yarp().write(helper,helper); - return ok?helper._return:_return; -} -bool LinkAttacherServer::detachUnscoped(const std::string& model_name, const std::string& model_link_name) { - bool _return = false; - LinkAttacherServer_detachUnscoped helper; - helper.init(model_name,model_link_name); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","bool LinkAttacherServer::detachUnscoped(const std::string& model_name, const std::string& model_link_name)"); - } - bool ok = yarp().write(helper,helper); - return ok?helper._return:_return; -} +class LinkAttacherServer_detachUnscoped : + public yarp::os::Portable +{ +public: + std::string model_name; + std::string model_link_name; + bool _return; + void init(const std::string& model_name, const std::string& model_link_name); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; +}; -bool LinkAttacherServer::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - reader.expectAccept(); - if (!reader.readListHeader()) { reader.fail(); return false; } - std::string tag = reader.readTag(); - bool direct = (tag=="__direct__"); - if (direct) tag = reader.readTag(); - while (!reader.isError()) { - // TODO: use quick lookup, this is just a test - if (tag == "enableGravity") { - std::string model_name; - bool enable; - if (!reader.readString(model_name)) { - reader.fail(); +bool LinkAttacherServer_detachUnscoped::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(3)) { return false; - } - if (!reader.readBool(enable)) { - reader.fail(); - return false; - } - bool _return; - _return = enableGravity(model_name,enable); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeBool(_return)) return false; - } - reader.accept(); - return true; } - if (tag == "attachUnscoped") { - std::string model_name; - std::string model_link_name; - std::string robot_name; - std::string robot_link_name; - if (!reader.readString(model_name)) { - reader.fail(); + if (!writer.writeTag("detachUnscoped", 1, 1)) { return false; - } - if (!reader.readString(model_link_name)) { - reader.fail(); - return false; - } - if (!reader.readString(robot_name)) { - reader.fail(); + } + if (!writer.writeString(model_name)) { return false; - } - if (!reader.readString(robot_link_name)) { - reader.fail(); + } + if (!writer.writeString(model_link_name)) { return false; - } - bool _return; - _return = attachUnscoped(model_name,model_link_name,robot_name,robot_link_name); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeBool(_return)) return false; - } - reader.accept(); - return true; } - if (tag == "detachUnscoped") { - std::string model_name; - std::string model_link_name; - if (!reader.readString(model_name)) { - reader.fail(); + return true; +} + +bool LinkAttacherServer_detachUnscoped::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { return false; - } - if (!reader.readString(model_link_name)) { + } + if (!reader.readBool(_return)) { reader.fail(); return false; - } - bool _return; - _return = detachUnscoped(model_name,model_link_name); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeBool(_return)) return false; - } - reader.accept(); - return true; } - if (tag == "help") { - std::string functionName; - if (!reader.readString(functionName)) { - functionName = "--all"; - } - std::vector _return=help(functionName); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(2)) return false; - if (!writer.writeTag("many",1, 0)) return false; - if (!writer.writeListBegin(BOTTLE_TAG_INT32, static_cast(_return.size()))) return false; - std::vector ::iterator _iterHelp; - for (_iterHelp = _return.begin(); _iterHelp != _return.end(); ++_iterHelp) - { - if (!writer.writeString(*_iterHelp)) return false; - } - if (!writer.writeListEnd()) return false; - } - reader.accept(); - return true; + return true; +} + +void LinkAttacherServer_detachUnscoped::init(const std::string& model_name, const std::string& model_link_name) +{ + _return = false; + this->model_name = model_name; + this->model_link_name = model_link_name; +} + +// Constructor +LinkAttacherServer::LinkAttacherServer() +{ + yarp().setOwner(*this); +} + +bool LinkAttacherServer::enableGravity(const std::string& model_name, const bool enable) +{ + bool _return = false; + LinkAttacherServer_enableGravity helper; + helper.init(model_name,enable); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "bool LinkAttacherServer::enableGravity(const std::string& model_name, const bool enable)"); } - if (reader.noMore()) { reader.fail(); return false; } - std::string next_tag = reader.readTag(); - if (next_tag=="") break; - tag = tag + "_" + next_tag; - } - return false; + bool ok = yarp().write(helper, helper); + return ok ? helper._return : _return; } -std::vector LinkAttacherServer::help(const std::string& functionName) { - bool showAll=(functionName=="--all"); - std::vector helpString; - if(showAll) { - helpString.push_back("*** Available commands:"); - helpString.push_back("enableGravity"); - helpString.push_back("attachUnscoped"); - helpString.push_back("detachUnscoped"); - helpString.push_back("help"); - } - else { - if (functionName=="enableGravity") { - helpString.push_back("bool enableGravity(const std::string& model_name, const bool enable) "); - helpString.push_back("Enable/disables gravity for a model "); - helpString.push_back("@param model_name name that identifies model in gazebo (that are already spawned in gazebo) "); - helpString.push_back("@param enable 1 to enable gravity, 0 otherwise "); - helpString.push_back("@return returns true or false on success failure "); +bool LinkAttacherServer::attachUnscoped(const std::string& model_name, const std::string& model_link_name, const std::string& robot_name, const std::string& robot_link_name) +{ + bool _return = false; + LinkAttacherServer_attachUnscoped helper; + helper.init(model_name,model_link_name,robot_name,robot_link_name); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "bool LinkAttacherServer::attachUnscoped(const std::string& model_name, const std::string& model_link_name, const std::string& robot_name, const std::string& robot_link_name)"); } - if (functionName=="attachUnscoped") { - helpString.push_back("bool attachUnscoped(const std::string& model_name, const std::string& model_link_name, const std::string& robot_name, const std::string& robot_link_name) "); - helpString.push_back("Attach any link of the models spawned in gazebo to a link of the robot. "); - helpString.push_back("@param model_name name that identifies model in gazebo (that are already spawned in gazebo) "); - helpString.push_back("@param model_link_name name of a the link in the model you want to attach to the robot "); - helpString.push_back("@param robot_name name of the robot "); - helpString.push_back("@param robot_link_name name of the robot link to which you want to attached the model link "); - helpString.push_back("@return true if success, false otherwise "); + bool ok = yarp().write(helper, helper); + return ok ? helper._return : _return; +} + +bool LinkAttacherServer::detachUnscoped(const std::string& model_name, const std::string& model_link_name) +{ + bool _return = false; + LinkAttacherServer_detachUnscoped helper; + helper.init(model_name,model_link_name); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "bool LinkAttacherServer::detachUnscoped(const std::string& model_name, const std::string& model_link_name)"); } - if (functionName=="detachUnscoped") { - helpString.push_back("bool detachUnscoped(const std::string& model_name, const std::string& model_link_name) "); - helpString.push_back("Detach a previously attached model link. "); - helpString.push_back("@param model_name name that identifies model in gazebo (that are already spawned in gazebo) "); - helpString.push_back("@param model_link_name name of a the link in the model that is attached to the robot "); - helpString.push_back("@return true if success, false otherwise "); + bool ok = yarp().write(helper, helper); + return ok ? helper._return : _return; +} + +// help method +std::vector LinkAttacherServer::help(const std::string& functionName) +{ + bool showAll = (functionName == "--all"); + std::vector helpString; + if (showAll) { + helpString.emplace_back("*** Available commands:"); + helpString.emplace_back("enableGravity"); + helpString.emplace_back("attachUnscoped"); + helpString.emplace_back("detachUnscoped"); + helpString.emplace_back("help"); + } else { + if (functionName == "enableGravity") { + helpString.emplace_back("bool enableGravity(const std::string& model_name, const bool enable) "); + helpString.emplace_back("Enable/disables gravity for a model "); + helpString.emplace_back("@param model_name name that identifies model in gazebo (that are already spawned in gazebo) "); + helpString.emplace_back("@param enable 1 to enable gravity, 0 otherwise "); + helpString.emplace_back("@return returns true or false on success failure "); + } + if (functionName == "attachUnscoped") { + helpString.emplace_back("bool attachUnscoped(const std::string& model_name, const std::string& model_link_name, const std::string& robot_name, const std::string& robot_link_name) "); + helpString.emplace_back("Attach any link of the models spawned in gazebo to a link of the robot using a fixed joint. "); + helpString.emplace_back("@param model_name name that identifies model in gazebo (that are already spawned in gazebo) "); + helpString.emplace_back("@param model_link_name name of a the link in the model you want to attach to the robot "); + helpString.emplace_back("@param robot_name name of the robot "); + helpString.emplace_back("@param robot_link_name name of the robot link to which you want to attached the model link "); + helpString.emplace_back("@return true if success, false otherwise "); + } + if (functionName == "detachUnscoped") { + helpString.emplace_back("bool detachUnscoped(const std::string& model_name, const std::string& model_link_name) "); + helpString.emplace_back("Detach the model link which was previously attached to the robot link through a fixed joint. "); + helpString.emplace_back("@param model_name name that identifies model in gazebo (that are already spawned in gazebo) "); + helpString.emplace_back("@param model_link_name name of a the link in the model that is attached to the robot "); + helpString.emplace_back("@return true if success, false otherwise "); + } + if (functionName == "help") { + helpString.emplace_back("std::vector help(const std::string& functionName = \"--all\")"); + helpString.emplace_back("Return list of available commands, or help message for a specific function"); + helpString.emplace_back("@param functionName name of command for which to get a detailed description. If none or '--all' is provided, print list of available commands"); + helpString.emplace_back("@return list of strings (one string per line)"); + } } - if (functionName=="help") { - helpString.push_back("std::vector help(const std::string& functionName=\"--all\")"); - helpString.push_back("Return list of available commands, or help message for a specific function"); - helpString.push_back("@param functionName name of command for which to get a detailed description. If none or '--all' is provided, print list of available commands"); - helpString.push_back("@return list of strings (one string per line)"); + if (helpString.empty()) { + helpString.emplace_back("Command not found"); } - } - if ( helpString.empty()) helpString.push_back("Command not found"); - return helpString; + return helpString; } -} // namespace +// read from ConnectionReader +bool LinkAttacherServer::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + reader.expectAccept(); + if (!reader.readListHeader()) { + reader.fail(); + return false; + } + + std::string tag = reader.readTag(); + bool direct = (tag == "__direct__"); + if (direct) { + tag = reader.readTag(); + } + while (!reader.isError()) { + if (tag == "enableGravity") { + std::string model_name; + bool enable; + if (!reader.readString(model_name)) { + reader.fail(); + return false; + } + if (!reader.readBool(enable)) { + reader.fail(); + return false; + } + bool _return; + _return = enableGravity(model_name,enable); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeBool(_return)) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "attachUnscoped") { + std::string model_name; + std::string model_link_name; + std::string robot_name; + std::string robot_link_name; + if (!reader.readString(model_name)) { + reader.fail(); + return false; + } + if (!reader.readString(model_link_name)) { + reader.fail(); + return false; + } + if (!reader.readString(robot_name)) { + reader.fail(); + return false; + } + if (!reader.readString(robot_link_name)) { + reader.fail(); + return false; + } + bool _return; + _return = attachUnscoped(model_name,model_link_name,robot_name,robot_link_name); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeBool(_return)) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "detachUnscoped") { + std::string model_name; + std::string model_link_name; + if (!reader.readString(model_name)) { + reader.fail(); + return false; + } + if (!reader.readString(model_link_name)) { + reader.fail(); + return false; + } + bool _return; + _return = detachUnscoped(model_name,model_link_name); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeBool(_return)) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "help") { + std::string functionName; + if (!reader.readString(functionName)) { + functionName = "--all"; + } + auto _return = help(functionName); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(2)) { + return false; + } + if (!writer.writeTag("many", 1, 0)) { + return false; + } + if (!writer.writeListBegin(BOTTLE_TAG_INT32, static_cast(_return.size()))) { + return false; + } + for (const auto& _ret : _return) { + if (!writer.writeString(_ret)) { + return false; + } + } + if (!writer.writeListEnd()) { + return false; + } + } + reader.accept(); + return true; + } + if (reader.noMore()) { + reader.fail(); + return false; + } + std::string next_tag = reader.readTag(); + if (next_tag == "") { + break; + } + tag.append("_").append(next_tag); + } + return false; +} +} // namespace GazeboYarpPlugins diff --git a/thrift/worldinterface/autogenerated/include/Color.h b/thrift/worldinterface/autogenerated/include/Color.h index 89bd89452..3064d7f14 100644 --- a/thrift/worldinterface/autogenerated/include/Color.h +++ b/thrift/worldinterface/autogenerated/include/Color.h @@ -1,213 +1,185 @@ /* - * Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT) + * Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT) * All rights reserved. * * This software may be modified and distributed under the terms of the * BSD-3-Clause license. See the accompanying LICENSE file for details. */ +// Autogenerated by Thrift Compiler (0.12.0-yarped) +// // This is an automatically generated file. // It could get re-generated if the ALLOW_IDL_GENERATION flag is on. -#ifndef YARP_THRIFT_GENERATOR_STRUCT_Color -#define YARP_THRIFT_GENERATOR_STRUCT_Color +#ifndef YARP_THRIFT_GENERATOR_STRUCT_COLOR_H +#define YARP_THRIFT_GENERATOR_STRUCT_COLOR_H #include #include namespace GazeboYarpPlugins { - class Color; -} - -class GazeboYarpPlugins::Color : public yarp::os::idl::WirePortable { +class Color : + public yarp::os::idl::WirePortable +{ public: - // Fields - std::int16_t r; - std::int16_t g; - std::int16_t b; - - // Default constructor - Color() : r(0), g(0), b(0) { - } - - // Constructor with field values - Color(const std::int16_t r,const std::int16_t g,const std::int16_t b) : r(r), g(g), b(b) { - } - - // Copy constructor - Color(const Color& __alt) : WirePortable(__alt) { - this->r = __alt.r; - this->g = __alt.g; - this->b = __alt.b; - } - - // Assignment operator - const Color& operator = (const Color& __alt) { - this->r = __alt.r; - this->g = __alt.g; - this->b = __alt.b; - return *this; - } - - // read and write structure on a connection - bool read(yarp::os::idl::WireReader& reader) override; - bool read(yarp::os::ConnectionReader& connection) override; - bool write(const yarp::os::idl::WireWriter& writer) const override; - bool write(yarp::os::ConnectionWriter& connection) const override; + // Fields + std::int16_t r; + std::int16_t g; + std::int16_t b; -private: - bool write_r(const yarp::os::idl::WireWriter& writer) const; - bool nested_write_r(const yarp::os::idl::WireWriter& writer) const; - bool write_g(const yarp::os::idl::WireWriter& writer) const; - bool nested_write_g(const yarp::os::idl::WireWriter& writer) const; - bool write_b(const yarp::os::idl::WireWriter& writer) const; - bool nested_write_b(const yarp::os::idl::WireWriter& writer) const; - bool read_r(yarp::os::idl::WireReader& reader); - bool nested_read_r(yarp::os::idl::WireReader& reader); - bool read_g(yarp::os::idl::WireReader& reader); - bool nested_read_g(yarp::os::idl::WireReader& reader); - bool read_b(yarp::os::idl::WireReader& reader); - bool nested_read_b(yarp::os::idl::WireReader& reader); + // Default constructor + Color(); -public: + // Constructor with field values + Color(const std::int16_t r, + const std::int16_t g, + const std::int16_t b); - std::string toString() const; - - // if you want to serialize this class without nesting, use this helper - typedef yarp::os::idl::Unwrapped unwrapped; - - class Editor : public yarp::os::Wire, public yarp::os::PortWriter { - public: - - Editor() { - group = 0; - obj_owned = true; - obj = new Color; - dirty_flags(false); - yarp().setOwner(*this); - } - - Editor(Color& obj) { - group = 0; - obj_owned = false; - edit(obj,false); - yarp().setOwner(*this); - } - - bool edit(Color& obj, bool dirty = true) { - if (obj_owned) delete this->obj; - this->obj = &obj; - obj_owned = false; - dirty_flags(dirty); - return true; - } - - virtual ~Editor() { - if (obj_owned) delete obj; - } - - bool isValid() const { - return obj!=0/*NULL*/; - } - - Color& state() { return *obj; } - - void begin() { group++; } - - void end() { - group--; - if (group==0&&is_dirty) communicate(); - } - void set_r(const std::int16_t r) { - will_set_r(); - obj->r = r; - mark_dirty_r(); - communicate(); - did_set_r(); - } - void set_g(const std::int16_t g) { - will_set_g(); - obj->g = g; - mark_dirty_g(); - communicate(); - did_set_g(); - } - void set_b(const std::int16_t b) { - will_set_b(); - obj->b = b; - mark_dirty_b(); - communicate(); - did_set_b(); - } - std::int16_t get_r() { - return obj->r; - } - std::int16_t get_g() { - return obj->g; - } - std::int16_t get_b() { - return obj->b; - } - virtual bool will_set_r() { return true; } - virtual bool will_set_g() { return true; } - virtual bool will_set_b() { return true; } - virtual bool did_set_r() { return true; } - virtual bool did_set_g() { return true; } - virtual bool did_set_b() { return true; } - void clean() { - dirty_flags(false); - } + // Read structure on a Wire + bool read(yarp::os::idl::WireReader& reader) override; + + // Read structure on a Connection bool read(yarp::os::ConnectionReader& connection) override; + + // Write structure on a Wire + bool write(const yarp::os::idl::WireWriter& writer) const override; + + // Write structure on a Connection bool write(yarp::os::ConnectionWriter& connection) const override; - private: - - Color *obj; - - bool obj_owned; - int group; - - void communicate() { - if (group!=0) return; - if (yarp().canWrite()) { - yarp().write(*this); - clean(); - } - } - void mark_dirty() { - is_dirty = true; - } - void mark_dirty_r() { - if (is_dirty_r) return; - dirty_count++; - is_dirty_r = true; - mark_dirty(); - } - void mark_dirty_g() { - if (is_dirty_g) return; - dirty_count++; - is_dirty_g = true; - mark_dirty(); - } - void mark_dirty_b() { - if (is_dirty_b) return; - dirty_count++; - is_dirty_b = true; - mark_dirty(); - } - void dirty_flags(bool flag) { - is_dirty = flag; - is_dirty_r = flag; - is_dirty_g = flag; - is_dirty_b = flag; - dirty_count = flag ? 3 : 0; - } - bool is_dirty; - int dirty_count; - bool is_dirty_r; - bool is_dirty_g; - bool is_dirty_b; - }; + + // Convert to a printable string + std::string toString() const; + + // If you want to serialize this class without nesting, use this helper + typedef yarp::os::idl::Unwrapped unwrapped; + + class Editor : + public yarp::os::Wire, + public yarp::os::PortWriter + { + public: + // Editor: default constructor + Editor(); + + // Editor: constructor with base class + Editor(Color& obj); + + // Editor: destructor + ~Editor() override; + + // Editor: Deleted constructors and operator= + Editor(const Editor& rhs) = delete; + Editor(Editor&& rhs) = delete; + Editor& operator=(const Editor& rhs) = delete; + Editor& operator=(Editor&& rhs) = delete; + + // Editor: edit + bool edit(Color& obj, bool dirty = true); + + // Editor: validity check + bool isValid() const; + + // Editor: state + Color& state(); + + // Editor: start editing + void start_editing(); + +#ifndef YARP_NO_DEPRECATED // Since YARP 3.2 + YARP_DEPRECATED_MSG("Use start_editing() instead") + void begin() + { + start_editing(); + } +#endif // YARP_NO_DEPRECATED + + // Editor: stop editing + void stop_editing(); + +#ifndef YARP_NO_DEPRECATED // Since YARP 3.2 + YARP_DEPRECATED_MSG("Use stop_editing() instead") + void end() + { + stop_editing(); + } +#endif // YARP_NO_DEPRECATED + + // Editor: r field + void set_r(const std::int16_t r); + std::int16_t get_r() const; + virtual bool will_set_r(); + virtual bool did_set_r(); + + // Editor: g field + void set_g(const std::int16_t g); + std::int16_t get_g() const; + virtual bool will_set_g(); + virtual bool did_set_g(); + + // Editor: b field + void set_b(const std::int16_t b); + std::int16_t get_b() const; + virtual bool will_set_b(); + virtual bool did_set_b(); + + // Editor: clean + void clean(); + + // Editor: read + bool read(yarp::os::ConnectionReader& connection) override; + + // Editor: write + bool write(yarp::os::ConnectionWriter& connection) const override; + + private: + // Editor: state + Color* obj; + bool obj_owned; + int group; + + // Editor: dirty variables + bool is_dirty; + bool is_dirty_r; + bool is_dirty_g; + bool is_dirty_b; + int dirty_count; + + // Editor: send if possible + void communicate(); + + // Editor: mark dirty overall + void mark_dirty(); + + // Editor: mark dirty single fields + void mark_dirty_r(); + void mark_dirty_g(); + void mark_dirty_b(); + + // Editor: dirty_flags + void dirty_flags(bool flag); + }; + +private: + // read/write r field + bool read_r(yarp::os::idl::WireReader& reader); + bool write_r(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_r(yarp::os::idl::WireReader& reader); + bool nested_write_r(const yarp::os::idl::WireWriter& writer) const; + + // read/write g field + bool read_g(yarp::os::idl::WireReader& reader); + bool write_g(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_g(yarp::os::idl::WireReader& reader); + bool nested_write_g(const yarp::os::idl::WireWriter& writer) const; + + // read/write b field + bool read_b(yarp::os::idl::WireReader& reader); + bool write_b(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_b(yarp::os::idl::WireReader& reader); + bool nested_write_b(const yarp::os::idl::WireWriter& writer) const; }; -#endif +} // namespace GazeboYarpPlugins + +#endif // YARP_THRIFT_GENERATOR_STRUCT_COLOR_H diff --git a/thrift/worldinterface/autogenerated/include/Pose.h b/thrift/worldinterface/autogenerated/include/Pose.h index f9bb1abfe..fb7cdc65b 100644 --- a/thrift/worldinterface/autogenerated/include/Pose.h +++ b/thrift/worldinterface/autogenerated/include/Pose.h @@ -1,294 +1,233 @@ /* - * Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT) + * Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT) * All rights reserved. * * This software may be modified and distributed under the terms of the * BSD-3-Clause license. See the accompanying LICENSE file for details. */ +// Autogenerated by Thrift Compiler (0.12.0-yarped) +// // This is an automatically generated file. // It could get re-generated if the ALLOW_IDL_GENERATION flag is on. -#ifndef YARP_THRIFT_GENERATOR_STRUCT_Pose -#define YARP_THRIFT_GENERATOR_STRUCT_Pose +#ifndef YARP_THRIFT_GENERATOR_STRUCT_POSE_H +#define YARP_THRIFT_GENERATOR_STRUCT_POSE_H #include #include namespace GazeboYarpPlugins { - class Pose; -} - -class GazeboYarpPlugins::Pose : public yarp::os::idl::WirePortable { +class Pose : + public yarp::os::idl::WirePortable +{ public: - // Fields - double x; - double y; - double z; - double roll; - double pitch; - double yaw; - - // Default constructor - Pose() : x(0), y(0), z(0), roll(0), pitch(0), yaw(0) { - } - - // Constructor with field values - Pose(const double x,const double y,const double z,const double roll,const double pitch,const double yaw) : x(x), y(y), z(z), roll(roll), pitch(pitch), yaw(yaw) { - } - - // Copy constructor - Pose(const Pose& __alt) : WirePortable(__alt) { - this->x = __alt.x; - this->y = __alt.y; - this->z = __alt.z; - this->roll = __alt.roll; - this->pitch = __alt.pitch; - this->yaw = __alt.yaw; - } - - // Assignment operator - const Pose& operator = (const Pose& __alt) { - this->x = __alt.x; - this->y = __alt.y; - this->z = __alt.z; - this->roll = __alt.roll; - this->pitch = __alt.pitch; - this->yaw = __alt.yaw; - return *this; - } - - // read and write structure on a connection - bool read(yarp::os::idl::WireReader& reader) override; - bool read(yarp::os::ConnectionReader& connection) override; - bool write(const yarp::os::idl::WireWriter& writer) const override; - bool write(yarp::os::ConnectionWriter& connection) const override; - -private: - bool write_x(const yarp::os::idl::WireWriter& writer) const; - bool nested_write_x(const yarp::os::idl::WireWriter& writer) const; - bool write_y(const yarp::os::idl::WireWriter& writer) const; - bool nested_write_y(const yarp::os::idl::WireWriter& writer) const; - bool write_z(const yarp::os::idl::WireWriter& writer) const; - bool nested_write_z(const yarp::os::idl::WireWriter& writer) const; - bool write_roll(const yarp::os::idl::WireWriter& writer) const; - bool nested_write_roll(const yarp::os::idl::WireWriter& writer) const; - bool write_pitch(const yarp::os::idl::WireWriter& writer) const; - bool nested_write_pitch(const yarp::os::idl::WireWriter& writer) const; - bool write_yaw(const yarp::os::idl::WireWriter& writer) const; - bool nested_write_yaw(const yarp::os::idl::WireWriter& writer) const; - bool read_x(yarp::os::idl::WireReader& reader); - bool nested_read_x(yarp::os::idl::WireReader& reader); - bool read_y(yarp::os::idl::WireReader& reader); - bool nested_read_y(yarp::os::idl::WireReader& reader); - bool read_z(yarp::os::idl::WireReader& reader); - bool nested_read_z(yarp::os::idl::WireReader& reader); - bool read_roll(yarp::os::idl::WireReader& reader); - bool nested_read_roll(yarp::os::idl::WireReader& reader); - bool read_pitch(yarp::os::idl::WireReader& reader); - bool nested_read_pitch(yarp::os::idl::WireReader& reader); - bool read_yaw(yarp::os::idl::WireReader& reader); - bool nested_read_yaw(yarp::os::idl::WireReader& reader); + // Fields + double x; + double y; + double z; + double roll; + double pitch; + double yaw; + + // Default constructor + Pose(); + + // Constructor with field values + Pose(const double x, + const double y, + const double z, + const double roll, + const double pitch, + const double yaw); + + // Read structure on a Wire + bool read(yarp::os::idl::WireReader& reader) override; + + // Read structure on a Connection + bool read(yarp::os::ConnectionReader& connection) override; -public: + // Write structure on a Wire + bool write(const yarp::os::idl::WireWriter& writer) const override; - std::string toString() const; - - // if you want to serialize this class without nesting, use this helper - typedef yarp::os::idl::Unwrapped unwrapped; - - class Editor : public yarp::os::Wire, public yarp::os::PortWriter { - public: - - Editor() { - group = 0; - obj_owned = true; - obj = new Pose; - dirty_flags(false); - yarp().setOwner(*this); - } - - Editor(Pose& obj) { - group = 0; - obj_owned = false; - edit(obj,false); - yarp().setOwner(*this); - } - - bool edit(Pose& obj, bool dirty = true) { - if (obj_owned) delete this->obj; - this->obj = &obj; - obj_owned = false; - dirty_flags(dirty); - return true; - } - - virtual ~Editor() { - if (obj_owned) delete obj; - } - - bool isValid() const { - return obj!=0/*NULL*/; - } - - Pose& state() { return *obj; } - - void begin() { group++; } - - void end() { - group--; - if (group==0&&is_dirty) communicate(); - } - void set_x(const double x) { - will_set_x(); - obj->x = x; - mark_dirty_x(); - communicate(); - did_set_x(); - } - void set_y(const double y) { - will_set_y(); - obj->y = y; - mark_dirty_y(); - communicate(); - did_set_y(); - } - void set_z(const double z) { - will_set_z(); - obj->z = z; - mark_dirty_z(); - communicate(); - did_set_z(); - } - void set_roll(const double roll) { - will_set_roll(); - obj->roll = roll; - mark_dirty_roll(); - communicate(); - did_set_roll(); - } - void set_pitch(const double pitch) { - will_set_pitch(); - obj->pitch = pitch; - mark_dirty_pitch(); - communicate(); - did_set_pitch(); - } - void set_yaw(const double yaw) { - will_set_yaw(); - obj->yaw = yaw; - mark_dirty_yaw(); - communicate(); - did_set_yaw(); - } - double get_x() { - return obj->x; - } - double get_y() { - return obj->y; - } - double get_z() { - return obj->z; - } - double get_roll() { - return obj->roll; - } - double get_pitch() { - return obj->pitch; - } - double get_yaw() { - return obj->yaw; - } - virtual bool will_set_x() { return true; } - virtual bool will_set_y() { return true; } - virtual bool will_set_z() { return true; } - virtual bool will_set_roll() { return true; } - virtual bool will_set_pitch() { return true; } - virtual bool will_set_yaw() { return true; } - virtual bool did_set_x() { return true; } - virtual bool did_set_y() { return true; } - virtual bool did_set_z() { return true; } - virtual bool did_set_roll() { return true; } - virtual bool did_set_pitch() { return true; } - virtual bool did_set_yaw() { return true; } - void clean() { - dirty_flags(false); - } - bool read(yarp::os::ConnectionReader& connection) override; + // Write structure on a Connection bool write(yarp::os::ConnectionWriter& connection) const override; - private: - - Pose *obj; - - bool obj_owned; - int group; - - void communicate() { - if (group!=0) return; - if (yarp().canWrite()) { - yarp().write(*this); - clean(); - } - } - void mark_dirty() { - is_dirty = true; - } - void mark_dirty_x() { - if (is_dirty_x) return; - dirty_count++; - is_dirty_x = true; - mark_dirty(); - } - void mark_dirty_y() { - if (is_dirty_y) return; - dirty_count++; - is_dirty_y = true; - mark_dirty(); - } - void mark_dirty_z() { - if (is_dirty_z) return; - dirty_count++; - is_dirty_z = true; - mark_dirty(); - } - void mark_dirty_roll() { - if (is_dirty_roll) return; - dirty_count++; - is_dirty_roll = true; - mark_dirty(); - } - void mark_dirty_pitch() { - if (is_dirty_pitch) return; - dirty_count++; - is_dirty_pitch = true; - mark_dirty(); - } - void mark_dirty_yaw() { - if (is_dirty_yaw) return; - dirty_count++; - is_dirty_yaw = true; - mark_dirty(); - } - void dirty_flags(bool flag) { - is_dirty = flag; - is_dirty_x = flag; - is_dirty_y = flag; - is_dirty_z = flag; - is_dirty_roll = flag; - is_dirty_pitch = flag; - is_dirty_yaw = flag; - dirty_count = flag ? 6 : 0; - } - bool is_dirty; - int dirty_count; - bool is_dirty_x; - bool is_dirty_y; - bool is_dirty_z; - bool is_dirty_roll; - bool is_dirty_pitch; - bool is_dirty_yaw; - }; + + // Convert to a printable string + std::string toString() const; + + // If you want to serialize this class without nesting, use this helper + typedef yarp::os::idl::Unwrapped unwrapped; + + class Editor : + public yarp::os::Wire, + public yarp::os::PortWriter + { + public: + // Editor: default constructor + Editor(); + + // Editor: constructor with base class + Editor(Pose& obj); + + // Editor: destructor + ~Editor() override; + + // Editor: Deleted constructors and operator= + Editor(const Editor& rhs) = delete; + Editor(Editor&& rhs) = delete; + Editor& operator=(const Editor& rhs) = delete; + Editor& operator=(Editor&& rhs) = delete; + + // Editor: edit + bool edit(Pose& obj, bool dirty = true); + + // Editor: validity check + bool isValid() const; + + // Editor: state + Pose& state(); + + // Editor: start editing + void start_editing(); + +#ifndef YARP_NO_DEPRECATED // Since YARP 3.2 + YARP_DEPRECATED_MSG("Use start_editing() instead") + void begin() + { + start_editing(); + } +#endif // YARP_NO_DEPRECATED + + // Editor: stop editing + void stop_editing(); + +#ifndef YARP_NO_DEPRECATED // Since YARP 3.2 + YARP_DEPRECATED_MSG("Use stop_editing() instead") + void end() + { + stop_editing(); + } +#endif // YARP_NO_DEPRECATED + + // Editor: x field + void set_x(const double x); + double get_x() const; + virtual bool will_set_x(); + virtual bool did_set_x(); + + // Editor: y field + void set_y(const double y); + double get_y() const; + virtual bool will_set_y(); + virtual bool did_set_y(); + + // Editor: z field + void set_z(const double z); + double get_z() const; + virtual bool will_set_z(); + virtual bool did_set_z(); + + // Editor: roll field + void set_roll(const double roll); + double get_roll() const; + virtual bool will_set_roll(); + virtual bool did_set_roll(); + + // Editor: pitch field + void set_pitch(const double pitch); + double get_pitch() const; + virtual bool will_set_pitch(); + virtual bool did_set_pitch(); + + // Editor: yaw field + void set_yaw(const double yaw); + double get_yaw() const; + virtual bool will_set_yaw(); + virtual bool did_set_yaw(); + + // Editor: clean + void clean(); + + // Editor: read + bool read(yarp::os::ConnectionReader& connection) override; + + // Editor: write + bool write(yarp::os::ConnectionWriter& connection) const override; + + private: + // Editor: state + Pose* obj; + bool obj_owned; + int group; + + // Editor: dirty variables + bool is_dirty; + bool is_dirty_x; + bool is_dirty_y; + bool is_dirty_z; + bool is_dirty_roll; + bool is_dirty_pitch; + bool is_dirty_yaw; + int dirty_count; + + // Editor: send if possible + void communicate(); + + // Editor: mark dirty overall + void mark_dirty(); + + // Editor: mark dirty single fields + void mark_dirty_x(); + void mark_dirty_y(); + void mark_dirty_z(); + void mark_dirty_roll(); + void mark_dirty_pitch(); + void mark_dirty_yaw(); + + // Editor: dirty_flags + void dirty_flags(bool flag); + }; + +private: + // read/write x field + bool read_x(yarp::os::idl::WireReader& reader); + bool write_x(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_x(yarp::os::idl::WireReader& reader); + bool nested_write_x(const yarp::os::idl::WireWriter& writer) const; + + // read/write y field + bool read_y(yarp::os::idl::WireReader& reader); + bool write_y(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_y(yarp::os::idl::WireReader& reader); + bool nested_write_y(const yarp::os::idl::WireWriter& writer) const; + + // read/write z field + bool read_z(yarp::os::idl::WireReader& reader); + bool write_z(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_z(yarp::os::idl::WireReader& reader); + bool nested_write_z(const yarp::os::idl::WireWriter& writer) const; + + // read/write roll field + bool read_roll(yarp::os::idl::WireReader& reader); + bool write_roll(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_roll(yarp::os::idl::WireReader& reader); + bool nested_write_roll(const yarp::os::idl::WireWriter& writer) const; + + // read/write pitch field + bool read_pitch(yarp::os::idl::WireReader& reader); + bool write_pitch(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_pitch(yarp::os::idl::WireReader& reader); + bool nested_write_pitch(const yarp::os::idl::WireWriter& writer) const; + + // read/write yaw field + bool read_yaw(yarp::os::idl::WireReader& reader); + bool write_yaw(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_yaw(yarp::os::idl::WireReader& reader); + bool nested_write_yaw(const yarp::os::idl::WireWriter& writer) const; }; -#endif +} // namespace GazeboYarpPlugins + +#endif // YARP_THRIFT_GENERATOR_STRUCT_POSE_H diff --git a/thrift/worldinterface/autogenerated/include/WorldInterfaceServer.h b/thrift/worldinterface/autogenerated/include/WorldInterfaceServer.h index 798421033..e8b2aa89b 100644 --- a/thrift/worldinterface/autogenerated/include/WorldInterfaceServer.h +++ b/thrift/worldinterface/autogenerated/include/WorldInterfaceServer.h @@ -1,16 +1,18 @@ /* - * Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT) + * Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT) * All rights reserved. * * This software may be modified and distributed under the terms of the * BSD-3-Clause license. See the accompanying LICENSE file for details. */ +// Autogenerated by Thrift Compiler (0.12.0-yarped) +// // This is an automatically generated file. // It could get re-generated if the ALLOW_IDL_GENERATION flag is on. -#ifndef YARP_THRIFT_GENERATOR_WorldInterfaceServer -#define YARP_THRIFT_GENERATOR_WorldInterfaceServer +#ifndef YARP_THRIFT_GENERATOR_SERVICE_WORLDINTERFACESERVER_H +#define YARP_THRIFT_GENERATOR_SERVICE_WORLDINTERFACESERVER_H #include #include @@ -18,143 +20,165 @@ #include namespace GazeboYarpPlugins { - class WorldInterfaceServer; -} - -class GazeboYarpPlugins::WorldInterfaceServer : public yarp::os::Wire { +class WorldInterfaceServer : + public yarp::os::Wire +{ public: - WorldInterfaceServer(); - /** - * Make a sphere. - * @param radius radius of the sphere [m] - * @param pose pose of the sphere [m] - * @param color color of the sphere - * @param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. - * @param object_name (optional) assigns a name to the object. - * @param gravity_enable (optional) enables gravity (default false) - * @param collision_enable (optional) enables collision (default true) - * @return returns a string that contains the name of the object in the world - */ - virtual std::string makeSphere(const double radius, const Pose& pose, const Color& color, const std::string& frame_name = "", const std::string& object_name = "", const bool gravity_enable = 0, const bool collision_enable = 1); - /** - * Make a box. - * @param width box width [m] - * @param height box height[m] - * @param thickness box thickness [m] - * @param pose pose of the box [m] - * @param color color of the box - * @param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. - * @param object_name (optional) assigns a name to the object. - * @param gravity_enable (optional) enables gravity (default false) - * @param collision_enable (optional) enables collision (default true) - * @return returns a string that contains the name of the object in the world - */ - virtual std::string makeBox(const double width, const double height, const double thickness, const Pose& pose, const Color& color, const std::string& frame_name = "", const std::string& object_name = "", const bool gravity_enable = 0, const bool collision_enable = 1); - /** - * Make a cylinder. - * @param radius radius of the cylinder [m] - * @param length lenght of the cylinder [m] - * @param pose pose of the cylinder [m] - * @param color color of the cylinder - * @param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. - * @param object_name (optional) assigns a name to the object. - * @param gravity_enable (optional) enables gravity (default false) - * @param collision_enable (optional) enables collision (default true) - * @return returns a string that contains the name of the object in the world - */ - virtual std::string makeCylinder(const double radius, const double length, const Pose& pose, const Color& color, const std::string& frame_name = "", const std::string& object_name = "", const bool gravity_enable = 0, const bool collision_enable = 1); - /** - * Make a reference frame. - * @param size size of the frame [m] - * @param pose pose of the frame [m] - * @param color color of the frame - * @param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. - * @param object_name (optional) assigns a name to the object. - * @param gravity_enable (optional) enables gravity (default false) - * @param collision_enable (optional) enables collision (default true) - * @return returns a string that contains the name of the object in the world - */ - virtual std::string makeFrame(const double size, const Pose& pose, const Color& color, const std::string& frame_name = "", const std::string& object_name = "", const bool gravity_enable = 0, const bool collision_enable = 1); - /** - * Change the color of an object - * @param id object id - * @param color color of the frame - * @return returns true or false on success failure - */ - virtual bool changeColor(const std::string& id, const Color& color); - /** - * Set new object pose. - * @param id object id - * @param pose new pose - * @param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. - * @return returns true or false on success failure - */ - virtual bool setPose(const std::string& id, const Pose& pose, const std::string& frame_name = ""); - /** - * Enable/disables gravity for an object - * @param id object id - * @param enable 1 to enable gravity, 0 otherwise - * @return returns true or false on success failure - */ - virtual bool enableGravity(const std::string& id, const bool enable); - /** - * Enable/disables collision detection for an object - * @param id object id - * @param enable 1 to enable collision detection, 0 otherwise - * @return returns true or false on success failure - */ - virtual bool enableCollision(const std::string& id, const bool enable); - /** - * Get object pose. - * @param id string that identifies object in gazebo (returned after creation) - * @param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. - * @return returns value of the pose in the world reference frame - */ - virtual Pose getPose(const std::string& id, const std::string& frame_name = ""); - /** - * Load a model from file. - * @param id string that specifies the name of the model - * @return returns true/false on success failure. - */ - virtual bool loadModelFromFile(const std::string& filename); - /** - * Delete an object. - * @param id string that identifies object in gazebo (returned after creation) - * @return returns true/false on success failure. - */ - virtual bool deleteObject(const std::string& id); - /** - * Delete all objects in the world. - */ - virtual bool deleteAll(); - /** - * List id of all objects that have been added to the world. - * @return return a list of string containing the id of the objects - */ - virtual std::vector getList(); - /** - * Attach an object to a link of the robot. - * @param id string that identifies object in gazebo (returned after creation) - * @param link_name name of a link of the robot - * @return true if success, false otherwise - */ - virtual bool attach(const std::string& id, const std::string& link_name); - /** - * Detach a previously attached object. - * @param id string that identifies object in gazebo (returned after creation) - * @return true if success, false otherwise - */ - virtual bool detach(const std::string& id); - /** - * Change the names of an object. - * @param old_name string that identifies object in gazebo - * @param new_name string that will be used as new name - * @return true if success, false otherwise - */ - virtual bool rename(const std::string& old_name, const std::string& new_name); - virtual bool read(yarp::os::ConnectionReader& connection) override; - virtual std::vector help(const std::string& functionName="--all"); + // Constructor + WorldInterfaceServer(); + + /** + * Make a sphere. + * @param radius radius of the sphere [m] + * @param pose pose of the sphere [m] + * @param color color of the sphere + * @param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. + * @param object_name (optional) assigns a name to the object. + * @param gravity_enable (optional) enables gravity (default false) + * @param collision_enable (optional) enables collision (default true) + * @return returns a string that contains the name of the object in the world + */ + virtual std::string makeSphere(const double radius, const Pose& pose, const Color& color, const std::string& frame_name = "", const std::string& object_name = "", const bool gravity_enable = 0, const bool collision_enable = 1); + + /** + * Make a box. + * @param width box width [m] + * @param height box height[m] + * @param thickness box thickness [m] + * @param pose pose of the box [m] + * @param color color of the box + * @param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. + * @param object_name (optional) assigns a name to the object. + * @param gravity_enable (optional) enables gravity (default false) + * @param collision_enable (optional) enables collision (default true) + * @return returns a string that contains the name of the object in the world + */ + virtual std::string makeBox(const double width, const double height, const double thickness, const Pose& pose, const Color& color, const std::string& frame_name = "", const std::string& object_name = "", const bool gravity_enable = 0, const bool collision_enable = 1); + + /** + * Make a cylinder. + * @param radius radius of the cylinder [m] + * @param length lenght of the cylinder [m] + * @param pose pose of the cylinder [m] + * @param color color of the cylinder + * @param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. + * @param object_name (optional) assigns a name to the object. + * @param gravity_enable (optional) enables gravity (default false) + * @param collision_enable (optional) enables collision (default true) + * @return returns a string that contains the name of the object in the world + */ + virtual std::string makeCylinder(const double radius, const double length, const Pose& pose, const Color& color, const std::string& frame_name = "", const std::string& object_name = "", const bool gravity_enable = 0, const bool collision_enable = 1); + + /** + * Make a reference frame. + * @param size size of the frame [m] + * @param pose pose of the frame [m] + * @param color color of the frame + * @param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. + * @param object_name (optional) assigns a name to the object. + * @param gravity_enable (optional) enables gravity (default false) + * @param collision_enable (optional) enables collision (default true) + * @return returns a string that contains the name of the object in the world + */ + virtual std::string makeFrame(const double size, const Pose& pose, const Color& color, const std::string& frame_name = "", const std::string& object_name = "", const bool gravity_enable = 0, const bool collision_enable = 1); + + /** + * Change the color of an object + * @param id object id + * @param color color of the frame + * @return returns true or false on success failure + */ + virtual bool changeColor(const std::string& id, const Color& color); + + /** + * Set new object pose. + * @param id object id + * @param pose new pose + * @param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. + * @return returns true or false on success failure + */ + virtual bool setPose(const std::string& id, const Pose& pose, const std::string& frame_name = ""); + + /** + * Enable/disables gravity for an object + * @param id object id + * @param enable 1 to enable gravity, 0 otherwise + * @return returns true or false on success failure + */ + virtual bool enableGravity(const std::string& id, const bool enable); + + /** + * Enable/disables collision detection for an object + * @param id object id + * @param enable 1 to enable collision detection, 0 otherwise + * @return returns true or false on success failure + */ + virtual bool enableCollision(const std::string& id, const bool enable); + + /** + * Get object pose. + * @param id string that identifies object in gazebo (returned after creation) + * @param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. + * @return returns value of the pose in the world reference frame + */ + virtual Pose getPose(const std::string& id, const std::string& frame_name = ""); + + /** + * Load a model from file. + * @param id string that specifies the name of the model + * @return returns true/false on success failure. + */ + virtual bool loadModelFromFile(const std::string& filename); + + /** + * Delete an object. + * @param id string that identifies object in gazebo (returned after creation) + * @return returns true/false on success failure. + */ + virtual bool deleteObject(const std::string& id); + + /** + * Delete all objects in the world. + */ + virtual bool deleteAll(); + + /** + * List id of all objects that have been added to the world. + * @return return a list of string containing the id of the objects + */ + virtual std::vector getList(); + + /** + * Attach an object to a link of the robot. + * @param id string that identifies object in gazebo (returned after creation) + * @param link_name name of a link of the robot + * @return true if success, false otherwise + */ + virtual bool attach(const std::string& id, const std::string& link_name); + + /** + * Detach a previously attached object. + * @param id string that identifies object in gazebo (returned after creation) + * @return true if success, false otherwise + */ + virtual bool detach(const std::string& id); + + /** + * Change the names of an object. + * @param old_name string that identifies object in gazebo + * @param new_name string that will be used as new name + * @return true if success, false otherwise + */ + virtual bool rename(const std::string& old_name, const std::string& new_name); + + // help method + virtual std::vector help(const std::string& functionName = "--all"); + + // read from ConnectionReader + bool read(yarp::os::ConnectionReader& connection) override; }; -#endif +} // namespace GazeboYarpPlugins + +#endif // YARP_THRIFT_GENERATOR_SERVICE_WORLDINTERFACESERVER_H diff --git a/thrift/worldinterface/autogenerated/src/Color.cpp b/thrift/worldinterface/autogenerated/src/Color.cpp index 40e5e88c0..3338a9735 100644 --- a/thrift/worldinterface/autogenerated/src/Color.cpp +++ b/thrift/worldinterface/autogenerated/src/Color.cpp @@ -1,222 +1,617 @@ /* - * Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT) + * Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT) * All rights reserved. * * This software may be modified and distributed under the terms of the * BSD-3-Clause license. See the accompanying LICENSE file for details. */ +// Autogenerated by Thrift Compiler (0.12.0-yarped) +// // This is an automatically generated file. // It could get re-generated if the ALLOW_IDL_GENERATION flag is on. #include namespace GazeboYarpPlugins { -bool Color::read_r(yarp::os::idl::WireReader& reader) { - if (!reader.readI16(r)) { - reader.fail(); - return false; - } - return true; -} -bool Color::nested_read_r(yarp::os::idl::WireReader& reader) { - if (!reader.readI16(r)) { - reader.fail(); - return false; - } - return true; -} -bool Color::read_g(yarp::os::idl::WireReader& reader) { - if (!reader.readI16(g)) { - reader.fail(); - return false; - } - return true; -} -bool Color::nested_read_g(yarp::os::idl::WireReader& reader) { - if (!reader.readI16(g)) { - reader.fail(); - return false; - } - return true; -} -bool Color::read_b(yarp::os::idl::WireReader& reader) { - if (!reader.readI16(b)) { - reader.fail(); - return false; - } - return true; -} -bool Color::nested_read_b(yarp::os::idl::WireReader& reader) { - if (!reader.readI16(b)) { - reader.fail(); - return false; - } - return true; -} -bool Color::read(yarp::os::idl::WireReader& reader) { - if (!read_r(reader)) return false; - if (!read_g(reader)) return false; - if (!read_b(reader)) return false; - return !reader.isError(); -} - -bool Color::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListHeader(3)) return false; - return read(reader); -} - -bool Color::write_r(const yarp::os::idl::WireWriter& writer) const { - if (!writer.writeI16(r)) return false; - return true; -} -bool Color::nested_write_r(const yarp::os::idl::WireWriter& writer) const { - if (!writer.writeI16(r)) return false; - return true; -} -bool Color::write_g(const yarp::os::idl::WireWriter& writer) const { - if (!writer.writeI16(g)) return false; - return true; -} -bool Color::nested_write_g(const yarp::os::idl::WireWriter& writer) const { - if (!writer.writeI16(g)) return false; - return true; -} -bool Color::write_b(const yarp::os::idl::WireWriter& writer) const { - if (!writer.writeI16(b)) return false; - return true; -} -bool Color::nested_write_b(const yarp::os::idl::WireWriter& writer) const { - if (!writer.writeI16(b)) return false; - return true; -} -bool Color::write(const yarp::os::idl::WireWriter& writer) const { - if (!write_r(writer)) return false; - if (!write_g(writer)) return false; - if (!write_b(writer)) return false; - return !writer.isError(); -} - -bool Color::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(3)) return false; - return write(writer); -} -bool Color::Editor::write(yarp::os::ConnectionWriter& connection) const { - if (!isValid()) return false; - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(dirty_count+1)) return false; - if (!writer.writeString("patch")) return false; - if (is_dirty_r) { - if (!writer.writeListHeader(3)) return false; - if (!writer.writeString("set")) return false; - if (!writer.writeString("r")) return false; - if (!obj->nested_write_r(writer)) return false; - } - if (is_dirty_g) { - if (!writer.writeListHeader(3)) return false; - if (!writer.writeString("set")) return false; - if (!writer.writeString("g")) return false; - if (!obj->nested_write_g(writer)) return false; - } - if (is_dirty_b) { - if (!writer.writeListHeader(3)) return false; - if (!writer.writeString("set")) return false; - if (!writer.writeString("b")) return false; - if (!obj->nested_write_b(writer)) return false; - } - return !writer.isError(); -} -bool Color::Editor::read(yarp::os::ConnectionReader& connection) { - if (!isValid()) return false; - yarp::os::idl::WireReader reader(connection); - reader.expectAccept(); - if (!reader.readListHeader()) return false; - int len = reader.getLength(); - if (len==0) { - yarp::os::idl::WireWriter writer(reader); - if (writer.isNull()) return true; - if (!writer.writeListHeader(1)) return false; - writer.writeString("send: 'help' or 'patch (param1 val1) (param2 val2)'"); - return true; - } - std::string tag; - if (!reader.readString(tag)) return false; - if (tag=="help") { + +// Default constructor +Color::Color() : + WirePortable(), + r(0), + g(0), + b(0) +{ +} + +// Constructor with field values +Color::Color(const std::int16_t r, + const std::int16_t g, + const std::int16_t b) : + WirePortable(), + r(r), + g(g), + b(b) +{ +} + +// Read structure on a Wire +bool Color::read(yarp::os::idl::WireReader& reader) +{ + if (!read_r(reader)) { + return false; + } + if (!read_g(reader)) { + return false; + } + if (!read_b(reader)) { + return false; + } + return !reader.isError(); +} + +// Read structure on a Connection +bool Color::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListHeader(3)) { + return false; + } + return read(reader); +} + +// Write structure on a Wire +bool Color::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!write_r(writer)) { + return false; + } + if (!write_g(writer)) { + return false; + } + if (!write_b(writer)) { + return false; + } + return !writer.isError(); +} + +// Write structure on a Connection +bool Color::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(3)) { + return false; + } + return write(writer); +} + +// Convert to a printable string +std::string Color::toString() const +{ + yarp::os::Bottle b; + b.read(*this); + return b.toString(); +} + +// Editor: default constructor +Color::Editor::Editor() +{ + group = 0; + obj_owned = true; + obj = new Color; + dirty_flags(false); + yarp().setOwner(*this); +} + +// Editor: constructor with base class +Color::Editor::Editor(Color& obj) +{ + group = 0; + obj_owned = false; + edit(obj, false); + yarp().setOwner(*this); +} + +// Editor: destructor +Color::Editor::~Editor() +{ + if (obj_owned) { + delete obj; + } +} + +// Editor: edit +bool Color::Editor::edit(Color& obj, bool dirty) +{ + if (obj_owned) { + delete this->obj; + } + this->obj = &obj; + obj_owned = false; + dirty_flags(dirty); + return true; +} + +// Editor: validity check +bool Color::Editor::isValid() const +{ + return obj != nullptr; +} + +// Editor: state +Color& Color::Editor::state() +{ + return *obj; +} + +// Editor: grouping begin +void Color::Editor::start_editing() +{ + group++; +} + +// Editor: grouping end +void Color::Editor::stop_editing() +{ + group--; + if (group == 0 && is_dirty) { + communicate(); + } +} +// Editor: r setter +void Color::Editor::set_r(const std::int16_t r) +{ + will_set_r(); + obj->r = r; + mark_dirty_r(); + communicate(); + did_set_r(); +} + +// Editor: r getter +std::int16_t Color::Editor::get_r() const +{ + return obj->r; +} + +// Editor: r will_set +bool Color::Editor::will_set_r() +{ + return true; +} + +// Editor: r did_set +bool Color::Editor::did_set_r() +{ + return true; +} + +// Editor: g setter +void Color::Editor::set_g(const std::int16_t g) +{ + will_set_g(); + obj->g = g; + mark_dirty_g(); + communicate(); + did_set_g(); +} + +// Editor: g getter +std::int16_t Color::Editor::get_g() const +{ + return obj->g; +} + +// Editor: g will_set +bool Color::Editor::will_set_g() +{ + return true; +} + +// Editor: g did_set +bool Color::Editor::did_set_g() +{ + return true; +} + +// Editor: b setter +void Color::Editor::set_b(const std::int16_t b) +{ + will_set_b(); + obj->b = b; + mark_dirty_b(); + communicate(); + did_set_b(); +} + +// Editor: b getter +std::int16_t Color::Editor::get_b() const +{ + return obj->b; +} + +// Editor: b will_set +bool Color::Editor::will_set_b() +{ + return true; +} + +// Editor: b did_set +bool Color::Editor::did_set_b() +{ + return true; +} + +// Editor: clean +void Color::Editor::clean() +{ + dirty_flags(false); +} + +// Editor: read +bool Color::Editor::read(yarp::os::ConnectionReader& connection) +{ + if (!isValid()) { + return false; + } + yarp::os::idl::WireReader reader(connection); + reader.expectAccept(); + if (!reader.readListHeader()) { + return false; + } + int len = reader.getLength(); + if (len == 0) { + yarp::os::idl::WireWriter writer(reader); + if (writer.isNull()) { + return true; + } + if (!writer.writeListHeader(1)) { + return false; + } + writer.writeString("send: 'help' or 'patch (param1 val1) (param2 val2)'"); + return true; + } + std::string tag; + if (!reader.readString(tag)) { + return false; + } + if (tag == "help") { + yarp::os::idl::WireWriter writer(reader); + if (writer.isNull()) { + return true; + } + if (!writer.writeListHeader(2)) { + return false; + } + if (!writer.writeTag("many", 1, 0)) { + return false; + } + if (reader.getLength() > 0) { + std::string field; + if (!reader.readString(field)) { + return false; + } + if (field == "r") { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeString("std::int16_t r")) { + return false; + } + } + if (field == "g") { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeString("std::int16_t g")) { + return false; + } + } + if (field == "b") { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeString("std::int16_t b")) { + return false; + } + } + } + if (!writer.writeListHeader(4)) { + return false; + } + writer.writeString("*** Available fields:"); + writer.writeString("r"); + writer.writeString("g"); + writer.writeString("b"); + return true; + } + bool nested = true; + bool have_act = false; + if (tag != "patch") { + if (((len - 1) % 2) != 0) { + return false; + } + len = 1 + ((len - 1) / 2); + nested = false; + have_act = true; + } + for (int i = 1; i < len; ++i) { + if (nested && !reader.readListHeader(3)) { + return false; + } + std::string act; + std::string key; + if (have_act) { + act = tag; + } else if (!reader.readString(act)) { + return false; + } + if (!reader.readString(key)) { + return false; + } + if (key == "r") { + will_set_r(); + if (!obj->nested_read_r(reader)) { + return false; + } + did_set_r(); + } else if (key == "g") { + will_set_g(); + if (!obj->nested_read_g(reader)) { + return false; + } + did_set_g(); + } else if (key == "b") { + will_set_b(); + if (!obj->nested_read_b(reader)) { + return false; + } + did_set_b(); + } else { + // would be useful to have a fallback here + } + } + reader.accept(); yarp::os::idl::WireWriter writer(reader); - if (writer.isNull()) return true; - if (!writer.writeListHeader(2)) return false; - if (!writer.writeTag("many",1, 0)) return false; - if (reader.getLength()>0) { - std::string field; - if (!reader.readString(field)) return false; - if (field=="r") { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeString("std::int16_t r")) return false; - } - if (field=="g") { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeString("std::int16_t g")) return false; - } - if (field=="b") { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeString("std::int16_t b")) return false; - } - } - if (!writer.writeListHeader(4)) return false; - writer.writeString("*** Available fields:"); - writer.writeString("r"); - writer.writeString("g"); - writer.writeString("b"); - return true; - } - bool nested = true; - bool have_act = false; - if (tag!="patch") { - if ((len-1)%2 != 0) return false; - len = 1 + ((len-1)/2); - nested = false; - have_act = true; - } - for (int i=1; inested_read_r(reader)) return false; - did_set_r(); - } else if (key == "g") { - will_set_g(); - if (!obj->nested_read_g(reader)) return false; - did_set_g(); - } else if (key == "b") { - will_set_b(); - if (!obj->nested_read_b(reader)) return false; - did_set_b(); - } else { - // would be useful to have a fallback here - } - } - reader.accept(); - yarp::os::idl::WireWriter writer(reader); - if (writer.isNull()) return true; - writer.writeListHeader(1); - writer.writeVocab(yarp::os::createVocab('o','k')); - return true; -} - -std::string Color::toString() const { - yarp::os::Bottle b; - b.read(*this); - return b.toString(); -} -} // namespace + if (writer.isNull()) { + return true; + } + writer.writeListHeader(1); + writer.writeVocab(yarp::os::createVocab('o', 'k')); + return true; +} + +// Editor: write +bool Color::Editor::write(yarp::os::ConnectionWriter& connection) const +{ + if (!isValid()) { + return false; + } + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(dirty_count + 1)) { + return false; + } + if (!writer.writeString("patch")) { + return false; + } + if (is_dirty_r) { + if (!writer.writeListHeader(3)) { + return false; + } + if (!writer.writeString("set")) { + return false; + } + if (!writer.writeString("r")) { + return false; + } + if (!obj->nested_write_r(writer)) { + return false; + } + } + if (is_dirty_g) { + if (!writer.writeListHeader(3)) { + return false; + } + if (!writer.writeString("set")) { + return false; + } + if (!writer.writeString("g")) { + return false; + } + if (!obj->nested_write_g(writer)) { + return false; + } + } + if (is_dirty_b) { + if (!writer.writeListHeader(3)) { + return false; + } + if (!writer.writeString("set")) { + return false; + } + if (!writer.writeString("b")) { + return false; + } + if (!obj->nested_write_b(writer)) { + return false; + } + } + return !writer.isError(); +} + +// Editor: send if possible +void Color::Editor::communicate() +{ + if (group != 0) { + return; + } + if (yarp().canWrite()) { + yarp().write(*this); + clean(); + } +} + +// Editor: mark dirty overall +void Color::Editor::mark_dirty() +{ + is_dirty = true; +} + +// Editor: r mark_dirty +void Color::Editor::mark_dirty_r() +{ + if (is_dirty_r) { + return; + } + dirty_count++; + is_dirty_r = true; + mark_dirty(); +} + +// Editor: g mark_dirty +void Color::Editor::mark_dirty_g() +{ + if (is_dirty_g) { + return; + } + dirty_count++; + is_dirty_g = true; + mark_dirty(); +} + +// Editor: b mark_dirty +void Color::Editor::mark_dirty_b() +{ + if (is_dirty_b) { + return; + } + dirty_count++; + is_dirty_b = true; + mark_dirty(); +} + +// Editor: dirty_flags +void Color::Editor::dirty_flags(bool flag) +{ + is_dirty = flag; + is_dirty_r = flag; + is_dirty_g = flag; + is_dirty_b = flag; + dirty_count = flag ? 3 : 0; +} + +// read r field +bool Color::read_r(yarp::os::idl::WireReader& reader) +{ + if (!reader.readI16(r)) { + reader.fail(); + return false; + } + return true; +} + +// write r field +bool Color::write_r(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeI16(r)) { + return false; + } + return true; +} + +// read (nested) r field +bool Color::nested_read_r(yarp::os::idl::WireReader& reader) +{ + if (!reader.readI16(r)) { + reader.fail(); + return false; + } + return true; +} + +// write (nested) r field +bool Color::nested_write_r(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeI16(r)) { + return false; + } + return true; +} + +// read g field +bool Color::read_g(yarp::os::idl::WireReader& reader) +{ + if (!reader.readI16(g)) { + reader.fail(); + return false; + } + return true; +} + +// write g field +bool Color::write_g(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeI16(g)) { + return false; + } + return true; +} + +// read (nested) g field +bool Color::nested_read_g(yarp::os::idl::WireReader& reader) +{ + if (!reader.readI16(g)) { + reader.fail(); + return false; + } + return true; +} + +// write (nested) g field +bool Color::nested_write_g(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeI16(g)) { + return false; + } + return true; +} + +// read b field +bool Color::read_b(yarp::os::idl::WireReader& reader) +{ + if (!reader.readI16(b)) { + reader.fail(); + return false; + } + return true; +} + +// write b field +bool Color::write_b(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeI16(b)) { + return false; + } + return true; +} + +// read (nested) b field +bool Color::nested_read_b(yarp::os::idl::WireReader& reader) +{ + if (!reader.readI16(b)) { + reader.fail(); + return false; + } + return true; +} + +// write (nested) b field +bool Color::nested_write_b(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeI16(b)) { + return false; + } + return true; +} + +} // namespace GazeboYarpPlugins diff --git a/thrift/worldinterface/autogenerated/src/Pose.cpp b/thrift/worldinterface/autogenerated/src/Pose.cpp index 17f6ba98d..6a34f5c4b 100644 --- a/thrift/worldinterface/autogenerated/src/Pose.cpp +++ b/thrift/worldinterface/autogenerated/src/Pose.cpp @@ -1,339 +1,965 @@ /* - * Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT) + * Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT) * All rights reserved. * * This software may be modified and distributed under the terms of the * BSD-3-Clause license. See the accompanying LICENSE file for details. */ +// Autogenerated by Thrift Compiler (0.12.0-yarped) +// // This is an automatically generated file. // It could get re-generated if the ALLOW_IDL_GENERATION flag is on. #include namespace GazeboYarpPlugins { -bool Pose::read_x(yarp::os::idl::WireReader& reader) { - if (!reader.readFloat64(x)) { - reader.fail(); - return false; - } - return true; -} -bool Pose::nested_read_x(yarp::os::idl::WireReader& reader) { - if (!reader.readFloat64(x)) { - reader.fail(); - return false; - } - return true; -} -bool Pose::read_y(yarp::os::idl::WireReader& reader) { - if (!reader.readFloat64(y)) { - reader.fail(); - return false; - } - return true; -} -bool Pose::nested_read_y(yarp::os::idl::WireReader& reader) { - if (!reader.readFloat64(y)) { - reader.fail(); - return false; - } - return true; -} -bool Pose::read_z(yarp::os::idl::WireReader& reader) { - if (!reader.readFloat64(z)) { - reader.fail(); - return false; - } - return true; -} -bool Pose::nested_read_z(yarp::os::idl::WireReader& reader) { - if (!reader.readFloat64(z)) { - reader.fail(); - return false; - } - return true; -} -bool Pose::read_roll(yarp::os::idl::WireReader& reader) { - if (!reader.readFloat64(roll)) { - reader.fail(); - return false; - } - return true; -} -bool Pose::nested_read_roll(yarp::os::idl::WireReader& reader) { - if (!reader.readFloat64(roll)) { - reader.fail(); - return false; - } - return true; -} -bool Pose::read_pitch(yarp::os::idl::WireReader& reader) { - if (!reader.readFloat64(pitch)) { - reader.fail(); - return false; - } - return true; -} -bool Pose::nested_read_pitch(yarp::os::idl::WireReader& reader) { - if (!reader.readFloat64(pitch)) { - reader.fail(); - return false; - } - return true; -} -bool Pose::read_yaw(yarp::os::idl::WireReader& reader) { - if (!reader.readFloat64(yaw)) { - reader.fail(); - return false; - } - return true; -} -bool Pose::nested_read_yaw(yarp::os::idl::WireReader& reader) { - if (!reader.readFloat64(yaw)) { - reader.fail(); - return false; - } - return true; -} -bool Pose::read(yarp::os::idl::WireReader& reader) { - if (!read_x(reader)) return false; - if (!read_y(reader)) return false; - if (!read_z(reader)) return false; - if (!read_roll(reader)) return false; - if (!read_pitch(reader)) return false; - if (!read_yaw(reader)) return false; - return !reader.isError(); -} - -bool Pose::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListHeader(6)) return false; - return read(reader); -} - -bool Pose::write_x(const yarp::os::idl::WireWriter& writer) const { - if (!writer.writeFloat64(x)) return false; - return true; -} -bool Pose::nested_write_x(const yarp::os::idl::WireWriter& writer) const { - if (!writer.writeFloat64(x)) return false; - return true; -} -bool Pose::write_y(const yarp::os::idl::WireWriter& writer) const { - if (!writer.writeFloat64(y)) return false; - return true; -} -bool Pose::nested_write_y(const yarp::os::idl::WireWriter& writer) const { - if (!writer.writeFloat64(y)) return false; - return true; -} -bool Pose::write_z(const yarp::os::idl::WireWriter& writer) const { - if (!writer.writeFloat64(z)) return false; - return true; -} -bool Pose::nested_write_z(const yarp::os::idl::WireWriter& writer) const { - if (!writer.writeFloat64(z)) return false; - return true; -} -bool Pose::write_roll(const yarp::os::idl::WireWriter& writer) const { - if (!writer.writeFloat64(roll)) return false; - return true; -} -bool Pose::nested_write_roll(const yarp::os::idl::WireWriter& writer) const { - if (!writer.writeFloat64(roll)) return false; - return true; -} -bool Pose::write_pitch(const yarp::os::idl::WireWriter& writer) const { - if (!writer.writeFloat64(pitch)) return false; - return true; -} -bool Pose::nested_write_pitch(const yarp::os::idl::WireWriter& writer) const { - if (!writer.writeFloat64(pitch)) return false; - return true; -} -bool Pose::write_yaw(const yarp::os::idl::WireWriter& writer) const { - if (!writer.writeFloat64(yaw)) return false; - return true; -} -bool Pose::nested_write_yaw(const yarp::os::idl::WireWriter& writer) const { - if (!writer.writeFloat64(yaw)) return false; - return true; -} -bool Pose::write(const yarp::os::idl::WireWriter& writer) const { - if (!write_x(writer)) return false; - if (!write_y(writer)) return false; - if (!write_z(writer)) return false; - if (!write_roll(writer)) return false; - if (!write_pitch(writer)) return false; - if (!write_yaw(writer)) return false; - return !writer.isError(); -} - -bool Pose::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(6)) return false; - return write(writer); -} -bool Pose::Editor::write(yarp::os::ConnectionWriter& connection) const { - if (!isValid()) return false; - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(dirty_count+1)) return false; - if (!writer.writeString("patch")) return false; - if (is_dirty_x) { - if (!writer.writeListHeader(3)) return false; - if (!writer.writeString("set")) return false; - if (!writer.writeString("x")) return false; - if (!obj->nested_write_x(writer)) return false; - } - if (is_dirty_y) { - if (!writer.writeListHeader(3)) return false; - if (!writer.writeString("set")) return false; - if (!writer.writeString("y")) return false; - if (!obj->nested_write_y(writer)) return false; - } - if (is_dirty_z) { - if (!writer.writeListHeader(3)) return false; - if (!writer.writeString("set")) return false; - if (!writer.writeString("z")) return false; - if (!obj->nested_write_z(writer)) return false; - } - if (is_dirty_roll) { - if (!writer.writeListHeader(3)) return false; - if (!writer.writeString("set")) return false; - if (!writer.writeString("roll")) return false; - if (!obj->nested_write_roll(writer)) return false; - } - if (is_dirty_pitch) { - if (!writer.writeListHeader(3)) return false; - if (!writer.writeString("set")) return false; - if (!writer.writeString("pitch")) return false; - if (!obj->nested_write_pitch(writer)) return false; - } - if (is_dirty_yaw) { - if (!writer.writeListHeader(3)) return false; - if (!writer.writeString("set")) return false; - if (!writer.writeString("yaw")) return false; - if (!obj->nested_write_yaw(writer)) return false; - } - return !writer.isError(); -} -bool Pose::Editor::read(yarp::os::ConnectionReader& connection) { - if (!isValid()) return false; - yarp::os::idl::WireReader reader(connection); - reader.expectAccept(); - if (!reader.readListHeader()) return false; - int len = reader.getLength(); - if (len==0) { - yarp::os::idl::WireWriter writer(reader); - if (writer.isNull()) return true; - if (!writer.writeListHeader(1)) return false; - writer.writeString("send: 'help' or 'patch (param1 val1) (param2 val2)'"); - return true; - } - std::string tag; - if (!reader.readString(tag)) return false; - if (tag=="help") { + +// Default constructor +Pose::Pose() : + WirePortable(), + x(0), + y(0), + z(0), + roll(0), + pitch(0), + yaw(0) +{ +} + +// Constructor with field values +Pose::Pose(const double x, + const double y, + const double z, + const double roll, + const double pitch, + const double yaw) : + WirePortable(), + x(x), + y(y), + z(z), + roll(roll), + pitch(pitch), + yaw(yaw) +{ +} + +// Read structure on a Wire +bool Pose::read(yarp::os::idl::WireReader& reader) +{ + if (!read_x(reader)) { + return false; + } + if (!read_y(reader)) { + return false; + } + if (!read_z(reader)) { + return false; + } + if (!read_roll(reader)) { + return false; + } + if (!read_pitch(reader)) { + return false; + } + if (!read_yaw(reader)) { + return false; + } + return !reader.isError(); +} + +// Read structure on a Connection +bool Pose::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListHeader(6)) { + return false; + } + return read(reader); +} + +// Write structure on a Wire +bool Pose::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!write_x(writer)) { + return false; + } + if (!write_y(writer)) { + return false; + } + if (!write_z(writer)) { + return false; + } + if (!write_roll(writer)) { + return false; + } + if (!write_pitch(writer)) { + return false; + } + if (!write_yaw(writer)) { + return false; + } + return !writer.isError(); +} + +// Write structure on a Connection +bool Pose::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(6)) { + return false; + } + return write(writer); +} + +// Convert to a printable string +std::string Pose::toString() const +{ + yarp::os::Bottle b; + b.read(*this); + return b.toString(); +} + +// Editor: default constructor +Pose::Editor::Editor() +{ + group = 0; + obj_owned = true; + obj = new Pose; + dirty_flags(false); + yarp().setOwner(*this); +} + +// Editor: constructor with base class +Pose::Editor::Editor(Pose& obj) +{ + group = 0; + obj_owned = false; + edit(obj, false); + yarp().setOwner(*this); +} + +// Editor: destructor +Pose::Editor::~Editor() +{ + if (obj_owned) { + delete obj; + } +} + +// Editor: edit +bool Pose::Editor::edit(Pose& obj, bool dirty) +{ + if (obj_owned) { + delete this->obj; + } + this->obj = &obj; + obj_owned = false; + dirty_flags(dirty); + return true; +} + +// Editor: validity check +bool Pose::Editor::isValid() const +{ + return obj != nullptr; +} + +// Editor: state +Pose& Pose::Editor::state() +{ + return *obj; +} + +// Editor: grouping begin +void Pose::Editor::start_editing() +{ + group++; +} + +// Editor: grouping end +void Pose::Editor::stop_editing() +{ + group--; + if (group == 0 && is_dirty) { + communicate(); + } +} +// Editor: x setter +void Pose::Editor::set_x(const double x) +{ + will_set_x(); + obj->x = x; + mark_dirty_x(); + communicate(); + did_set_x(); +} + +// Editor: x getter +double Pose::Editor::get_x() const +{ + return obj->x; +} + +// Editor: x will_set +bool Pose::Editor::will_set_x() +{ + return true; +} + +// Editor: x did_set +bool Pose::Editor::did_set_x() +{ + return true; +} + +// Editor: y setter +void Pose::Editor::set_y(const double y) +{ + will_set_y(); + obj->y = y; + mark_dirty_y(); + communicate(); + did_set_y(); +} + +// Editor: y getter +double Pose::Editor::get_y() const +{ + return obj->y; +} + +// Editor: y will_set +bool Pose::Editor::will_set_y() +{ + return true; +} + +// Editor: y did_set +bool Pose::Editor::did_set_y() +{ + return true; +} + +// Editor: z setter +void Pose::Editor::set_z(const double z) +{ + will_set_z(); + obj->z = z; + mark_dirty_z(); + communicate(); + did_set_z(); +} + +// Editor: z getter +double Pose::Editor::get_z() const +{ + return obj->z; +} + +// Editor: z will_set +bool Pose::Editor::will_set_z() +{ + return true; +} + +// Editor: z did_set +bool Pose::Editor::did_set_z() +{ + return true; +} + +// Editor: roll setter +void Pose::Editor::set_roll(const double roll) +{ + will_set_roll(); + obj->roll = roll; + mark_dirty_roll(); + communicate(); + did_set_roll(); +} + +// Editor: roll getter +double Pose::Editor::get_roll() const +{ + return obj->roll; +} + +// Editor: roll will_set +bool Pose::Editor::will_set_roll() +{ + return true; +} + +// Editor: roll did_set +bool Pose::Editor::did_set_roll() +{ + return true; +} + +// Editor: pitch setter +void Pose::Editor::set_pitch(const double pitch) +{ + will_set_pitch(); + obj->pitch = pitch; + mark_dirty_pitch(); + communicate(); + did_set_pitch(); +} + +// Editor: pitch getter +double Pose::Editor::get_pitch() const +{ + return obj->pitch; +} + +// Editor: pitch will_set +bool Pose::Editor::will_set_pitch() +{ + return true; +} + +// Editor: pitch did_set +bool Pose::Editor::did_set_pitch() +{ + return true; +} + +// Editor: yaw setter +void Pose::Editor::set_yaw(const double yaw) +{ + will_set_yaw(); + obj->yaw = yaw; + mark_dirty_yaw(); + communicate(); + did_set_yaw(); +} + +// Editor: yaw getter +double Pose::Editor::get_yaw() const +{ + return obj->yaw; +} + +// Editor: yaw will_set +bool Pose::Editor::will_set_yaw() +{ + return true; +} + +// Editor: yaw did_set +bool Pose::Editor::did_set_yaw() +{ + return true; +} + +// Editor: clean +void Pose::Editor::clean() +{ + dirty_flags(false); +} + +// Editor: read +bool Pose::Editor::read(yarp::os::ConnectionReader& connection) +{ + if (!isValid()) { + return false; + } + yarp::os::idl::WireReader reader(connection); + reader.expectAccept(); + if (!reader.readListHeader()) { + return false; + } + int len = reader.getLength(); + if (len == 0) { + yarp::os::idl::WireWriter writer(reader); + if (writer.isNull()) { + return true; + } + if (!writer.writeListHeader(1)) { + return false; + } + writer.writeString("send: 'help' or 'patch (param1 val1) (param2 val2)'"); + return true; + } + std::string tag; + if (!reader.readString(tag)) { + return false; + } + if (tag == "help") { + yarp::os::idl::WireWriter writer(reader); + if (writer.isNull()) { + return true; + } + if (!writer.writeListHeader(2)) { + return false; + } + if (!writer.writeTag("many", 1, 0)) { + return false; + } + if (reader.getLength() > 0) { + std::string field; + if (!reader.readString(field)) { + return false; + } + if (field == "x") { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeString("double x")) { + return false; + } + } + if (field == "y") { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeString("double y")) { + return false; + } + } + if (field == "z") { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeString("double z")) { + return false; + } + } + if (field == "roll") { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeString("double roll")) { + return false; + } + } + if (field == "pitch") { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeString("double pitch")) { + return false; + } + } + if (field == "yaw") { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeString("double yaw")) { + return false; + } + } + } + if (!writer.writeListHeader(7)) { + return false; + } + writer.writeString("*** Available fields:"); + writer.writeString("x"); + writer.writeString("y"); + writer.writeString("z"); + writer.writeString("roll"); + writer.writeString("pitch"); + writer.writeString("yaw"); + return true; + } + bool nested = true; + bool have_act = false; + if (tag != "patch") { + if (((len - 1) % 2) != 0) { + return false; + } + len = 1 + ((len - 1) / 2); + nested = false; + have_act = true; + } + for (int i = 1; i < len; ++i) { + if (nested && !reader.readListHeader(3)) { + return false; + } + std::string act; + std::string key; + if (have_act) { + act = tag; + } else if (!reader.readString(act)) { + return false; + } + if (!reader.readString(key)) { + return false; + } + if (key == "x") { + will_set_x(); + if (!obj->nested_read_x(reader)) { + return false; + } + did_set_x(); + } else if (key == "y") { + will_set_y(); + if (!obj->nested_read_y(reader)) { + return false; + } + did_set_y(); + } else if (key == "z") { + will_set_z(); + if (!obj->nested_read_z(reader)) { + return false; + } + did_set_z(); + } else if (key == "roll") { + will_set_roll(); + if (!obj->nested_read_roll(reader)) { + return false; + } + did_set_roll(); + } else if (key == "pitch") { + will_set_pitch(); + if (!obj->nested_read_pitch(reader)) { + return false; + } + did_set_pitch(); + } else if (key == "yaw") { + will_set_yaw(); + if (!obj->nested_read_yaw(reader)) { + return false; + } + did_set_yaw(); + } else { + // would be useful to have a fallback here + } + } + reader.accept(); yarp::os::idl::WireWriter writer(reader); - if (writer.isNull()) return true; - if (!writer.writeListHeader(2)) return false; - if (!writer.writeTag("many",1, 0)) return false; - if (reader.getLength()>0) { - std::string field; - if (!reader.readString(field)) return false; - if (field=="x") { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeString("double x")) return false; - } - if (field=="y") { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeString("double y")) return false; - } - if (field=="z") { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeString("double z")) return false; - } - if (field=="roll") { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeString("double roll")) return false; - } - if (field=="pitch") { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeString("double pitch")) return false; - } - if (field=="yaw") { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeString("double yaw")) return false; - } - } - if (!writer.writeListHeader(7)) return false; - writer.writeString("*** Available fields:"); - writer.writeString("x"); - writer.writeString("y"); - writer.writeString("z"); - writer.writeString("roll"); - writer.writeString("pitch"); - writer.writeString("yaw"); - return true; - } - bool nested = true; - bool have_act = false; - if (tag!="patch") { - if ((len-1)%2 != 0) return false; - len = 1 + ((len-1)/2); - nested = false; - have_act = true; - } - for (int i=1; inested_read_x(reader)) return false; - did_set_x(); - } else if (key == "y") { - will_set_y(); - if (!obj->nested_read_y(reader)) return false; - did_set_y(); - } else if (key == "z") { - will_set_z(); - if (!obj->nested_read_z(reader)) return false; - did_set_z(); - } else if (key == "roll") { - will_set_roll(); - if (!obj->nested_read_roll(reader)) return false; - did_set_roll(); - } else if (key == "pitch") { - will_set_pitch(); - if (!obj->nested_read_pitch(reader)) return false; - did_set_pitch(); - } else if (key == "yaw") { - will_set_yaw(); - if (!obj->nested_read_yaw(reader)) return false; - did_set_yaw(); - } else { - // would be useful to have a fallback here - } - } - reader.accept(); - yarp::os::idl::WireWriter writer(reader); - if (writer.isNull()) return true; - writer.writeListHeader(1); - writer.writeVocab(yarp::os::createVocab('o','k')); - return true; -} - -std::string Pose::toString() const { - yarp::os::Bottle b; - b.read(*this); - return b.toString(); -} -} // namespace + if (writer.isNull()) { + return true; + } + writer.writeListHeader(1); + writer.writeVocab(yarp::os::createVocab('o', 'k')); + return true; +} + +// Editor: write +bool Pose::Editor::write(yarp::os::ConnectionWriter& connection) const +{ + if (!isValid()) { + return false; + } + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(dirty_count + 1)) { + return false; + } + if (!writer.writeString("patch")) { + return false; + } + if (is_dirty_x) { + if (!writer.writeListHeader(3)) { + return false; + } + if (!writer.writeString("set")) { + return false; + } + if (!writer.writeString("x")) { + return false; + } + if (!obj->nested_write_x(writer)) { + return false; + } + } + if (is_dirty_y) { + if (!writer.writeListHeader(3)) { + return false; + } + if (!writer.writeString("set")) { + return false; + } + if (!writer.writeString("y")) { + return false; + } + if (!obj->nested_write_y(writer)) { + return false; + } + } + if (is_dirty_z) { + if (!writer.writeListHeader(3)) { + return false; + } + if (!writer.writeString("set")) { + return false; + } + if (!writer.writeString("z")) { + return false; + } + if (!obj->nested_write_z(writer)) { + return false; + } + } + if (is_dirty_roll) { + if (!writer.writeListHeader(3)) { + return false; + } + if (!writer.writeString("set")) { + return false; + } + if (!writer.writeString("roll")) { + return false; + } + if (!obj->nested_write_roll(writer)) { + return false; + } + } + if (is_dirty_pitch) { + if (!writer.writeListHeader(3)) { + return false; + } + if (!writer.writeString("set")) { + return false; + } + if (!writer.writeString("pitch")) { + return false; + } + if (!obj->nested_write_pitch(writer)) { + return false; + } + } + if (is_dirty_yaw) { + if (!writer.writeListHeader(3)) { + return false; + } + if (!writer.writeString("set")) { + return false; + } + if (!writer.writeString("yaw")) { + return false; + } + if (!obj->nested_write_yaw(writer)) { + return false; + } + } + return !writer.isError(); +} + +// Editor: send if possible +void Pose::Editor::communicate() +{ + if (group != 0) { + return; + } + if (yarp().canWrite()) { + yarp().write(*this); + clean(); + } +} + +// Editor: mark dirty overall +void Pose::Editor::mark_dirty() +{ + is_dirty = true; +} + +// Editor: x mark_dirty +void Pose::Editor::mark_dirty_x() +{ + if (is_dirty_x) { + return; + } + dirty_count++; + is_dirty_x = true; + mark_dirty(); +} + +// Editor: y mark_dirty +void Pose::Editor::mark_dirty_y() +{ + if (is_dirty_y) { + return; + } + dirty_count++; + is_dirty_y = true; + mark_dirty(); +} + +// Editor: z mark_dirty +void Pose::Editor::mark_dirty_z() +{ + if (is_dirty_z) { + return; + } + dirty_count++; + is_dirty_z = true; + mark_dirty(); +} + +// Editor: roll mark_dirty +void Pose::Editor::mark_dirty_roll() +{ + if (is_dirty_roll) { + return; + } + dirty_count++; + is_dirty_roll = true; + mark_dirty(); +} + +// Editor: pitch mark_dirty +void Pose::Editor::mark_dirty_pitch() +{ + if (is_dirty_pitch) { + return; + } + dirty_count++; + is_dirty_pitch = true; + mark_dirty(); +} + +// Editor: yaw mark_dirty +void Pose::Editor::mark_dirty_yaw() +{ + if (is_dirty_yaw) { + return; + } + dirty_count++; + is_dirty_yaw = true; + mark_dirty(); +} + +// Editor: dirty_flags +void Pose::Editor::dirty_flags(bool flag) +{ + is_dirty = flag; + is_dirty_x = flag; + is_dirty_y = flag; + is_dirty_z = flag; + is_dirty_roll = flag; + is_dirty_pitch = flag; + is_dirty_yaw = flag; + dirty_count = flag ? 6 : 0; +} + +// read x field +bool Pose::read_x(yarp::os::idl::WireReader& reader) +{ + if (!reader.readFloat64(x)) { + reader.fail(); + return false; + } + return true; +} + +// write x field +bool Pose::write_x(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeFloat64(x)) { + return false; + } + return true; +} + +// read (nested) x field +bool Pose::nested_read_x(yarp::os::idl::WireReader& reader) +{ + if (!reader.readFloat64(x)) { + reader.fail(); + return false; + } + return true; +} + +// write (nested) x field +bool Pose::nested_write_x(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeFloat64(x)) { + return false; + } + return true; +} + +// read y field +bool Pose::read_y(yarp::os::idl::WireReader& reader) +{ + if (!reader.readFloat64(y)) { + reader.fail(); + return false; + } + return true; +} + +// write y field +bool Pose::write_y(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeFloat64(y)) { + return false; + } + return true; +} + +// read (nested) y field +bool Pose::nested_read_y(yarp::os::idl::WireReader& reader) +{ + if (!reader.readFloat64(y)) { + reader.fail(); + return false; + } + return true; +} + +// write (nested) y field +bool Pose::nested_write_y(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeFloat64(y)) { + return false; + } + return true; +} + +// read z field +bool Pose::read_z(yarp::os::idl::WireReader& reader) +{ + if (!reader.readFloat64(z)) { + reader.fail(); + return false; + } + return true; +} + +// write z field +bool Pose::write_z(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeFloat64(z)) { + return false; + } + return true; +} + +// read (nested) z field +bool Pose::nested_read_z(yarp::os::idl::WireReader& reader) +{ + if (!reader.readFloat64(z)) { + reader.fail(); + return false; + } + return true; +} + +// write (nested) z field +bool Pose::nested_write_z(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeFloat64(z)) { + return false; + } + return true; +} + +// read roll field +bool Pose::read_roll(yarp::os::idl::WireReader& reader) +{ + if (!reader.readFloat64(roll)) { + reader.fail(); + return false; + } + return true; +} + +// write roll field +bool Pose::write_roll(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeFloat64(roll)) { + return false; + } + return true; +} + +// read (nested) roll field +bool Pose::nested_read_roll(yarp::os::idl::WireReader& reader) +{ + if (!reader.readFloat64(roll)) { + reader.fail(); + return false; + } + return true; +} + +// write (nested) roll field +bool Pose::nested_write_roll(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeFloat64(roll)) { + return false; + } + return true; +} + +// read pitch field +bool Pose::read_pitch(yarp::os::idl::WireReader& reader) +{ + if (!reader.readFloat64(pitch)) { + reader.fail(); + return false; + } + return true; +} + +// write pitch field +bool Pose::write_pitch(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeFloat64(pitch)) { + return false; + } + return true; +} + +// read (nested) pitch field +bool Pose::nested_read_pitch(yarp::os::idl::WireReader& reader) +{ + if (!reader.readFloat64(pitch)) { + reader.fail(); + return false; + } + return true; +} + +// write (nested) pitch field +bool Pose::nested_write_pitch(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeFloat64(pitch)) { + return false; + } + return true; +} + +// read yaw field +bool Pose::read_yaw(yarp::os::idl::WireReader& reader) +{ + if (!reader.readFloat64(yaw)) { + reader.fail(); + return false; + } + return true; +} + +// write yaw field +bool Pose::write_yaw(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeFloat64(yaw)) { + return false; + } + return true; +} + +// read (nested) yaw field +bool Pose::nested_read_yaw(yarp::os::idl::WireReader& reader) +{ + if (!reader.readFloat64(yaw)) { + reader.fail(); + return false; + } + return true; +} + +// write (nested) yaw field +bool Pose::nested_write_yaw(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeFloat64(yaw)) { + return false; + } + return true; +} + +} // namespace GazeboYarpPlugins diff --git a/thrift/worldinterface/autogenerated/src/WorldInterfaceServer.cpp b/thrift/worldinterface/autogenerated/src/WorldInterfaceServer.cpp index e2dc21efe..25ede17b8 100644 --- a/thrift/worldinterface/autogenerated/src/WorldInterfaceServer.cpp +++ b/thrift/worldinterface/autogenerated/src/WorldInterfaceServer.cpp @@ -1,1416 +1,1808 @@ /* - * Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT) + * Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT) * All rights reserved. * * This software may be modified and distributed under the terms of the * BSD-3-Clause license. See the accompanying LICENSE file for details. */ +// Autogenerated by Thrift Compiler (0.12.0-yarped) +// // This is an automatically generated file. // It could get re-generated if the ALLOW_IDL_GENERATION flag is on. #include + #include namespace GazeboYarpPlugins { - -class WorldInterfaceServer_makeSphere : public yarp::os::Portable { -public: - double radius; - Pose pose; - Color color; - std::string frame_name; - std::string object_name; - bool gravity_enable; - bool collision_enable; - std::string _return; - void init(const double radius, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; -}; - -class WorldInterfaceServer_makeBox : public yarp::os::Portable { +class WorldInterfaceServer_makeSphere : + public yarp::os::Portable +{ public: - double width; - double height; - double thickness; - Pose pose; - Color color; - std::string frame_name; - std::string object_name; - bool gravity_enable; - bool collision_enable; - std::string _return; - void init(const double width, const double height, const double thickness, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; + double radius; + Pose pose; + Color color; + std::string frame_name; + std::string object_name; + bool gravity_enable; + bool collision_enable; + std::string _return; + void init(const double radius, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; }; -class WorldInterfaceServer_makeCylinder : public yarp::os::Portable { -public: - double radius; - double length; - Pose pose; - Color color; - std::string frame_name; - std::string object_name; - bool gravity_enable; - bool collision_enable; - std::string _return; - void init(const double radius, const double length, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; -}; +bool WorldInterfaceServer_makeSphere::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(15)) { + return false; + } + if (!writer.writeTag("makeSphere", 1, 1)) { + return false; + } + if (!writer.writeFloat64(radius)) { + return false; + } + if (!writer.write(pose)) { + return false; + } + if (!writer.write(color)) { + return false; + } + if (!writer.writeString(frame_name)) { + return false; + } + if (!writer.writeString(object_name)) { + return false; + } + if (!writer.writeBool(gravity_enable)) { + return false; + } + if (!writer.writeBool(collision_enable)) { + return false; + } + return true; +} -class WorldInterfaceServer_makeFrame : public yarp::os::Portable { -public: - double size; - Pose pose; - Color color; - std::string frame_name; - std::string object_name; - bool gravity_enable; - bool collision_enable; - std::string _return; - void init(const double size, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; -}; +bool WorldInterfaceServer_makeSphere::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { + return false; + } + if (!reader.readString(_return)) { + reader.fail(); + return false; + } + return true; +} -class WorldInterfaceServer_changeColor : public yarp::os::Portable { -public: - std::string id; - Color color; - bool _return; - void init(const std::string& id, const Color& color); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; -}; +void WorldInterfaceServer_makeSphere::init(const double radius, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable) +{ + _return = ""; + this->radius = radius; + this->pose = pose; + this->color = color; + this->frame_name = frame_name; + this->object_name = object_name; + this->gravity_enable = gravity_enable; + this->collision_enable = collision_enable; +} -class WorldInterfaceServer_setPose : public yarp::os::Portable { +class WorldInterfaceServer_makeBox : + public yarp::os::Portable +{ public: - std::string id; - Pose pose; - std::string frame_name; - bool _return; - void init(const std::string& id, const Pose& pose, const std::string& frame_name); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; + double width; + double height; + double thickness; + Pose pose; + Color color; + std::string frame_name; + std::string object_name; + bool gravity_enable; + bool collision_enable; + std::string _return; + void init(const double width, const double height, const double thickness, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; }; -class WorldInterfaceServer_enableGravity : public yarp::os::Portable { -public: - std::string id; - bool enable; - bool _return; - void init(const std::string& id, const bool enable); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; -}; +bool WorldInterfaceServer_makeBox::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(17)) { + return false; + } + if (!writer.writeTag("makeBox", 1, 1)) { + return false; + } + if (!writer.writeFloat64(width)) { + return false; + } + if (!writer.writeFloat64(height)) { + return false; + } + if (!writer.writeFloat64(thickness)) { + return false; + } + if (!writer.write(pose)) { + return false; + } + if (!writer.write(color)) { + return false; + } + if (!writer.writeString(frame_name)) { + return false; + } + if (!writer.writeString(object_name)) { + return false; + } + if (!writer.writeBool(gravity_enable)) { + return false; + } + if (!writer.writeBool(collision_enable)) { + return false; + } + return true; +} -class WorldInterfaceServer_enableCollision : public yarp::os::Portable { +bool WorldInterfaceServer_makeBox::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { + return false; + } + if (!reader.readString(_return)) { + reader.fail(); + return false; + } + return true; +} + +void WorldInterfaceServer_makeBox::init(const double width, const double height, const double thickness, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable) +{ + _return = ""; + this->width = width; + this->height = height; + this->thickness = thickness; + this->pose = pose; + this->color = color; + this->frame_name = frame_name; + this->object_name = object_name; + this->gravity_enable = gravity_enable; + this->collision_enable = collision_enable; +} + +class WorldInterfaceServer_makeCylinder : + public yarp::os::Portable +{ public: - std::string id; - bool enable; - bool _return; - void init(const std::string& id, const bool enable); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; + double radius; + double length; + Pose pose; + Color color; + std::string frame_name; + std::string object_name; + bool gravity_enable; + bool collision_enable; + std::string _return; + void init(const double radius, const double length, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; }; -class WorldInterfaceServer_getPose : public yarp::os::Portable { -public: - std::string id; - std::string frame_name; - Pose _return; - void init(const std::string& id, const std::string& frame_name); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; -}; +bool WorldInterfaceServer_makeCylinder::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(16)) { + return false; + } + if (!writer.writeTag("makeCylinder", 1, 1)) { + return false; + } + if (!writer.writeFloat64(radius)) { + return false; + } + if (!writer.writeFloat64(length)) { + return false; + } + if (!writer.write(pose)) { + return false; + } + if (!writer.write(color)) { + return false; + } + if (!writer.writeString(frame_name)) { + return false; + } + if (!writer.writeString(object_name)) { + return false; + } + if (!writer.writeBool(gravity_enable)) { + return false; + } + if (!writer.writeBool(collision_enable)) { + return false; + } + return true; +} -class WorldInterfaceServer_loadModelFromFile : public yarp::os::Portable { -public: - std::string filename; - bool _return; - void init(const std::string& filename); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; -}; +bool WorldInterfaceServer_makeCylinder::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { + return false; + } + if (!reader.readString(_return)) { + reader.fail(); + return false; + } + return true; +} -class WorldInterfaceServer_deleteObject : public yarp::os::Portable { -public: - std::string id; - bool _return; - void init(const std::string& id); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; -}; +void WorldInterfaceServer_makeCylinder::init(const double radius, const double length, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable) +{ + _return = ""; + this->radius = radius; + this->length = length; + this->pose = pose; + this->color = color; + this->frame_name = frame_name; + this->object_name = object_name; + this->gravity_enable = gravity_enable; + this->collision_enable = collision_enable; +} -class WorldInterfaceServer_deleteAll : public yarp::os::Portable { +class WorldInterfaceServer_makeFrame : + public yarp::os::Portable +{ public: - bool _return; - void init(); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; + double size; + Pose pose; + Color color; + std::string frame_name; + std::string object_name; + bool gravity_enable; + bool collision_enable; + std::string _return; + void init(const double size, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; }; -class WorldInterfaceServer_getList : public yarp::os::Portable { -public: - std::vector _return; - void init(); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; -}; +bool WorldInterfaceServer_makeFrame::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(15)) { + return false; + } + if (!writer.writeTag("makeFrame", 1, 1)) { + return false; + } + if (!writer.writeFloat64(size)) { + return false; + } + if (!writer.write(pose)) { + return false; + } + if (!writer.write(color)) { + return false; + } + if (!writer.writeString(frame_name)) { + return false; + } + if (!writer.writeString(object_name)) { + return false; + } + if (!writer.writeBool(gravity_enable)) { + return false; + } + if (!writer.writeBool(collision_enable)) { + return false; + } + return true; +} -class WorldInterfaceServer_attach : public yarp::os::Portable { -public: - std::string id; - std::string link_name; - bool _return; - void init(const std::string& id, const std::string& link_name); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; -}; +bool WorldInterfaceServer_makeFrame::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { + return false; + } + if (!reader.readString(_return)) { + reader.fail(); + return false; + } + return true; +} -class WorldInterfaceServer_detach : public yarp::os::Portable { -public: - std::string id; - bool _return; - void init(const std::string& id); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; -}; +void WorldInterfaceServer_makeFrame::init(const double size, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable) +{ + _return = ""; + this->size = size; + this->pose = pose; + this->color = color; + this->frame_name = frame_name; + this->object_name = object_name; + this->gravity_enable = gravity_enable; + this->collision_enable = collision_enable; +} -class WorldInterfaceServer_rename : public yarp::os::Portable { +class WorldInterfaceServer_changeColor : + public yarp::os::Portable +{ public: - std::string old_name; - std::string new_name; - bool _return; - void init(const std::string& old_name, const std::string& new_name); - virtual bool write(yarp::os::ConnectionWriter& connection) const override; - virtual bool read(yarp::os::ConnectionReader& connection) override; + std::string id; + Color color; + bool _return; + void init(const std::string& id, const Color& color); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; }; -bool WorldInterfaceServer_makeSphere::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(15)) return false; - if (!writer.writeTag("makeSphere",1,1)) return false; - if (!writer.writeFloat64(radius)) return false; - if (!writer.write(pose)) return false; - if (!writer.write(color)) return false; - if (!writer.writeString(frame_name)) return false; - if (!writer.writeString(object_name)) return false; - if (!writer.writeBool(gravity_enable)) return false; - if (!writer.writeBool(collision_enable)) return false; - return true; -} - -bool WorldInterfaceServer_makeSphere::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - if (!reader.readString(_return)) { - reader.fail(); - return false; - } - return true; -} - -void WorldInterfaceServer_makeSphere::init(const double radius, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable) { - _return = ""; - this->radius = radius; - this->pose = pose; - this->color = color; - this->frame_name = frame_name; - this->object_name = object_name; - this->gravity_enable = gravity_enable; - this->collision_enable = collision_enable; -} - -bool WorldInterfaceServer_makeBox::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(17)) return false; - if (!writer.writeTag("makeBox",1,1)) return false; - if (!writer.writeFloat64(width)) return false; - if (!writer.writeFloat64(height)) return false; - if (!writer.writeFloat64(thickness)) return false; - if (!writer.write(pose)) return false; - if (!writer.write(color)) return false; - if (!writer.writeString(frame_name)) return false; - if (!writer.writeString(object_name)) return false; - if (!writer.writeBool(gravity_enable)) return false; - if (!writer.writeBool(collision_enable)) return false; - return true; -} - -bool WorldInterfaceServer_makeBox::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - if (!reader.readString(_return)) { - reader.fail(); - return false; - } - return true; -} - -void WorldInterfaceServer_makeBox::init(const double width, const double height, const double thickness, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable) { - _return = ""; - this->width = width; - this->height = height; - this->thickness = thickness; - this->pose = pose; - this->color = color; - this->frame_name = frame_name; - this->object_name = object_name; - this->gravity_enable = gravity_enable; - this->collision_enable = collision_enable; -} - -bool WorldInterfaceServer_makeCylinder::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(16)) return false; - if (!writer.writeTag("makeCylinder",1,1)) return false; - if (!writer.writeFloat64(radius)) return false; - if (!writer.writeFloat64(length)) return false; - if (!writer.write(pose)) return false; - if (!writer.write(color)) return false; - if (!writer.writeString(frame_name)) return false; - if (!writer.writeString(object_name)) return false; - if (!writer.writeBool(gravity_enable)) return false; - if (!writer.writeBool(collision_enable)) return false; - return true; -} - -bool WorldInterfaceServer_makeCylinder::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - if (!reader.readString(_return)) { - reader.fail(); - return false; - } - return true; -} - -void WorldInterfaceServer_makeCylinder::init(const double radius, const double length, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable) { - _return = ""; - this->radius = radius; - this->length = length; - this->pose = pose; - this->color = color; - this->frame_name = frame_name; - this->object_name = object_name; - this->gravity_enable = gravity_enable; - this->collision_enable = collision_enable; -} - -bool WorldInterfaceServer_makeFrame::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(15)) return false; - if (!writer.writeTag("makeFrame",1,1)) return false; - if (!writer.writeFloat64(size)) return false; - if (!writer.write(pose)) return false; - if (!writer.write(color)) return false; - if (!writer.writeString(frame_name)) return false; - if (!writer.writeString(object_name)) return false; - if (!writer.writeBool(gravity_enable)) return false; - if (!writer.writeBool(collision_enable)) return false; - return true; -} - -bool WorldInterfaceServer_makeFrame::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - if (!reader.readString(_return)) { - reader.fail(); - return false; - } - return true; -} - -void WorldInterfaceServer_makeFrame::init(const double size, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable) { - _return = ""; - this->size = size; - this->pose = pose; - this->color = color; - this->frame_name = frame_name; - this->object_name = object_name; - this->gravity_enable = gravity_enable; - this->collision_enable = collision_enable; -} - -bool WorldInterfaceServer_changeColor::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(5)) return false; - if (!writer.writeTag("changeColor",1,1)) return false; - if (!writer.writeString(id)) return false; - if (!writer.write(color)) return false; - return true; -} - -bool WorldInterfaceServer_changeColor::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - if (!reader.readBool(_return)) { - reader.fail(); - return false; - } - return true; +bool WorldInterfaceServer_changeColor::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(5)) { + return false; + } + if (!writer.writeTag("changeColor", 1, 1)) { + return false; + } + if (!writer.writeString(id)) { + return false; + } + if (!writer.write(color)) { + return false; + } + return true; } -void WorldInterfaceServer_changeColor::init(const std::string& id, const Color& color) { - _return = false; - this->id = id; - this->color = color; +bool WorldInterfaceServer_changeColor::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { + return false; + } + if (!reader.readBool(_return)) { + reader.fail(); + return false; + } + return true; } -bool WorldInterfaceServer_setPose::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(9)) return false; - if (!writer.writeTag("setPose",1,1)) return false; - if (!writer.writeString(id)) return false; - if (!writer.write(pose)) return false; - if (!writer.writeString(frame_name)) return false; - return true; +void WorldInterfaceServer_changeColor::init(const std::string& id, const Color& color) +{ + _return = false; + this->id = id; + this->color = color; } -bool WorldInterfaceServer_setPose::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - if (!reader.readBool(_return)) { - reader.fail(); - return false; - } - return true; -} +class WorldInterfaceServer_setPose : + public yarp::os::Portable +{ +public: + std::string id; + Pose pose; + std::string frame_name; + bool _return; + void init(const std::string& id, const Pose& pose, const std::string& frame_name); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; +}; -void WorldInterfaceServer_setPose::init(const std::string& id, const Pose& pose, const std::string& frame_name) { - _return = false; - this->id = id; - this->pose = pose; - this->frame_name = frame_name; +bool WorldInterfaceServer_setPose::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(9)) { + return false; + } + if (!writer.writeTag("setPose", 1, 1)) { + return false; + } + if (!writer.writeString(id)) { + return false; + } + if (!writer.write(pose)) { + return false; + } + if (!writer.writeString(frame_name)) { + return false; + } + return true; } -bool WorldInterfaceServer_enableGravity::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(3)) return false; - if (!writer.writeTag("enableGravity",1,1)) return false; - if (!writer.writeString(id)) return false; - if (!writer.writeBool(enable)) return false; - return true; +bool WorldInterfaceServer_setPose::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { + return false; + } + if (!reader.readBool(_return)) { + reader.fail(); + return false; + } + return true; } -bool WorldInterfaceServer_enableGravity::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - if (!reader.readBool(_return)) { - reader.fail(); - return false; - } - return true; +void WorldInterfaceServer_setPose::init(const std::string& id, const Pose& pose, const std::string& frame_name) +{ + _return = false; + this->id = id; + this->pose = pose; + this->frame_name = frame_name; } -void WorldInterfaceServer_enableGravity::init(const std::string& id, const bool enable) { - _return = false; - this->id = id; - this->enable = enable; -} +class WorldInterfaceServer_enableGravity : + public yarp::os::Portable +{ +public: + std::string id; + bool enable; + bool _return; + void init(const std::string& id, const bool enable); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; +}; -bool WorldInterfaceServer_enableCollision::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(3)) return false; - if (!writer.writeTag("enableCollision",1,1)) return false; - if (!writer.writeString(id)) return false; - if (!writer.writeBool(enable)) return false; - return true; +bool WorldInterfaceServer_enableGravity::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(3)) { + return false; + } + if (!writer.writeTag("enableGravity", 1, 1)) { + return false; + } + if (!writer.writeString(id)) { + return false; + } + if (!writer.writeBool(enable)) { + return false; + } + return true; } -bool WorldInterfaceServer_enableCollision::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - if (!reader.readBool(_return)) { - reader.fail(); - return false; - } - return true; +bool WorldInterfaceServer_enableGravity::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { + return false; + } + if (!reader.readBool(_return)) { + reader.fail(); + return false; + } + return true; } -void WorldInterfaceServer_enableCollision::init(const std::string& id, const bool enable) { - _return = false; - this->id = id; - this->enable = enable; +void WorldInterfaceServer_enableGravity::init(const std::string& id, const bool enable) +{ + _return = false; + this->id = id; + this->enable = enable; } -bool WorldInterfaceServer_getPose::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(3)) return false; - if (!writer.writeTag("getPose",1,1)) return false; - if (!writer.writeString(id)) return false; - if (!writer.writeString(frame_name)) return false; - return true; -} +class WorldInterfaceServer_enableCollision : + public yarp::os::Portable +{ +public: + std::string id; + bool enable; + bool _return; + void init(const std::string& id, const bool enable); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; +}; -bool WorldInterfaceServer_getPose::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - if (!reader.read(_return)) { - reader.fail(); - return false; - } - return true; +bool WorldInterfaceServer_enableCollision::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(3)) { + return false; + } + if (!writer.writeTag("enableCollision", 1, 1)) { + return false; + } + if (!writer.writeString(id)) { + return false; + } + if (!writer.writeBool(enable)) { + return false; + } + return true; } -void WorldInterfaceServer_getPose::init(const std::string& id, const std::string& frame_name) { - this->id = id; - this->frame_name = frame_name; +bool WorldInterfaceServer_enableCollision::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { + return false; + } + if (!reader.readBool(_return)) { + reader.fail(); + return false; + } + return true; } -bool WorldInterfaceServer_loadModelFromFile::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(2)) return false; - if (!writer.writeTag("loadModelFromFile",1,1)) return false; - if (!writer.writeString(filename)) return false; - return true; +void WorldInterfaceServer_enableCollision::init(const std::string& id, const bool enable) +{ + _return = false; + this->id = id; + this->enable = enable; } -bool WorldInterfaceServer_loadModelFromFile::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - if (!reader.readBool(_return)) { - reader.fail(); - return false; - } - return true; -} +class WorldInterfaceServer_getPose : + public yarp::os::Portable +{ +public: + std::string id; + std::string frame_name; + Pose _return; + void init(const std::string& id, const std::string& frame_name); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; +}; -void WorldInterfaceServer_loadModelFromFile::init(const std::string& filename) { - _return = false; - this->filename = filename; +bool WorldInterfaceServer_getPose::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(3)) { + return false; + } + if (!writer.writeTag("getPose", 1, 1)) { + return false; + } + if (!writer.writeString(id)) { + return false; + } + if (!writer.writeString(frame_name)) { + return false; + } + return true; } -bool WorldInterfaceServer_deleteObject::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(2)) return false; - if (!writer.writeTag("deleteObject",1,1)) return false; - if (!writer.writeString(id)) return false; - return true; +bool WorldInterfaceServer_getPose::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { + return false; + } + if (!reader.read(_return)) { + reader.fail(); + return false; + } + return true; } -bool WorldInterfaceServer_deleteObject::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - if (!reader.readBool(_return)) { - reader.fail(); - return false; - } - return true; +void WorldInterfaceServer_getPose::init(const std::string& id, const std::string& frame_name) +{ + this->id = id; + this->frame_name = frame_name; } -void WorldInterfaceServer_deleteObject::init(const std::string& id) { - _return = false; - this->id = id; -} +class WorldInterfaceServer_loadModelFromFile : + public yarp::os::Portable +{ +public: + std::string filename; + bool _return; + void init(const std::string& filename); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; +}; -bool WorldInterfaceServer_deleteAll::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(1)) return false; - if (!writer.writeTag("deleteAll",1,1)) return false; - return true; +bool WorldInterfaceServer_loadModelFromFile::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(2)) { + return false; + } + if (!writer.writeTag("loadModelFromFile", 1, 1)) { + return false; + } + if (!writer.writeString(filename)) { + return false; + } + return true; } -bool WorldInterfaceServer_deleteAll::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - if (!reader.readBool(_return)) { - reader.fail(); - return false; - } - return true; +bool WorldInterfaceServer_loadModelFromFile::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { + return false; + } + if (!reader.readBool(_return)) { + reader.fail(); + return false; + } + return true; } -void WorldInterfaceServer_deleteAll::init() { - _return = false; +void WorldInterfaceServer_loadModelFromFile::init(const std::string& filename) +{ + _return = false; + this->filename = filename; } -bool WorldInterfaceServer_getList::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(1)) return false; - if (!writer.writeTag("getList",1,1)) return false; - return true; +class WorldInterfaceServer_deleteObject : + public yarp::os::Portable +{ +public: + std::string id; + bool _return; + void init(const std::string& id); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; +}; + +bool WorldInterfaceServer_deleteObject::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(2)) { + return false; + } + if (!writer.writeTag("deleteObject", 1, 1)) { + return false; + } + if (!writer.writeString(id)) { + return false; + } + return true; } -bool WorldInterfaceServer_getList::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - { - _return.clear(); - uint32_t _size0; - yarp::os::idl::WireState _etype3; - reader.readListBegin(_etype3, _size0); - _return.resize(_size0); - uint32_t _i4; - for (_i4 = 0; _i4 < _size0; ++_i4) - { - if (!reader.readString(_return[_i4])) { +bool WorldInterfaceServer_deleteObject::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { + return false; + } + if (!reader.readBool(_return)) { reader.fail(); return false; - } } - reader.readListEnd(); - } - return true; + return true; } -void WorldInterfaceServer_getList::init() { +void WorldInterfaceServer_deleteObject::init(const std::string& id) +{ + _return = false; + this->id = id; } -bool WorldInterfaceServer_attach::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(3)) return false; - if (!writer.writeTag("attach",1,1)) return false; - if (!writer.writeString(id)) return false; - if (!writer.writeString(link_name)) return false; - return true; -} +class WorldInterfaceServer_deleteAll : + public yarp::os::Portable +{ +public: + bool _return; + void init(); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; +}; -bool WorldInterfaceServer_attach::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - if (!reader.readBool(_return)) { - reader.fail(); - return false; - } - return true; +bool WorldInterfaceServer_deleteAll::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeTag("deleteAll", 1, 1)) { + return false; + } + return true; } -void WorldInterfaceServer_attach::init(const std::string& id, const std::string& link_name) { - _return = false; - this->id = id; - this->link_name = link_name; +bool WorldInterfaceServer_deleteAll::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { + return false; + } + if (!reader.readBool(_return)) { + reader.fail(); + return false; + } + return true; } -bool WorldInterfaceServer_detach::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(2)) return false; - if (!writer.writeTag("detach",1,1)) return false; - if (!writer.writeString(id)) return false; - return true; +void WorldInterfaceServer_deleteAll::init() +{ + _return = false; } -bool WorldInterfaceServer_detach::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - if (!reader.readBool(_return)) { - reader.fail(); - return false; - } - return true; +class WorldInterfaceServer_getList : + public yarp::os::Portable +{ +public: + std::vector _return; + void init(); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; +}; + +bool WorldInterfaceServer_getList::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeTag("getList", 1, 1)) { + return false; + } + return true; } -void WorldInterfaceServer_detach::init(const std::string& id) { - _return = false; - this->id = id; +bool WorldInterfaceServer_getList::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { + return false; + } + _return.clear(); + uint32_t _size0; + yarp::os::idl::WireState _etype3; + reader.readListBegin(_etype3, _size0); + _return.resize(_size0); + for (auto& _elem4 : _return) { + if (!reader.readString(_elem4)) { + reader.fail(); + return false; + } + } + reader.readListEnd(); + return true; } -bool WorldInterfaceServer_rename::write(yarp::os::ConnectionWriter& connection) const { - yarp::os::idl::WireWriter writer(connection); - if (!writer.writeListHeader(3)) return false; - if (!writer.writeTag("rename",1,1)) return false; - if (!writer.writeString(old_name)) return false; - if (!writer.writeString(new_name)) return false; - return true; +void WorldInterfaceServer_getList::init() +{ } -bool WorldInterfaceServer_rename::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - if (!reader.readListReturn()) return false; - if (!reader.readBool(_return)) { - reader.fail(); - return false; - } - return true; -} - -void WorldInterfaceServer_rename::init(const std::string& old_name, const std::string& new_name) { - _return = false; - this->old_name = old_name; - this->new_name = new_name; -} - -WorldInterfaceServer::WorldInterfaceServer() { - yarp().setOwner(*this); -} -std::string WorldInterfaceServer::makeSphere(const double radius, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable) { - std::string _return = ""; - WorldInterfaceServer_makeSphere helper; - helper.init(radius,pose,color,frame_name,object_name,gravity_enable,collision_enable); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","std::string WorldInterfaceServer::makeSphere(const double radius, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable)"); - } - bool ok = yarp().write(helper,helper); - return ok?helper._return:_return; -} -std::string WorldInterfaceServer::makeBox(const double width, const double height, const double thickness, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable) { - std::string _return = ""; - WorldInterfaceServer_makeBox helper; - helper.init(width,height,thickness,pose,color,frame_name,object_name,gravity_enable,collision_enable); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","std::string WorldInterfaceServer::makeBox(const double width, const double height, const double thickness, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable)"); - } - bool ok = yarp().write(helper,helper); - return ok?helper._return:_return; -} -std::string WorldInterfaceServer::makeCylinder(const double radius, const double length, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable) { - std::string _return = ""; - WorldInterfaceServer_makeCylinder helper; - helper.init(radius,length,pose,color,frame_name,object_name,gravity_enable,collision_enable); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","std::string WorldInterfaceServer::makeCylinder(const double radius, const double length, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable)"); - } - bool ok = yarp().write(helper,helper); - return ok?helper._return:_return; -} -std::string WorldInterfaceServer::makeFrame(const double size, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable) { - std::string _return = ""; - WorldInterfaceServer_makeFrame helper; - helper.init(size,pose,color,frame_name,object_name,gravity_enable,collision_enable); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","std::string WorldInterfaceServer::makeFrame(const double size, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable)"); - } - bool ok = yarp().write(helper,helper); - return ok?helper._return:_return; -} -bool WorldInterfaceServer::changeColor(const std::string& id, const Color& color) { - bool _return = false; - WorldInterfaceServer_changeColor helper; - helper.init(id,color); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","bool WorldInterfaceServer::changeColor(const std::string& id, const Color& color)"); - } - bool ok = yarp().write(helper,helper); - return ok?helper._return:_return; -} -bool WorldInterfaceServer::setPose(const std::string& id, const Pose& pose, const std::string& frame_name) { - bool _return = false; - WorldInterfaceServer_setPose helper; - helper.init(id,pose,frame_name); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","bool WorldInterfaceServer::setPose(const std::string& id, const Pose& pose, const std::string& frame_name)"); - } - bool ok = yarp().write(helper,helper); - return ok?helper._return:_return; -} -bool WorldInterfaceServer::enableGravity(const std::string& id, const bool enable) { - bool _return = false; - WorldInterfaceServer_enableGravity helper; - helper.init(id,enable); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","bool WorldInterfaceServer::enableGravity(const std::string& id, const bool enable)"); - } - bool ok = yarp().write(helper,helper); - return ok?helper._return:_return; -} -bool WorldInterfaceServer::enableCollision(const std::string& id, const bool enable) { - bool _return = false; - WorldInterfaceServer_enableCollision helper; - helper.init(id,enable); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","bool WorldInterfaceServer::enableCollision(const std::string& id, const bool enable)"); - } - bool ok = yarp().write(helper,helper); - return ok?helper._return:_return; -} -Pose WorldInterfaceServer::getPose(const std::string& id, const std::string& frame_name) { - Pose _return; - WorldInterfaceServer_getPose helper; - helper.init(id,frame_name); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","Pose WorldInterfaceServer::getPose(const std::string& id, const std::string& frame_name)"); - } - bool ok = yarp().write(helper,helper); - return ok?helper._return:_return; -} -bool WorldInterfaceServer::loadModelFromFile(const std::string& filename) { - bool _return = false; - WorldInterfaceServer_loadModelFromFile helper; - helper.init(filename); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","bool WorldInterfaceServer::loadModelFromFile(const std::string& filename)"); - } - bool ok = yarp().write(helper,helper); - return ok?helper._return:_return; -} -bool WorldInterfaceServer::deleteObject(const std::string& id) { - bool _return = false; - WorldInterfaceServer_deleteObject helper; - helper.init(id); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","bool WorldInterfaceServer::deleteObject(const std::string& id)"); - } - bool ok = yarp().write(helper,helper); - return ok?helper._return:_return; -} -bool WorldInterfaceServer::deleteAll() { - bool _return = false; - WorldInterfaceServer_deleteAll helper; - helper.init(); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","bool WorldInterfaceServer::deleteAll()"); - } - bool ok = yarp().write(helper,helper); - return ok?helper._return:_return; -} -std::vector WorldInterfaceServer::getList() { - std::vector _return; - WorldInterfaceServer_getList helper; - helper.init(); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","std::vector WorldInterfaceServer::getList()"); - } - bool ok = yarp().write(helper,helper); - return ok?helper._return:_return; -} -bool WorldInterfaceServer::attach(const std::string& id, const std::string& link_name) { - bool _return = false; - WorldInterfaceServer_attach helper; - helper.init(id,link_name); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","bool WorldInterfaceServer::attach(const std::string& id, const std::string& link_name)"); - } - bool ok = yarp().write(helper,helper); - return ok?helper._return:_return; -} -bool WorldInterfaceServer::detach(const std::string& id) { - bool _return = false; - WorldInterfaceServer_detach helper; - helper.init(id); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","bool WorldInterfaceServer::detach(const std::string& id)"); - } - bool ok = yarp().write(helper,helper); - return ok?helper._return:_return; -} -bool WorldInterfaceServer::rename(const std::string& old_name, const std::string& new_name) { - bool _return = false; - WorldInterfaceServer_rename helper; - helper.init(old_name,new_name); - if (!yarp().canWrite()) { - yError("Missing server method '%s'?","bool WorldInterfaceServer::rename(const std::string& old_name, const std::string& new_name)"); - } - bool ok = yarp().write(helper,helper); - return ok?helper._return:_return; -} - -bool WorldInterfaceServer::read(yarp::os::ConnectionReader& connection) { - yarp::os::idl::WireReader reader(connection); - reader.expectAccept(); - if (!reader.readListHeader()) { reader.fail(); return false; } - std::string tag = reader.readTag(); - bool direct = (tag=="__direct__"); - if (direct) tag = reader.readTag(); - while (!reader.isError()) { - // TODO: use quick lookup, this is just a test - if (tag == "makeSphere") { - double radius; - Pose pose; - Color color; - std::string frame_name; - std::string object_name; - bool gravity_enable; - bool collision_enable; - if (!reader.readFloat64(radius)) { - reader.fail(); - return false; - } - if (!reader.read(pose)) { - reader.fail(); - return false; - } - if (!reader.read(color)) { - reader.fail(); - return false; - } - if (!reader.readString(frame_name)) { - frame_name = ""; - } - if (!reader.readString(object_name)) { - object_name = ""; - } - if (!reader.readBool(gravity_enable)) { - gravity_enable = 0; - } - if (!reader.readBool(collision_enable)) { - collision_enable = 1; - } - std::string _return; - _return = makeSphere(radius,pose,color,frame_name,object_name,gravity_enable,collision_enable); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeString(_return)) return false; - } - reader.accept(); - return true; - } - if (tag == "makeBox") { - double width; - double height; - double thickness; - Pose pose; - Color color; - std::string frame_name; - std::string object_name; - bool gravity_enable; - bool collision_enable; - if (!reader.readFloat64(width)) { - reader.fail(); - return false; - } - if (!reader.readFloat64(height)) { - reader.fail(); - return false; - } - if (!reader.readFloat64(thickness)) { - reader.fail(); - return false; - } - if (!reader.read(pose)) { - reader.fail(); - return false; - } - if (!reader.read(color)) { - reader.fail(); - return false; - } - if (!reader.readString(frame_name)) { - frame_name = ""; - } - if (!reader.readString(object_name)) { - object_name = ""; - } - if (!reader.readBool(gravity_enable)) { - gravity_enable = 0; - } - if (!reader.readBool(collision_enable)) { - collision_enable = 1; - } - std::string _return; - _return = makeBox(width,height,thickness,pose,color,frame_name,object_name,gravity_enable,collision_enable); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeString(_return)) return false; - } - reader.accept(); - return true; - } - if (tag == "makeCylinder") { - double radius; - double length; - Pose pose; - Color color; - std::string frame_name; - std::string object_name; - bool gravity_enable; - bool collision_enable; - if (!reader.readFloat64(radius)) { - reader.fail(); - return false; - } - if (!reader.readFloat64(length)) { - reader.fail(); +class WorldInterfaceServer_attach : + public yarp::os::Portable +{ +public: + std::string id; + std::string link_name; + bool _return; + void init(const std::string& id, const std::string& link_name); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; +}; + +bool WorldInterfaceServer_attach::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(3)) { return false; - } - if (!reader.read(pose)) { - reader.fail(); + } + if (!writer.writeTag("attach", 1, 1)) { return false; - } - if (!reader.read(color)) { - reader.fail(); + } + if (!writer.writeString(id)) { return false; - } - if (!reader.readString(frame_name)) { - frame_name = ""; - } - if (!reader.readString(object_name)) { - object_name = ""; - } - if (!reader.readBool(gravity_enable)) { - gravity_enable = 0; - } - if (!reader.readBool(collision_enable)) { - collision_enable = 1; - } - std::string _return; - _return = makeCylinder(radius,length,pose,color,frame_name,object_name,gravity_enable,collision_enable); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeString(_return)) return false; - } - reader.accept(); - return true; - } - if (tag == "makeFrame") { - double size; - Pose pose; - Color color; - std::string frame_name; - std::string object_name; - bool gravity_enable; - bool collision_enable; - if (!reader.readFloat64(size)) { - reader.fail(); + } + if (!writer.writeString(link_name)) { return false; - } - if (!reader.read(pose)) { - reader.fail(); + } + return true; +} + +bool WorldInterfaceServer_attach::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { return false; - } - if (!reader.read(color)) { + } + if (!reader.readBool(_return)) { reader.fail(); return false; - } - if (!reader.readString(frame_name)) { - frame_name = ""; - } - if (!reader.readString(object_name)) { - object_name = ""; - } - if (!reader.readBool(gravity_enable)) { - gravity_enable = 0; - } - if (!reader.readBool(collision_enable)) { - collision_enable = 1; - } - std::string _return; - _return = makeFrame(size,pose,color,frame_name,object_name,gravity_enable,collision_enable); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeString(_return)) return false; - } - reader.accept(); - return true; - } - if (tag == "changeColor") { - std::string id; - Color color; - if (!reader.readString(id)) { - reader.fail(); + } + return true; +} + +void WorldInterfaceServer_attach::init(const std::string& id, const std::string& link_name) +{ + _return = false; + this->id = id; + this->link_name = link_name; +} + +class WorldInterfaceServer_detach : + public yarp::os::Portable +{ +public: + std::string id; + bool _return; + void init(const std::string& id); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; +}; + +bool WorldInterfaceServer_detach::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(2)) { return false; - } - if (!reader.read(color)) { - reader.fail(); + } + if (!writer.writeTag("detach", 1, 1)) { return false; - } - bool _return; - _return = changeColor(id,color); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeBool(_return)) return false; - } - reader.accept(); - return true; - } - if (tag == "setPose") { - std::string id; - Pose pose; - std::string frame_name; - if (!reader.readString(id)) { - reader.fail(); + } + if (!writer.writeString(id)) { return false; - } - if (!reader.read(pose)) { - reader.fail(); + } + return true; +} + +bool WorldInterfaceServer_detach::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { return false; - } - if (!reader.readString(frame_name)) { - frame_name = ""; - } - bool _return; - _return = setPose(id,pose,frame_name); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeBool(_return)) return false; - } - reader.accept(); - return true; - } - if (tag == "enableGravity") { - std::string id; - bool enable; - if (!reader.readString(id)) { + } + if (!reader.readBool(_return)) { reader.fail(); return false; - } - if (!reader.readBool(enable)) { - reader.fail(); + } + return true; +} + +void WorldInterfaceServer_detach::init(const std::string& id) +{ + _return = false; + this->id = id; +} + +class WorldInterfaceServer_rename : + public yarp::os::Portable +{ +public: + std::string old_name; + std::string new_name; + bool _return; + void init(const std::string& old_name, const std::string& new_name); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; +}; + +bool WorldInterfaceServer_rename::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(3)) { return false; - } - bool _return; - _return = enableGravity(id,enable); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeBool(_return)) return false; - } - reader.accept(); - return true; - } - if (tag == "enableCollision") { - std::string id; - bool enable; - if (!reader.readString(id)) { - reader.fail(); + } + if (!writer.writeTag("rename", 1, 1)) { return false; - } - if (!reader.readBool(enable)) { - reader.fail(); + } + if (!writer.writeString(old_name)) { return false; - } - bool _return; - _return = enableCollision(id,enable); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeBool(_return)) return false; - } - reader.accept(); - return true; - } - if (tag == "getPose") { - std::string id; - std::string frame_name; - if (!reader.readString(id)) { - reader.fail(); + } + if (!writer.writeString(new_name)) { return false; - } - if (!reader.readString(frame_name)) { - frame_name = ""; - } - Pose _return; - _return = getPose(id,frame_name); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(6)) return false; - if (!writer.write(_return)) return false; - } - reader.accept(); - return true; - } - if (tag == "loadModelFromFile") { - std::string filename; - if (!reader.readString(filename)) { - reader.fail(); + } + return true; +} + +bool WorldInterfaceServer_rename::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListReturn()) { return false; - } - bool _return; - _return = loadModelFromFile(filename); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeBool(_return)) return false; - } - reader.accept(); - return true; - } - if (tag == "deleteObject") { - std::string id; - if (!reader.readString(id)) { + } + if (!reader.readBool(_return)) { reader.fail(); return false; - } - bool _return; - _return = deleteObject(id); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeBool(_return)) return false; - } - reader.accept(); - return true; - } - if (tag == "deleteAll") { - bool _return; - _return = deleteAll(); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeBool(_return)) return false; - } - reader.accept(); - return true; - } - if (tag == "getList") { - std::vector _return; - _return = getList(); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(1)) return false; - { - if (!writer.writeListBegin(BOTTLE_TAG_STRING, static_cast(_return.size()))) return false; - std::vector ::const_iterator _iter5; - for (_iter5 = _return.begin(); _iter5 != _return.end(); ++_iter5) - { - if (!writer.writeString((*_iter5))) return false; - } - if (!writer.writeListEnd()) return false; + } + return true; +} + +void WorldInterfaceServer_rename::init(const std::string& old_name, const std::string& new_name) +{ + _return = false; + this->old_name = old_name; + this->new_name = new_name; +} + +// Constructor +WorldInterfaceServer::WorldInterfaceServer() +{ + yarp().setOwner(*this); +} + +std::string WorldInterfaceServer::makeSphere(const double radius, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable) +{ + std::string _return = ""; + WorldInterfaceServer_makeSphere helper; + helper.init(radius,pose,color,frame_name,object_name,gravity_enable,collision_enable); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "std::string WorldInterfaceServer::makeSphere(const double radius, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable)"); + } + bool ok = yarp().write(helper, helper); + return ok ? helper._return : _return; +} + +std::string WorldInterfaceServer::makeBox(const double width, const double height, const double thickness, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable) +{ + std::string _return = ""; + WorldInterfaceServer_makeBox helper; + helper.init(width,height,thickness,pose,color,frame_name,object_name,gravity_enable,collision_enable); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "std::string WorldInterfaceServer::makeBox(const double width, const double height, const double thickness, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable)"); + } + bool ok = yarp().write(helper, helper); + return ok ? helper._return : _return; +} + +std::string WorldInterfaceServer::makeCylinder(const double radius, const double length, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable) +{ + std::string _return = ""; + WorldInterfaceServer_makeCylinder helper; + helper.init(radius,length,pose,color,frame_name,object_name,gravity_enable,collision_enable); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "std::string WorldInterfaceServer::makeCylinder(const double radius, const double length, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable)"); + } + bool ok = yarp().write(helper, helper); + return ok ? helper._return : _return; +} + +std::string WorldInterfaceServer::makeFrame(const double size, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable) +{ + std::string _return = ""; + WorldInterfaceServer_makeFrame helper; + helper.init(size,pose,color,frame_name,object_name,gravity_enable,collision_enable); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "std::string WorldInterfaceServer::makeFrame(const double size, const Pose& pose, const Color& color, const std::string& frame_name, const std::string& object_name, const bool gravity_enable, const bool collision_enable)"); + } + bool ok = yarp().write(helper, helper); + return ok ? helper._return : _return; +} + +bool WorldInterfaceServer::changeColor(const std::string& id, const Color& color) +{ + bool _return = false; + WorldInterfaceServer_changeColor helper; + helper.init(id,color); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "bool WorldInterfaceServer::changeColor(const std::string& id, const Color& color)"); + } + bool ok = yarp().write(helper, helper); + return ok ? helper._return : _return; +} + +bool WorldInterfaceServer::setPose(const std::string& id, const Pose& pose, const std::string& frame_name) +{ + bool _return = false; + WorldInterfaceServer_setPose helper; + helper.init(id,pose,frame_name); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "bool WorldInterfaceServer::setPose(const std::string& id, const Pose& pose, const std::string& frame_name)"); + } + bool ok = yarp().write(helper, helper); + return ok ? helper._return : _return; +} + +bool WorldInterfaceServer::enableGravity(const std::string& id, const bool enable) +{ + bool _return = false; + WorldInterfaceServer_enableGravity helper; + helper.init(id,enable); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "bool WorldInterfaceServer::enableGravity(const std::string& id, const bool enable)"); + } + bool ok = yarp().write(helper, helper); + return ok ? helper._return : _return; +} + +bool WorldInterfaceServer::enableCollision(const std::string& id, const bool enable) +{ + bool _return = false; + WorldInterfaceServer_enableCollision helper; + helper.init(id,enable); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "bool WorldInterfaceServer::enableCollision(const std::string& id, const bool enable)"); + } + bool ok = yarp().write(helper, helper); + return ok ? helper._return : _return; +} + +Pose WorldInterfaceServer::getPose(const std::string& id, const std::string& frame_name) +{ + Pose _return; + WorldInterfaceServer_getPose helper; + helper.init(id,frame_name); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "Pose WorldInterfaceServer::getPose(const std::string& id, const std::string& frame_name)"); + } + bool ok = yarp().write(helper, helper); + return ok ? helper._return : _return; +} + +bool WorldInterfaceServer::loadModelFromFile(const std::string& filename) +{ + bool _return = false; + WorldInterfaceServer_loadModelFromFile helper; + helper.init(filename); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "bool WorldInterfaceServer::loadModelFromFile(const std::string& filename)"); + } + bool ok = yarp().write(helper, helper); + return ok ? helper._return : _return; +} + +bool WorldInterfaceServer::deleteObject(const std::string& id) +{ + bool _return = false; + WorldInterfaceServer_deleteObject helper; + helper.init(id); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "bool WorldInterfaceServer::deleteObject(const std::string& id)"); + } + bool ok = yarp().write(helper, helper); + return ok ? helper._return : _return; +} + +bool WorldInterfaceServer::deleteAll() +{ + bool _return = false; + WorldInterfaceServer_deleteAll helper; + helper.init(); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "bool WorldInterfaceServer::deleteAll()"); + } + bool ok = yarp().write(helper, helper); + return ok ? helper._return : _return; +} + +std::vector WorldInterfaceServer::getList() +{ + std::vector _return; + WorldInterfaceServer_getList helper; + helper.init(); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "std::vector WorldInterfaceServer::getList()"); + } + bool ok = yarp().write(helper, helper); + return ok ? helper._return : _return; +} + +bool WorldInterfaceServer::attach(const std::string& id, const std::string& link_name) +{ + bool _return = false; + WorldInterfaceServer_attach helper; + helper.init(id,link_name); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "bool WorldInterfaceServer::attach(const std::string& id, const std::string& link_name)"); + } + bool ok = yarp().write(helper, helper); + return ok ? helper._return : _return; +} + +bool WorldInterfaceServer::detach(const std::string& id) +{ + bool _return = false; + WorldInterfaceServer_detach helper; + helper.init(id); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "bool WorldInterfaceServer::detach(const std::string& id)"); + } + bool ok = yarp().write(helper, helper); + return ok ? helper._return : _return; +} + +bool WorldInterfaceServer::rename(const std::string& old_name, const std::string& new_name) +{ + bool _return = false; + WorldInterfaceServer_rename helper; + helper.init(old_name,new_name); + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", "bool WorldInterfaceServer::rename(const std::string& old_name, const std::string& new_name)"); + } + bool ok = yarp().write(helper, helper); + return ok ? helper._return : _return; +} + +// help method +std::vector WorldInterfaceServer::help(const std::string& functionName) +{ + bool showAll = (functionName == "--all"); + std::vector helpString; + if (showAll) { + helpString.emplace_back("*** Available commands:"); + helpString.emplace_back("makeSphere"); + helpString.emplace_back("makeBox"); + helpString.emplace_back("makeCylinder"); + helpString.emplace_back("makeFrame"); + helpString.emplace_back("changeColor"); + helpString.emplace_back("setPose"); + helpString.emplace_back("enableGravity"); + helpString.emplace_back("enableCollision"); + helpString.emplace_back("getPose"); + helpString.emplace_back("loadModelFromFile"); + helpString.emplace_back("deleteObject"); + helpString.emplace_back("deleteAll"); + helpString.emplace_back("getList"); + helpString.emplace_back("attach"); + helpString.emplace_back("detach"); + helpString.emplace_back("rename"); + helpString.emplace_back("help"); + } else { + if (functionName == "makeSphere") { + helpString.emplace_back("std::string makeSphere(const double radius, const Pose& pose, const Color& color, const std::string& frame_name = \"\", const std::string& object_name = \"\", const bool gravity_enable = 0, const bool collision_enable = 1) "); + helpString.emplace_back("Make a sphere. "); + helpString.emplace_back("@param radius radius of the sphere [m] "); + helpString.emplace_back("@param pose pose of the sphere [m] "); + helpString.emplace_back("@param color color of the sphere "); + helpString.emplace_back("@param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. "); + helpString.emplace_back("@param object_name (optional) assigns a name to the object. "); + helpString.emplace_back("@param gravity_enable (optional) enables gravity (default false) "); + helpString.emplace_back("@param collision_enable (optional) enables collision (default true) "); + helpString.emplace_back("@return returns a string that contains the name of the object in the world "); } - } - reader.accept(); - return true; - } - if (tag == "attach") { - std::string id; - std::string link_name; - if (!reader.readString(id)) { - reader.fail(); - return false; - } - if (!reader.readString(link_name)) { - reader.fail(); - return false; - } - bool _return; - _return = attach(id,link_name); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeBool(_return)) return false; - } - reader.accept(); - return true; - } - if (tag == "detach") { - std::string id; - if (!reader.readString(id)) { - reader.fail(); - return false; - } - bool _return; - _return = detach(id); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeBool(_return)) return false; - } - reader.accept(); - return true; - } - if (tag == "rename") { - std::string old_name; - std::string new_name; - if (!reader.readString(old_name)) { - reader.fail(); - return false; - } - if (!reader.readString(new_name)) { + if (functionName == "makeBox") { + helpString.emplace_back("std::string makeBox(const double width, const double height, const double thickness, const Pose& pose, const Color& color, const std::string& frame_name = \"\", const std::string& object_name = \"\", const bool gravity_enable = 0, const bool collision_enable = 1) "); + helpString.emplace_back("Make a box. "); + helpString.emplace_back("@param width box width [m] "); + helpString.emplace_back("@param height box height[m] "); + helpString.emplace_back("@param thickness box thickness [m] "); + helpString.emplace_back("@param pose pose of the box [m] "); + helpString.emplace_back("@param color color of the box "); + helpString.emplace_back("@param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. "); + helpString.emplace_back("@param object_name (optional) assigns a name to the object. "); + helpString.emplace_back("@param gravity_enable (optional) enables gravity (default false) "); + helpString.emplace_back("@param collision_enable (optional) enables collision (default true) "); + helpString.emplace_back("@return returns a string that contains the name of the object in the world "); + } + if (functionName == "makeCylinder") { + helpString.emplace_back("std::string makeCylinder(const double radius, const double length, const Pose& pose, const Color& color, const std::string& frame_name = \"\", const std::string& object_name = \"\", const bool gravity_enable = 0, const bool collision_enable = 1) "); + helpString.emplace_back("Make a cylinder. "); + helpString.emplace_back("@param radius radius of the cylinder [m] "); + helpString.emplace_back("@param length lenght of the cylinder [m] "); + helpString.emplace_back("@param pose pose of the cylinder [m] "); + helpString.emplace_back("@param color color of the cylinder "); + helpString.emplace_back("@param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. "); + helpString.emplace_back("@param object_name (optional) assigns a name to the object. "); + helpString.emplace_back("@param gravity_enable (optional) enables gravity (default false) "); + helpString.emplace_back("@param collision_enable (optional) enables collision (default true) "); + helpString.emplace_back("@return returns a string that contains the name of the object in the world "); + } + if (functionName == "makeFrame") { + helpString.emplace_back("std::string makeFrame(const double size, const Pose& pose, const Color& color, const std::string& frame_name = \"\", const std::string& object_name = \"\", const bool gravity_enable = 0, const bool collision_enable = 1) "); + helpString.emplace_back("Make a reference frame. "); + helpString.emplace_back("@param size size of the frame [m] "); + helpString.emplace_back("@param pose pose of the frame [m] "); + helpString.emplace_back("@param color color of the frame "); + helpString.emplace_back("@param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. "); + helpString.emplace_back("@param object_name (optional) assigns a name to the object. "); + helpString.emplace_back("@param gravity_enable (optional) enables gravity (default false) "); + helpString.emplace_back("@param collision_enable (optional) enables collision (default true) "); + helpString.emplace_back("@return returns a string that contains the name of the object in the world "); + } + if (functionName == "changeColor") { + helpString.emplace_back("bool changeColor(const std::string& id, const Color& color) "); + helpString.emplace_back("Change the color of an object "); + helpString.emplace_back("@param id object id "); + helpString.emplace_back("@param color color of the frame "); + helpString.emplace_back("@return returns true or false on success failure "); + } + if (functionName == "setPose") { + helpString.emplace_back("bool setPose(const std::string& id, const Pose& pose, const std::string& frame_name = \"\") "); + helpString.emplace_back("Set new object pose. "); + helpString.emplace_back("@param id object id "); + helpString.emplace_back("@param pose new pose "); + helpString.emplace_back("@param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. "); + helpString.emplace_back("@return returns true or false on success failure "); + } + if (functionName == "enableGravity") { + helpString.emplace_back("bool enableGravity(const std::string& id, const bool enable) "); + helpString.emplace_back("Enable/disables gravity for an object "); + helpString.emplace_back("@param id object id "); + helpString.emplace_back("@param enable 1 to enable gravity, 0 otherwise "); + helpString.emplace_back("@return returns true or false on success failure "); + } + if (functionName == "enableCollision") { + helpString.emplace_back("bool enableCollision(const std::string& id, const bool enable) "); + helpString.emplace_back("Enable/disables collision detection for an object "); + helpString.emplace_back("@param id object id "); + helpString.emplace_back("@param enable 1 to enable collision detection, 0 otherwise "); + helpString.emplace_back("@return returns true or false on success failure "); + } + if (functionName == "getPose") { + helpString.emplace_back("Pose getPose(const std::string& id, const std::string& frame_name = \"\") "); + helpString.emplace_back("Get object pose. "); + helpString.emplace_back("@param id string that identifies object in gazebo (returned after creation) "); + helpString.emplace_back("@param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. "); + helpString.emplace_back("@return returns value of the pose in the world reference frame "); + } + if (functionName == "loadModelFromFile") { + helpString.emplace_back("bool loadModelFromFile(const std::string& filename) "); + helpString.emplace_back("Load a model from file. "); + helpString.emplace_back("@param id string that specifies the name of the model "); + helpString.emplace_back("@return returns true/false on success failure. "); + } + if (functionName == "deleteObject") { + helpString.emplace_back("bool deleteObject(const std::string& id) "); + helpString.emplace_back("Delete an object. "); + helpString.emplace_back("@param id string that identifies object in gazebo (returned after creation) "); + helpString.emplace_back("@return returns true/false on success failure. "); + } + if (functionName == "deleteAll") { + helpString.emplace_back("bool deleteAll() "); + helpString.emplace_back("Delete all objects in the world. "); + } + if (functionName == "getList") { + helpString.emplace_back("std::vector getList() "); + helpString.emplace_back("List id of all objects that have been added to the world. "); + helpString.emplace_back("@return return a list of string containing the id of the objects "); + } + if (functionName == "attach") { + helpString.emplace_back("bool attach(const std::string& id, const std::string& link_name) "); + helpString.emplace_back("Attach an object to a link of the robot. "); + helpString.emplace_back("@param id string that identifies object in gazebo (returned after creation) "); + helpString.emplace_back("@param link_name name of a link of the robot "); + helpString.emplace_back("@return true if success, false otherwise "); + } + if (functionName == "detach") { + helpString.emplace_back("bool detach(const std::string& id) "); + helpString.emplace_back("Detach a previously attached object. "); + helpString.emplace_back("@param id string that identifies object in gazebo (returned after creation) "); + helpString.emplace_back("@return true if success, false otherwise "); + } + if (functionName == "rename") { + helpString.emplace_back("bool rename(const std::string& old_name, const std::string& new_name) "); + helpString.emplace_back("Change the names of an object. "); + helpString.emplace_back("@param old_name string that identifies object in gazebo "); + helpString.emplace_back("@param new_name string that will be used as new name "); + helpString.emplace_back("@return true if success, false otherwise "); + } + if (functionName == "help") { + helpString.emplace_back("std::vector help(const std::string& functionName = \"--all\")"); + helpString.emplace_back("Return list of available commands, or help message for a specific function"); + helpString.emplace_back("@param functionName name of command for which to get a detailed description. If none or '--all' is provided, print list of available commands"); + helpString.emplace_back("@return list of strings (one string per line)"); + } + } + if (helpString.empty()) { + helpString.emplace_back("Command not found"); + } + return helpString; +} + +// read from ConnectionReader +bool WorldInterfaceServer::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + reader.expectAccept(); + if (!reader.readListHeader()) { reader.fail(); return false; - } - bool _return; - _return = rename(old_name,new_name); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(1)) return false; - if (!writer.writeBool(_return)) return false; - } - reader.accept(); - return true; - } - if (tag == "help") { - std::string functionName; - if (!reader.readString(functionName)) { - functionName = "--all"; - } - std::vector _return=help(functionName); - yarp::os::idl::WireWriter writer(reader); - if (!writer.isNull()) { - if (!writer.writeListHeader(2)) return false; - if (!writer.writeTag("many",1, 0)) return false; - if (!writer.writeListBegin(BOTTLE_TAG_INT32, static_cast(_return.size()))) return false; - std::vector ::iterator _iterHelp; - for (_iterHelp = _return.begin(); _iterHelp != _return.end(); ++_iterHelp) - { - if (!writer.writeString(*_iterHelp)) return false; - } - if (!writer.writeListEnd()) return false; - } - reader.accept(); - return true; - } - if (reader.noMore()) { reader.fail(); return false; } - std::string next_tag = reader.readTag(); - if (next_tag=="") break; - tag = tag + "_" + next_tag; - } - return false; -} - -std::vector WorldInterfaceServer::help(const std::string& functionName) { - bool showAll=(functionName=="--all"); - std::vector helpString; - if(showAll) { - helpString.push_back("*** Available commands:"); - helpString.push_back("makeSphere"); - helpString.push_back("makeBox"); - helpString.push_back("makeCylinder"); - helpString.push_back("makeFrame"); - helpString.push_back("changeColor"); - helpString.push_back("setPose"); - helpString.push_back("enableGravity"); - helpString.push_back("enableCollision"); - helpString.push_back("getPose"); - helpString.push_back("loadModelFromFile"); - helpString.push_back("deleteObject"); - helpString.push_back("deleteAll"); - helpString.push_back("getList"); - helpString.push_back("attach"); - helpString.push_back("detach"); - helpString.push_back("rename"); - helpString.push_back("help"); - } - else { - if (functionName=="makeSphere") { - helpString.push_back("std::string makeSphere(const double radius, const Pose& pose, const Color& color, const std::string& frame_name = \"\", const std::string& object_name = \"\", const bool gravity_enable = 0, const bool collision_enable = 1) "); - helpString.push_back("Make a sphere. "); - helpString.push_back("@param radius radius of the sphere [m] "); - helpString.push_back("@param pose pose of the sphere [m] "); - helpString.push_back("@param color color of the sphere "); - helpString.push_back("@param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. "); - helpString.push_back("@param object_name (optional) assigns a name to the object. "); - helpString.push_back("@param gravity_enable (optional) enables gravity (default false) "); - helpString.push_back("@param collision_enable (optional) enables collision (default true) "); - helpString.push_back("@return returns a string that contains the name of the object in the world "); - } - if (functionName=="makeBox") { - helpString.push_back("std::string makeBox(const double width, const double height, const double thickness, const Pose& pose, const Color& color, const std::string& frame_name = \"\", const std::string& object_name = \"\", const bool gravity_enable = 0, const bool collision_enable = 1) "); - helpString.push_back("Make a box. "); - helpString.push_back("@param width box width [m] "); - helpString.push_back("@param height box height[m] "); - helpString.push_back("@param thickness box thickness [m] "); - helpString.push_back("@param pose pose of the box [m] "); - helpString.push_back("@param color color of the box "); - helpString.push_back("@param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. "); - helpString.push_back("@param object_name (optional) assigns a name to the object. "); - helpString.push_back("@param gravity_enable (optional) enables gravity (default false) "); - helpString.push_back("@param collision_enable (optional) enables collision (default true) "); - helpString.push_back("@return returns a string that contains the name of the object in the world "); - } - if (functionName=="makeCylinder") { - helpString.push_back("std::string makeCylinder(const double radius, const double length, const Pose& pose, const Color& color, const std::string& frame_name = \"\", const std::string& object_name = \"\", const bool gravity_enable = 0, const bool collision_enable = 1) "); - helpString.push_back("Make a cylinder. "); - helpString.push_back("@param radius radius of the cylinder [m] "); - helpString.push_back("@param length lenght of the cylinder [m] "); - helpString.push_back("@param pose pose of the cylinder [m] "); - helpString.push_back("@param color color of the cylinder "); - helpString.push_back("@param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. "); - helpString.push_back("@param object_name (optional) assigns a name to the object. "); - helpString.push_back("@param gravity_enable (optional) enables gravity (default false) "); - helpString.push_back("@param collision_enable (optional) enables collision (default true) "); - helpString.push_back("@return returns a string that contains the name of the object in the world "); - } - if (functionName=="makeFrame") { - helpString.push_back("std::string makeFrame(const double size, const Pose& pose, const Color& color, const std::string& frame_name = \"\", const std::string& object_name = \"\", const bool gravity_enable = 0, const bool collision_enable = 1) "); - helpString.push_back("Make a reference frame. "); - helpString.push_back("@param size size of the frame [m] "); - helpString.push_back("@param pose pose of the frame [m] "); - helpString.push_back("@param color color of the frame "); - helpString.push_back("@param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. "); - helpString.push_back("@param object_name (optional) assigns a name to the object. "); - helpString.push_back("@param gravity_enable (optional) enables gravity (default false) "); - helpString.push_back("@param collision_enable (optional) enables collision (default true) "); - helpString.push_back("@return returns a string that contains the name of the object in the world "); - } - if (functionName=="changeColor") { - helpString.push_back("bool changeColor(const std::string& id, const Color& color) "); - helpString.push_back("Change the color of an object "); - helpString.push_back("@param id object id "); - helpString.push_back("@param color color of the frame "); - helpString.push_back("@return returns true or false on success failure "); - } - if (functionName=="setPose") { - helpString.push_back("bool setPose(const std::string& id, const Pose& pose, const std::string& frame_name = \"\") "); - helpString.push_back("Set new object pose. "); - helpString.push_back("@param id object id "); - helpString.push_back("@param pose new pose "); - helpString.push_back("@param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. "); - helpString.push_back("@return returns true or false on success failure "); - } - if (functionName=="enableGravity") { - helpString.push_back("bool enableGravity(const std::string& id, const bool enable) "); - helpString.push_back("Enable/disables gravity for an object "); - helpString.push_back("@param id object id "); - helpString.push_back("@param enable 1 to enable gravity, 0 otherwise "); - helpString.push_back("@return returns true or false on success failure "); - } - if (functionName=="enableCollision") { - helpString.push_back("bool enableCollision(const std::string& id, const bool enable) "); - helpString.push_back("Enable/disables collision detection for an object "); - helpString.push_back("@param id object id "); - helpString.push_back("@param enable 1 to enable collision detection, 0 otherwise "); - helpString.push_back("@return returns true or false on success failure "); - } - if (functionName=="getPose") { - helpString.push_back("Pose getPose(const std::string& id, const std::string& frame_name = \"\") "); - helpString.push_back("Get object pose. "); - helpString.push_back("@param id string that identifies object in gazebo (returned after creation) "); - helpString.push_back("@param frame_name (optional) is specified, the pose will be relative to the specified fully scoped frame (e.g. MODEL_ID::FRAME_ID). Otherwise, world it will be used. "); - helpString.push_back("@return returns value of the pose in the world reference frame "); - } - if (functionName=="loadModelFromFile") { - helpString.push_back("bool loadModelFromFile(const std::string& filename) "); - helpString.push_back("Load a model from file. "); - helpString.push_back("@param id string that specifies the name of the model "); - helpString.push_back("@return returns true/false on success failure. "); - } - if (functionName=="deleteObject") { - helpString.push_back("bool deleteObject(const std::string& id) "); - helpString.push_back("Delete an object. "); - helpString.push_back("@param id string that identifies object in gazebo (returned after creation) "); - helpString.push_back("@return returns true/false on success failure. "); - } - if (functionName=="deleteAll") { - helpString.push_back("bool deleteAll() "); - helpString.push_back("Delete all objects in the world. "); - } - if (functionName=="getList") { - helpString.push_back("std::vector getList() "); - helpString.push_back("List id of all objects that have been added to the world. "); - helpString.push_back("@return return a list of string containing the id of the objects "); - } - if (functionName=="attach") { - helpString.push_back("bool attach(const std::string& id, const std::string& link_name) "); - helpString.push_back("Attach an object to a link of the robot. "); - helpString.push_back("@param id string that identifies object in gazebo (returned after creation) "); - helpString.push_back("@param link_name name of a link of the robot "); - helpString.push_back("@return true if success, false otherwise "); - } - if (functionName=="detach") { - helpString.push_back("bool detach(const std::string& id) "); - helpString.push_back("Detach a previously attached object. "); - helpString.push_back("@param id string that identifies object in gazebo (returned after creation) "); - helpString.push_back("@return true if success, false otherwise "); - } - if (functionName=="rename") { - helpString.push_back("bool rename(const std::string& old_name, const std::string& new_name) "); - helpString.push_back("Change the names of an object. "); - helpString.push_back("@param old_name string that identifies object in gazebo "); - helpString.push_back("@param new_name string that will be used as new name "); - helpString.push_back("@return true if success, false otherwise "); - } - if (functionName=="help") { - helpString.push_back("std::vector help(const std::string& functionName=\"--all\")"); - helpString.push_back("Return list of available commands, or help message for a specific function"); - helpString.push_back("@param functionName name of command for which to get a detailed description. If none or '--all' is provided, print list of available commands"); - helpString.push_back("@return list of strings (one string per line)"); - } - } - if ( helpString.empty()) helpString.push_back("Command not found"); - return helpString; -} -} // namespace + } + std::string tag = reader.readTag(); + bool direct = (tag == "__direct__"); + if (direct) { + tag = reader.readTag(); + } + while (!reader.isError()) { + if (tag == "makeSphere") { + double radius; + Pose pose; + Color color; + std::string frame_name; + std::string object_name; + bool gravity_enable; + bool collision_enable; + if (!reader.readFloat64(radius)) { + reader.fail(); + return false; + } + if (!reader.read(pose)) { + reader.fail(); + return false; + } + if (!reader.read(color)) { + reader.fail(); + return false; + } + if (!reader.readString(frame_name)) { + frame_name = ""; + } + if (!reader.readString(object_name)) { + object_name = ""; + } + if (!reader.readBool(gravity_enable)) { + gravity_enable = 0; + } + if (!reader.readBool(collision_enable)) { + collision_enable = 1; + } + std::string _return; + _return = makeSphere(radius,pose,color,frame_name,object_name,gravity_enable,collision_enable); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeString(_return)) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "makeBox") { + double width; + double height; + double thickness; + Pose pose; + Color color; + std::string frame_name; + std::string object_name; + bool gravity_enable; + bool collision_enable; + if (!reader.readFloat64(width)) { + reader.fail(); + return false; + } + if (!reader.readFloat64(height)) { + reader.fail(); + return false; + } + if (!reader.readFloat64(thickness)) { + reader.fail(); + return false; + } + if (!reader.read(pose)) { + reader.fail(); + return false; + } + if (!reader.read(color)) { + reader.fail(); + return false; + } + if (!reader.readString(frame_name)) { + frame_name = ""; + } + if (!reader.readString(object_name)) { + object_name = ""; + } + if (!reader.readBool(gravity_enable)) { + gravity_enable = 0; + } + if (!reader.readBool(collision_enable)) { + collision_enable = 1; + } + std::string _return; + _return = makeBox(width,height,thickness,pose,color,frame_name,object_name,gravity_enable,collision_enable); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeString(_return)) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "makeCylinder") { + double radius; + double length; + Pose pose; + Color color; + std::string frame_name; + std::string object_name; + bool gravity_enable; + bool collision_enable; + if (!reader.readFloat64(radius)) { + reader.fail(); + return false; + } + if (!reader.readFloat64(length)) { + reader.fail(); + return false; + } + if (!reader.read(pose)) { + reader.fail(); + return false; + } + if (!reader.read(color)) { + reader.fail(); + return false; + } + if (!reader.readString(frame_name)) { + frame_name = ""; + } + if (!reader.readString(object_name)) { + object_name = ""; + } + if (!reader.readBool(gravity_enable)) { + gravity_enable = 0; + } + if (!reader.readBool(collision_enable)) { + collision_enable = 1; + } + std::string _return; + _return = makeCylinder(radius,length,pose,color,frame_name,object_name,gravity_enable,collision_enable); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeString(_return)) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "makeFrame") { + double size; + Pose pose; + Color color; + std::string frame_name; + std::string object_name; + bool gravity_enable; + bool collision_enable; + if (!reader.readFloat64(size)) { + reader.fail(); + return false; + } + if (!reader.read(pose)) { + reader.fail(); + return false; + } + if (!reader.read(color)) { + reader.fail(); + return false; + } + if (!reader.readString(frame_name)) { + frame_name = ""; + } + if (!reader.readString(object_name)) { + object_name = ""; + } + if (!reader.readBool(gravity_enable)) { + gravity_enable = 0; + } + if (!reader.readBool(collision_enable)) { + collision_enable = 1; + } + std::string _return; + _return = makeFrame(size,pose,color,frame_name,object_name,gravity_enable,collision_enable); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeString(_return)) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "changeColor") { + std::string id; + Color color; + if (!reader.readString(id)) { + reader.fail(); + return false; + } + if (!reader.read(color)) { + reader.fail(); + return false; + } + bool _return; + _return = changeColor(id,color); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeBool(_return)) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "setPose") { + std::string id; + Pose pose; + std::string frame_name; + if (!reader.readString(id)) { + reader.fail(); + return false; + } + if (!reader.read(pose)) { + reader.fail(); + return false; + } + if (!reader.readString(frame_name)) { + frame_name = ""; + } + bool _return; + _return = setPose(id,pose,frame_name); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeBool(_return)) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "enableGravity") { + std::string id; + bool enable; + if (!reader.readString(id)) { + reader.fail(); + return false; + } + if (!reader.readBool(enable)) { + reader.fail(); + return false; + } + bool _return; + _return = enableGravity(id,enable); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeBool(_return)) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "enableCollision") { + std::string id; + bool enable; + if (!reader.readString(id)) { + reader.fail(); + return false; + } + if (!reader.readBool(enable)) { + reader.fail(); + return false; + } + bool _return; + _return = enableCollision(id,enable); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeBool(_return)) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "getPose") { + std::string id; + std::string frame_name; + if (!reader.readString(id)) { + reader.fail(); + return false; + } + if (!reader.readString(frame_name)) { + frame_name = ""; + } + Pose _return; + _return = getPose(id,frame_name); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(6)) { + return false; + } + if (!writer.write(_return)) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "loadModelFromFile") { + std::string filename; + if (!reader.readString(filename)) { + reader.fail(); + return false; + } + bool _return; + _return = loadModelFromFile(filename); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeBool(_return)) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "deleteObject") { + std::string id; + if (!reader.readString(id)) { + reader.fail(); + return false; + } + bool _return; + _return = deleteObject(id); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeBool(_return)) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "deleteAll") { + bool _return; + _return = deleteAll(); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeBool(_return)) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "getList") { + std::vector _return; + _return = getList(); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeListBegin(BOTTLE_TAG_STRING, static_cast(_return.size()))) { + return false; + } + for (const auto& _item5 : _return) { + if (!writer.writeString(_item5)) { + return false; + } + } + if (!writer.writeListEnd()) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "attach") { + std::string id; + std::string link_name; + if (!reader.readString(id)) { + reader.fail(); + return false; + } + if (!reader.readString(link_name)) { + reader.fail(); + return false; + } + bool _return; + _return = attach(id,link_name); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeBool(_return)) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "detach") { + std::string id; + if (!reader.readString(id)) { + reader.fail(); + return false; + } + bool _return; + _return = detach(id); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeBool(_return)) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "rename") { + std::string old_name; + std::string new_name; + if (!reader.readString(old_name)) { + reader.fail(); + return false; + } + if (!reader.readString(new_name)) { + reader.fail(); + return false; + } + bool _return; + _return = rename(old_name,new_name); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(1)) { + return false; + } + if (!writer.writeBool(_return)) { + return false; + } + } + reader.accept(); + return true; + } + if (tag == "help") { + std::string functionName; + if (!reader.readString(functionName)) { + functionName = "--all"; + } + auto _return = help(functionName); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(2)) { + return false; + } + if (!writer.writeTag("many", 1, 0)) { + return false; + } + if (!writer.writeListBegin(BOTTLE_TAG_INT32, static_cast(_return.size()))) { + return false; + } + for (const auto& _ret : _return) { + if (!writer.writeString(_ret)) { + return false; + } + } + if (!writer.writeListEnd()) { + return false; + } + } + reader.accept(); + return true; + } + if (reader.noMore()) { + reader.fail(); + return false; + } + std::string next_tag = reader.readTag(); + if (next_tag == "") { + break; + } + tag.append("_").append(next_tag); + } + return false; +} +} // namespace GazeboYarpPlugins diff --git a/thrift/worldinterface/autogenerated/worldinterface_rpc_thrift.cmake b/thrift/worldinterface/autogenerated/worldinterface_rpc_thrift.cmake index bb60da889..f53a98592 100644 --- a/thrift/worldinterface/autogenerated/worldinterface_rpc_thrift.cmake +++ b/thrift/worldinterface/autogenerated/worldinterface_rpc_thrift.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT) +# Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT) # All rights reserved. # # This software may be modified and distributed under the terms of the