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/GetJointForce.h"
00029
00030 #include <sstream>
00031
00032 Instruction::tExecResultType GetJointForce::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 force;
00040 if (Instr[2]=="1")
00041 force = joint->getForce(2).getValue();
00042 else
00043 force = joint->getForce(1).getValue();
00044 answer << std::scientific << force[0] << ' ' << force[1] << ' ' << force[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 }