Saturday, 11 October 2014

Calibrating the Arm

In the previous posts we talked about how we applied Inverse Kinematics and kinematic analysis of the mentor arm. As mentioned the arm consists with Potentiometers and DC motors and with the POTs we get a feedback on the angle and movement direction. In this post we will be talking on calibrating the arm. 

Indeed the reading from the POTs are consistent. And we don't have a control circuit to receive accurate readings. We are passing each POT readings through a digital low pass filter so it filters out the high frequency noise. Also there is a threshold value for pot readings (+/- 10) to avoid the overshoot. 

In the mentor arm there are physical limits to avoid gears getting damaged physically. In the code we will limiting the movement of each arm respect to the limits of the leap motion and including these physical limits. Also in the using the IK formulae calculated angles, will go to infinity if the distance of the palm and the leap origin is greater than the total length of Top arm and bot arm which is 31.5cm. So if the function "jointangles"outputs "NaN" (Not a Number - infinity) we ignore them.

if(theta2<=170 && theta2>=10){ //leap motion limits
moveBase(theta2,baseValue);
}
else stopBase();
if(!isNaN(angle2) && !isNaN(angle3)){ //if the angles are valid
if(angle2>=10 && angle2<=150){ //leap motion limits
moveShoulder(angle2,shoulderValue);
}
else stopShoulder();
if(angle3>=55 && angle3<=160){ //leap motion limits
moverElbow(angle3,elbowValue);
}
else stopElbow();
}
else{
motorStop();
console.log("joint angles NAN value detected");
}
view raw armcalib.js hosted with ❤ by GitHub
function filter(values){
var smoothing = 1;
var value = values[0]; // start with the first input
for (var i=1, len=values.length; i<len; ++i){
var currentValue = values[i];
value += (currentValue - value) / smoothing;
values[i] = Math.round(value);
}
var sum = 0;
for(var i = 0; i < values.length; i++){
sum += parseInt(values[i], 10);
}
var avg = sum/values.length;
return avg;
}
view raw lowpass.js hosted with ❤ by GitHub

No comments:

Post a Comment