YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ImplementJointCoupling.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6
8#include <algorithm>
9
10
11using namespace yarp::dev;
12
13
15 yarp::sig::VectorOf<size_t> coupled_actuated_axes,
16 std::vector<std::string> physical_joint_names,
17 std::vector<std::string> actuated_axes_names,
18 std::vector<std::pair<double, double>> physical_joint_limits)
19{
20 m_coupledPhysicalJoints = coupled_physical_joints;
21 m_coupledActuatedAxes = coupled_actuated_axes;
22 m_physicalJointNames = physical_joint_names;
23 m_actuatedAxesNames = actuated_axes_names;
24 m_physicalJointLimits = physical_joint_limits;
25}
26
28 nrOfPhysicalJoints = m_physicalJointNames.size();
29 return ReturnValue_ok;
30}
32 nrOfActuatedAxes = m_actuatedAxesNames.size();
33 return ReturnValue_ok;
34}
35
40
45
46ReturnValue ImplementJointCoupling::getPhysicalJointName(size_t physicalJointIndex, std::string& physicalJointName){
47 if(physicalJointIndex >= m_physicalJointNames.size()) {
49 }
50 else {
51 physicalJointName=m_physicalJointNames[physicalJointIndex];
52 return ReturnValue_ok;
53 }
54
55}
56
57ReturnValue ImplementJointCoupling::getActuatedAxisName(size_t actuatedAxisIndex, std::string& actuatedAxisName){
58 if(actuatedAxisIndex >= m_actuatedAxesNames.size()) {
60 }
61 else {
62 actuatedAxisName=m_actuatedAxesNames[actuatedAxisIndex];
63 return ReturnValue_ok;
64 }
65}
66
68 return std::find(m_coupledPhysicalJoints.begin(), m_coupledPhysicalJoints.end(), physicalJointIndex) != m_coupledPhysicalJoints.end();
69}
70
71ReturnValue ImplementJointCoupling::getPhysicalJointLimits(size_t physicalJointIndex, double& min, double& max){
72 size_t nrOfPhysicalJoints;
73 auto ok = getNrOfPhysicalJoints(nrOfPhysicalJoints);
74 if (ok && physicalJointIndex < nrOfPhysicalJoints)
75 {
76 min = m_physicalJointLimits[physicalJointIndex].first;
77 max = m_physicalJointLimits[physicalJointIndex].second;
78 return ReturnValue_ok;
79 }
81}
#define ReturnValue_ok
Definition ReturnValue.h:82
std::vector< std::pair< double, double > > m_physicalJointLimits
yarp::dev::ReturnValue getPhysicalJointLimits(size_t physicalJointIndex, double &min, double &max) override final
yarp::dev::ReturnValue getCoupledActuatedAxes(yarp::sig::VectorOf< size_t > &coupActAxesIndexes) override final
std::vector< std::string > m_physicalJointNames
std::vector< std::string > m_actuatedAxesNames
yarp::dev::ReturnValue getNrOfActuatedAxes(size_t &nrOfActuatedAxes) override final
yarp::dev::ReturnValue getActuatedAxisName(size_t actuatedAxisIndex, std::string &actuatedAxisName) override final
yarp::sig::VectorOf< size_t > m_coupledPhysicalJoints
yarp::dev::ReturnValue getNrOfPhysicalJoints(size_t &nrOfPhysicalJoints) override final
yarp::sig::VectorOf< size_t > m_coupledActuatedAxes
yarp::dev::ReturnValue getCoupledPhysicalJoints(yarp::sig::VectorOf< size_t > &coupPhysJointsIndexes) override final
bool checkPhysicalJointIsCoupled(size_t physicalJointIndex)
void initialise(yarp::sig::VectorOf< size_t > coupled_physical_joints, yarp::sig::VectorOf< size_t > coupled_actuated_axes, std::vector< std::string > physical_joint_names, std::vector< std::string > actuated_axes_names, std::vector< std::pair< double, double > > coupled_physical_joint_limits)
yarp::dev::ReturnValue getPhysicalJointName(size_t physicalJointIndex, std::string &physicalJointName) override final
@ return_value_error_input_out_of_bounds
Method failed because some initialization is missing.
For streams capable of holding different kinds of content, check what they actually have.
typename vector_selector< T >::type VectorOf
Definition Vector.h:174