@Manikanta Here's an updated version with the a user command 'updateRobotJoints' to which you pass in the robot, table and row as parameters:
updateRobotJoints(current,Table("GlobalTable1"),1);The user command code is:
Object current=param(1);
Table jointTab=param(2);
int row=param(3);
Map jointMap=current.jointMap;
Map jointInfo;
double newRotation;
for (int n=jointTab.numCols;n>0;n--){
newRotation=jointTab[row];
jointInfo=jointMap[jointTab.getColHeader(n)];
jointInfo.joint.rotation=(jointInfo.axisMask.as(Vec3)*newRotation)+jointInfo.refRotation.as(Vec3);
}The setup of the map has change too so that now the jointMap also contains a Map of joint information ('jointInfo') allowing dot notation to be used for the values as follows:
jointInfo.joint // the joint object in drawsurrogates
jointInfo.axisMask // the Vec3 defining the axis to apply the rotation to
jointInfo.refRotation // the stored rotation in the reference position
The setup script for the nested maps is then:
Object rob=Model.find("Robot1");
Object joint=drawsurrogate(rob).first.first;
Vec3 x=Vec3(1,0,0);
Vec3 y=Vec3(0,1,0);
Vec3 z=Vec3(0,0,1);
Map jointInfo;
Map jointMap;
Array jointAxes=[z,x,x,y,x,y];
Array jointNames=["Base","Shoulder","Elbow","Wrist1","Wrist2","Wrist3"];
for (int n=1;n<=jointAxes.length;n++){
jointInfo["joint"]=joint;
jointInfo["axisMask"]=jointAxes;
jointInfo["refRotation"]=joint.rotation;
jointMap[jointNames]=jointInfo.clone(); //Map of joint node, rotation vec3, static rotation state]
joint=joint.first;
}
rob.labels.assert("jointMap",jointMap); // for the first time
rob.jointMap=jointMap; // for subsequent times
test-robot-2_jl3.fsm