00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00027 #include "../include/IPSA/ipsaclasses.h"
00028 #include "../include/IPSA/viewer/instructions/GetJointTorque.h"
00029
00030 #include <sstream>
00031
00032 Instruction::tExecResultType GetJointTorque::vExecute(std::vector<std::string>& Instr, std::ostringstream& answer, unsigned int& numberOfReturnValues)
00033 {
00034 numberOfReturnValues = 0;
00035 tExecResultType res = eJOINT_NOT_FOUND;
00036 SoJoint* joint = Instruction::GetNodeOfTypeByName<SoJoint*>(Instr[1]);
00037 if (joint)
00038 {
00039 SbVec3f torque;
00040 if (Instr[2]=="1")
00041 torque = joint->getTorque(2).getValue();
00042 else
00043 torque = joint->getTorque(1).getValue();
00044 answer << std::scientific << torque[0] << ' ' << torque[1] << ' ' << torque[2];
00045 numberOfReturnValues = 3;
00046 res = eOK;
00047 }
00048 else
00049 res = eJOINT_TYPE_INCOMPATIBLE;
00050
00051 answer << '\r' << std::endl;
00052 return res;
00053 }