Compare commits
No commits in common. "86549f30935d0ac31a6f30bb6dee73e1e10fb79f" and "9483d84ad5d32b281103aa82951925070b4ceae7" have entirely different histories.
86549f3093
...
9483d84ad5
5 changed files with 11 additions and 30 deletions
|
@ -29,7 +29,7 @@ LSM6::LSM6(void)
|
|||
bool LSM6::checkForNewData(void)
|
||||
{
|
||||
bool retVal = false;
|
||||
if(getStatus() & 0x02)
|
||||
if(getStatus() & 0x01)
|
||||
{
|
||||
read();
|
||||
|
||||
|
@ -228,7 +228,7 @@ void LSM6::enableDefault(void)
|
|||
{
|
||||
// Set the gyro full scale and data rate
|
||||
setFullScaleGyro(GYRO_FS245);
|
||||
setGyroDataOutputRate(ODR104);
|
||||
setGyroDataOutputRate(ODR13);
|
||||
|
||||
// Set the accelerometer full scale and data rate
|
||||
setFullScaleAcc(ACC_FS2);
|
||||
|
|
|
@ -141,12 +141,6 @@ public:
|
|||
|
||||
vector<float> updateGyroBias(void)
|
||||
{
|
||||
if (initialMeasurement) {
|
||||
gyroBias.z = g.z;
|
||||
initialMeasurement = false;
|
||||
}
|
||||
float retain = (0.98);
|
||||
gyroBias.z = g.z * (1- retain) + gyroBias.z * retain;
|
||||
/**
|
||||
* TODO: add a low-pass filter to update the bias
|
||||
*/
|
||||
|
@ -175,7 +169,6 @@ public:
|
|||
// float estimatedPitchAngle = 0;
|
||||
// vector<float> eulerAngles;
|
||||
vector<float> gyroBias;
|
||||
bool initialMeasurement = true;
|
||||
|
||||
/* We make Robot a friend to avoid all the setters and getters. */
|
||||
friend class Robot;
|
||||
|
|
|
@ -25,10 +25,10 @@ protected:
|
|||
enum CTRL_MODE : uint8_t {CTRL_DIRECT, CTRL_SPEED};
|
||||
volatile CTRL_MODE ctrlMode = CTRL_DIRECT;
|
||||
|
||||
float Kp = 6.00; // proportional to error
|
||||
float Ki = 0.05;
|
||||
float Kp = 2.50; // proportional to error
|
||||
float Ki = 0.03;
|
||||
float Kd = 0;
|
||||
float Kf = 4.50; // proportional to setpoint
|
||||
float Kf = 3.00; // proportional to setpoint
|
||||
int16_t C = 22; // constant added to effort
|
||||
|
||||
// Used to keep track of the target speed, in counts / interval.
|
||||
|
|
|
@ -76,16 +76,16 @@ void Robot::HandleKeyCode(int16_t keyCode)
|
|||
switch(keyCode)
|
||||
{
|
||||
case UP_ARROW:
|
||||
chassis.SetTwist(15, 0);
|
||||
chassis.SetTwist(5, 0);
|
||||
break;
|
||||
case RIGHT_ARROW:
|
||||
chassis.SetTwist(0, -1.25);
|
||||
chassis.SetTwist(0, -0.25);
|
||||
break;
|
||||
case DOWN_ARROW:
|
||||
chassis.SetTwist(-15, 0);
|
||||
chassis.SetTwist(-5, 0);
|
||||
break;
|
||||
case LEFT_ARROW:
|
||||
chassis.SetTwist(0, 1.25);
|
||||
chassis.SetTwist(0, 0.25);
|
||||
break;
|
||||
case ENTER_SAVE:
|
||||
chassis.SetTwist(0, 0);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include "robot.h"
|
||||
#include <IRdecoder.h>
|
||||
#include <limits.h>
|
||||
|
||||
void Robot::InitializeRobot(void)
|
||||
{
|
||||
|
@ -80,22 +79,11 @@ void Robot::HandleOrientationUpdate(void)
|
|||
|
||||
else // update orientation
|
||||
{
|
||||
float z_rot = ((float)imu.g.z - imu.gyroBias.z) / (float) INT_MAX;
|
||||
z_rot /= 104;
|
||||
z_rot *= 245;
|
||||
eulerAngles.z += z_rot;
|
||||
// TODO: update the orientation
|
||||
}
|
||||
|
||||
#ifdef __IMU_DEBUG__
|
||||
Serial.print(imu.gyroBias.z);
|
||||
Serial.print('\t');
|
||||
Serial.print(eulerAngles.z);
|
||||
Serial.print('\t');
|
||||
//Serial.print(imu.g.x);
|
||||
//Serial.print('\t');
|
||||
//Serial.print(imu.g.y);
|
||||
//Serial.print('\t');
|
||||
Serial.println(imu.g.z);
|
||||
Serial.println(eulerAngles.z);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue