RoboManipal / Libraries

Set of personal libraries used by RoboManipal
Apache License 2.0
0 stars 0 forks source link

RazorIMU_9DOF library needed #5

Closed TheProjectsGuy closed 5 years ago

TheProjectsGuy commented 6 years ago

IMU: Razor 9DoF IMU GitHub reference: Here

Must Haves

TheProjectsGuy commented 6 years ago

The debugger is left out. Planning to incorporate it in a separate library altogether. For testing, we can use the standard Serial.print technique.

TheProjectsGuy commented 6 years ago

Testing will begin soon, the basic structure has already been testing with Arduino Mega and Arduino Uno.

TheProjectsGuy commented 5 years ago

Test 1

Getting lag in transmission of bytes. Might be a problem in parsing function RazorIMU_9DOF::GrabData(), might have to hardcode reading pointers till a more effective solution is met.

Trace

[0] > Debugger enabled
[0] > DebuggerSerial attached
[1] > Debugger set to SENSOR_FEED
[2 DEBUG] $IMU_9DOF$ Sending a '#f' to IMU serial
[7 DEBUG] $IMU_9DOF$ Waiting for IMU to respond
[11 DEBUG] $IMU_9DOF$ Waiting for IMU to respond
[1018 DEBUG] $IMU_9DOF$ Values Y: -84.03 P: 32.10 R: 1.19
[1020 DEBUG] $IMU_9DOF$ Full scale PRY values: 32.10 1.19 275.97 
[1025 DEBUG] $IMU_9DOF$ Sending a '#f' to IMU serial
[1029 DEBUG] $IMU_9DOF$ Waiting for IMU to respond
[1033 DEBUG] $IMU_9DOF$ Waiting for IMU to respond
[1038 DEBUG] $IMU_9DOF$ Waiting for IMU to respond
[2044 DEBUG] $IMU_9DOF$ Values Y: -83.78 P: 32.07 R: 1.14
[2046 DEBUG] $IMU_9DOF$ Full scale PRY values: 32.07 1.14 276.22 

Error might be in the readString function (direct read gives the following)

1024
Received: #YPR=-92.79,8.53,-1.48
2051
Received: #YPR=-92.82,8.56,-1.47

Change it to readStringUntil('\n') and the delay is considerably reduced

2611 $ Received: #YPR=-92.17,8.15,-1.28
2631 $ Received: #YPR=-92.19,8.15,-1.30

Changed the entire function code to (pseudocode given below)

  Serial1.println("#f");
  Serial.print(millis());
  Serial.print(" $ ");
  while(!Serial1.available()) {
  }
  Serial.print(millis());
  Serial.print(" $ ");
  if (Serial1.available()) {
    Serial.print("Received: ");
    Serial1.readStringUntil('=');   // #YPR= done
    float yaw = Serial1.readStringUntil(',').toFloat();
    float pitch = Serial1.readStringUntil(',').toFloat();
    float roll = Serial1.readStringUntil('\n').toFloat();
    Serial.print(yaw);
    Serial.print(' ');
    Serial.print(pitch);
    Serial.print(' ');
    Serial.println(roll);
  }

Fixed issue. Trace

[0] > Debugger enabled
[0] > DebuggerSerial attached
[1] > Debugger set to SENSOR_FEED
[2 DEBUG] $IMU_9DOF$ Sending a '#f' to IMU serial
[26 DEBUG] $IMU_9DOF$ Values Y: -107.03 P: 17.25 R: -0.35
[27 DEBUG] $IMU_9DOF$ Full scale RPY values: 359.65 17.25 252.97 
YAW = 252.97
[33 DEBUG] $IMU_9DOF$ Sending a '#f' to IMU serial
[67 DEBUG] $IMU_9DOF$ Values Y: -106.94 P: 17.28 R: -0.43
[68 DEBUG] $IMU_9DOF$ Full scale RPY values: 359.57 17.28 253.06 
YAW = 253.06
[74 DEBUG] $IMU_9DOF$ Sending a '#f' to IMU serial
[108 DEBUG] $IMU_9DOF$ Values Y: -106.91 P: 17.20 R: -0.37
[110 DEBUG] $IMU_9DOF$ Full scale RPY values: 359.63 17.20 253.09 
YAW = 253.09

Patch fixes

TheProjectsGuy commented 5 years ago

Tests have been finished, this issue is officially resolved