so I am testing some odom and I have some values printed to my terminal. The first value is the x value, the second is the y value and the third is the theta value (in radians). Here I have a sample of the outputs (this is not at the beggining of the algorithm). For some reason, one of the lines has 4 values and this line makes all of the values jump, ruining the accuracy. I bolded the line with two ** on each side. Any ideas on why this could be happening. (I am not couting anywhere else in the program)
17.0009 53.2492 0.967411
17.2584 53.6229 0.967411
17.5357 54.0253 0.967411
17.8169 54.4038 0.964918
**17.8169 54.555 69.9531 0.782905**
31.0555 69.9531 0.782905
31.105 70.0023 0.782905
31.1783 70.0523 0.780411
31.1783 70.0523 0.780411```
Would you be willing to post your code so we can better help you?
2 Likes
Well the code is kind of all over the place becuase I have a bunch of different header files but I’ll try to summarize what I’m doing. So I’m using 5225A’s algorithm in a position tracking function that I have tasked in main. Here is my print statement inside my position tracking function:
positionArray[ODOM_X] = position.x;
positionArray[ODOM_Y] = position.y;
positionArray[ODOM_THETA] = position.a;
cout << positionArray[ODOM_X] << " " << positionArray[ODOM_Y] << " " <<positionArray[ODOM_THETA] <<endl;
task::sleep(10);
I made the “ODOM_Y” stuff an enum class. And I have a movement function which works fine except for this weird jump thing
Buffer overflow perhaps, try slowing down the loop (ie. longer delay)
12 Likes
The encoders have been known to spew some garbage on program start - try delaying a few hundred ms at the beginning of the program before starting your odom loop.
6 Likes