mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
Use FPGA Time instead of wall clock time for odometry (#1996)
This commit is contained in:
committed by
Peter Johnson
parent
d4430b765e
commit
8e333c0aad
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user