QUB-ASL / bzzz

Quadcopter with ESP32 and RaspberryPi
MIT License
7 stars 1 forks source link

Initial angular velocities #44

Closed jamie-54 closed 1 year ago

jamie-54 commented 1 year ago

Main Changes

Added initialAngularVelocity in main.cpp which is then subtract from the measuredAngularVelocity to give the angularVelocityCorrected which is used for the controlAction

Associated Issues

alphaville commented 1 year ago

@jamie-54 This looks good - have you noticed whether this has an effect on the behaviour of the quadcopter?

alphaville commented 1 year ago

@jamie-54 Would the following work?

void initAngularVelocity()
{
  float angularVelocityTemp[3] = {0};
  int numInitAngularVelocity = 10;

  for (int i = 0; i < numInitAngularVelocity; i++)
  {
    ahrs.update();
    ahrs.angularVelocity(angularVelocityTemp);
    initialAngularVelocity[0] += angularVelocityTemp[0];
    initialAngularVelocity[1] += angularVelocityTemp[1];
    initialAngularVelocity[2] += angularVelocityTemp[2];
  }
  initialAngularVelocity[0] /= (float)numInitAngularVelocity;
  initialAngularVelocity[1] /= (float)numInitAngularVelocity;
  initialAngularVelocity[2] /= (float)numInitAngularVelocity;
}
jamie-54 commented 1 year ago

@jamie-54 Would the following work?

void initAngularVelocity()
{
  float angularVelocityTemp[3] = {0};
  int numInitAngularVelocity = 10;

  for (int i = 0; i < numInitAngularVelocity; i++)
  {
    ahrs.update();
    ahrs.angularVelocity(angularVelocityTemp);
    initialAngularVelocity[0] += angularVelocityTemp[0];
    initialAngularVelocity[1] += angularVelocityTemp[1];
    initialAngularVelocity[2] += angularVelocityTemp[2];
  }
  initialAngularVelocity[0] /= (float)numInitAngularVelocity;
  initialAngularVelocity[1] /= (float)numInitAngularVelocity;
  initialAngularVelocity[2] /= (float)numInitAngularVelocity;
}

I don't see any reason for this not to work, I'll test it on hardware tomorrow and then update. Then I'll check PR #45