Log in

View Full Version : Possiblity of using a few trig functions


baop858
17-01-2008, 23:11
Do you guys think there will be an problems if I used like 4 trig function on 28.6 ms loop? If I put the trig functions in the spin function functions would it work better? Would using a look up table for sin cos trig and arctan use up a lot of space?

Kevin Watson
17-01-2008, 23:36
Do you guys think there will be an problems if I used like 4 trig function on 28.6 ms loop?This won't be a problem if you aren't doing anything else time consuming.

-Kevin

comphappy
17-01-2008, 23:53
Do you guys think there will be an problems if I used like 4 trig function on 28.6 ms loop? If I put the trig functions in the spin function functions would it work better? Would using a look up table for sin cos trig and arctan use up a lot of space?
I would say that for most things actual trig functions are overkill, a look up table will good enough. As for space, it depends on how many values you need to calculate, and how many places you need them.

kaszeta
18-01-2008, 10:23
Do you guys think there will be an problems if I used like 4 trig function on 28.6 ms loop? If I put the trig functions in the spin function functions would it work better? Would using a look up table for sin cos trig and arctan use up a lot of space?

Team 95 had done quite a few test bots using field coordinates, where every time through the loop we'd do calls to sin(), cos(), abs(), and atan2(), all while using shaft encoders and the gyro, and it's never been an issue. I wouldn't get carried away, however.

comphappy
18-01-2008, 23:55
I would not expect abs to be take very many processors cycles, could be written as such,
int abs (int num)
{
if(num<0)
{
num=(-1)*num;
}
return(num);
}