diff --git a/src/libYARP_dev/src/yarp/dev/IJointCoupling.h b/src/libYARP_dev/src/yarp/dev/IJointCoupling.h index 0aedd3217d..4fabc76f7e 100644 --- a/src/libYARP_dev/src/yarp/dev/IJointCoupling.h +++ b/src/libYARP_dev/src/yarp/dev/IJointCoupling.h @@ -176,36 +176,39 @@ class YARP_dev_API yarp::dev::IJointCoupling /** * @brief Return the vector of "physical joints indices" (i.e. numbers from 0 to n-1) * that are related to actuated axis in a non-obvious way - * - * @return the vector of "physical joints indices" + * @param[out] coupPhysJointsIndexes the vector of "physical joints indices" + * @return true/false on success/failure */ - virtual yarp::sig::VectorOf getCoupledPhysicalJoints()=0; + virtual bool getCoupledPhysicalJoints(yarp::sig::VectorOf& coupPhysJointsIndexes)=0; /** * @brief Return the vector of "actuator axis indices" (i.e. numbers from 0 to m-1) * that are related to physical joints in a non-obvious way * - * @return teh vector of "actuator axis indices" + * @param[out] coupActAxesIndexes the vector of "actuator axis indices" + * @return true/false on success/failure */ - virtual yarp::sig::VectorOf getCoupledActuatedAxes()=0; + virtual bool getCoupledActuatedAxes(yarp::sig::VectorOf& coupActAxesIndexes)=0; /** * @brief Get the name of an actuated axis * * @param[in] actuatedAxisIndex the number from 0 to m-1 that identifies * the location of a "actuated axis" in a actuated axis vector. - * @return the actuated axis name + * @param[out] actuatedAxisName the actuated axis name + * @return true/false on success/failure */ - virtual std::string getActuatedAxisName(size_t actuatedAxisIndex)=0; + virtual bool getActuatedAxisName(size_t actuatedAxisIndex, std::string& actuatedAxisName)=0; /** * @brief Get the name of a physical joint * * @param[in] physicalJointIndex the number from 0 to n-1 that identifies * the location of a "physical joint" in a physical joint vector - * @return the physical joint name + * @param[out] physicalJointName the physical joint name + * @return true/false on success/failure */ - virtual std::string getPhysicalJointName(size_t physicalJointIndex)=0; + virtual bool getPhysicalJointName(size_t physicalJointIndex, std::string& physicalJointName)=0; /** * @brief Get the Physical Joint Limit object diff --git a/src/libYARP_dev/src/yarp/dev/ImplementJointCoupling.cpp b/src/libYARP_dev/src/yarp/dev/ImplementJointCoupling.cpp index f058218be6..f455d95da5 100644 --- a/src/libYARP_dev/src/yarp/dev/ImplementJointCoupling.cpp +++ b/src/libYARP_dev/src/yarp/dev/ImplementJointCoupling.cpp @@ -25,7 +25,8 @@ void ImplementJointCoupling::initialise(yarp::sig::VectorOf physical_joi for (std::size_t i = 0, j = 0; i < physical_joints.size(); i++) { const int physical_joint_index = physical_joints(i); - const std::string physical_joint_name = getPhysicalJointName(physical_joint_index); + std::string physical_joint_name {""}; + auto ok = getPhysicalJointName(physical_joint_index, physical_joint_name); if (physical_joint_name != "invalid" && physical_joint_name != "reserved") { m_physicalJointLimits[physical_joints[i]] = physical_joint_limits[j]; @@ -36,16 +37,17 @@ void ImplementJointCoupling::initialise(yarp::sig::VectorOf physical_joi } - -yarp::sig::VectorOf ImplementJointCoupling::getCoupledPhysicalJoints() { - return m_physicalJoints; +bool ImplementJointCoupling::getCoupledPhysicalJoints(yarp::sig::VectorOf& coupPhysJointsIndexes) { + coupPhysJointsIndexes = m_physicalJoints; + return true; } -yarp::sig::VectorOf ImplementJointCoupling::getCoupledActuatedAxes() { - return m_actuatedAxes; +bool ImplementJointCoupling::getCoupledActuatedAxes(yarp::sig::VectorOf& coupActAxesIndexes) { + coupActAxesIndexes = m_actuatedAxes; + return true; } -std::string ImplementJointCoupling::getPhysicalJointName(size_t physicalJointIndex){ +bool ImplementJointCoupling::getPhysicalJointName(size_t physicalJointIndex, std::string& physicalJointName){ int c_joint = -1; // TODO refactor also here for (size_t i = 0; i < m_physicalJoints.size(); ++i) @@ -55,17 +57,20 @@ std::string ImplementJointCoupling::getPhysicalJointName(size_t physicalJointInd if (c_joint >= 0 && static_cast(c_joint) < m_physicalJoints.size()) { - return m_physicalJointNames[c_joint]; + physicalJointName = m_physicalJointNames[c_joint]; + return true; } else { - return std::string("invalid"); + physicalJointName = "invalid"; + return false; } } -std::string ImplementJointCoupling::getActuatedAxisName(size_t actuatedAxisIndex){ +bool ImplementJointCoupling::getActuatedAxisName(size_t actuatedAxisIndex, std::string& actuatedAxisName){ // TODO is it right? - return m_actuatedAxesNames[actuatedAxisIndex]; + actuatedAxisName = m_actuatedAxesNames[actuatedAxisIndex]; + return true; } bool ImplementJointCoupling::checkPhysicalJointIsCoupled(size_t physicalJointIndex){ @@ -73,9 +78,10 @@ bool ImplementJointCoupling::checkPhysicalJointIsCoupled(size_t physicalJointInd } bool ImplementJointCoupling::getPhysicalJointLimits(size_t physicalJointIndex, double& min, double& max){ - const std::string physical_joint_name = getPhysicalJointName(physicalJointIndex); + std::string physical_joint_name{""}; + auto ok = getPhysicalJointName(physicalJointIndex, physical_joint_name); - if (physical_joint_name != "reserved" && physical_joint_name != "gyp_invalid") + if (physical_joint_name != "reserved" && physical_joint_name != "invalid") { min = m_physicalJointLimits.at(physicalJointIndex).first; max = m_physicalJointLimits.at(physicalJointIndex).second; diff --git a/src/libYARP_dev/src/yarp/dev/ImplementJointCoupling.h b/src/libYARP_dev/src/yarp/dev/ImplementJointCoupling.h index c6e2cbfa4c..2ab4128dc4 100644 --- a/src/libYARP_dev/src/yarp/dev/ImplementJointCoupling.h +++ b/src/libYARP_dev/src/yarp/dev/ImplementJointCoupling.h @@ -35,10 +35,10 @@ class YARP_dev_API yarp::dev::ImplementJointCoupling: public IJointCoupling std::vector actuated_axes_names, std::vector> physical_joint_limits); - yarp::sig::VectorOf getCoupledPhysicalJoints() override final; - yarp::sig::VectorOf getCoupledActuatedAxes() override final; - std::string getPhysicalJointName(size_t physicalJointIndex) override final; - std::string getActuatedAxisName(size_t actuatedAxisIndex) override final; + bool getCoupledPhysicalJoints(yarp::sig::VectorOf& coupPhysJointsIndexes) override final; + bool getCoupledActuatedAxes(yarp::sig::VectorOf& coupActAxesIndexes) override final; + bool getPhysicalJointName(size_t physicalJointIndex, std::string& physicalJointName) override final; + bool getActuatedAxisName(size_t actuatedAxisIndex, std::string& actuatedAxisName) override final; bool getPhysicalJointLimits(size_t physicalJointIndex, double& min, double& max) override final; protected: