Use FPGA Time instead of wall clock time for odometry (#1996)

This commit is contained in:
Prateek Machiraju
2019-10-27 10:57:35 -04:00
committed by Peter Johnson
parent d4430b765e
commit 8e333c0aad
6 changed files with 13 additions and 12 deletions

View File

@@ -11,6 +11,7 @@
#include "DifferentialDriveKinematics.h"
#include "frc/geometry/Pose2d.h"
#include "frc2/Timer.h"
namespace frc {
/**
@@ -86,9 +87,7 @@ class DifferentialDriveOdometry {
*/
const Pose2d& Update(const Rotation2d& angle,
const DifferentialDriveWheelSpeeds& wheelSpeeds) {
const auto now = std::chrono::system_clock::now().time_since_epoch();
units::second_t time{now};
return UpdateWithTime(time, angle, wheelSpeeds);
return UpdateWithTime(frc2::Timer::GetFPGATimestamp(), angle, wheelSpeeds);
}
private:

View File

@@ -12,6 +12,7 @@
#include "frc/geometry/Pose2d.h"
#include "frc/kinematics/MecanumDriveKinematics.h"
#include "frc/kinematics/MecanumDriveWheelSpeeds.h"
#include "frc2/Timer.h"
namespace frc {
@@ -84,9 +85,7 @@ class MecanumDriveOdometry {
*/
const Pose2d& Update(const Rotation2d& angle,
MecanumDriveWheelSpeeds wheelSpeeds) {
const auto now = std::chrono::system_clock::now().time_since_epoch();
units::second_t time{now};
return UpdateWithTime(time, angle, wheelSpeeds);
return UpdateWithTime(frc2::Timer::GetFPGATimestamp(), angle, wheelSpeeds);
}
private:

View File

@@ -16,6 +16,7 @@
#include "SwerveDriveKinematics.h"
#include "SwerveModuleState.h"
#include "frc/geometry/Pose2d.h"
#include "frc2/Timer.h"
namespace frc {
@@ -95,9 +96,8 @@ class SwerveDriveOdometry {
template <typename... ModuleStates>
const Pose2d& Update(const Rotation2d& angle,
ModuleStates&&... moduleStates) {
const auto now = std::chrono::system_clock::now().time_since_epoch();
units::second_t time{now};
return UpdateWithTime(time, angle, moduleStates...);
return UpdateWithTime(frc2::Timer::GetFPGATimestamp(), angle,
moduleStates...);
}
private: