WPILibC++ 2023.4.3-108-ge5452e3
MecanumDrivePoseEstimator.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <functional>
8
9#include <wpi/SymbolExports.h>
10#include <wpi/array.h>
11
12#include "frc/EigenCore.h"
14#include "frc/geometry/Pose2d.h"
19#include "units/time.h"
20
21namespace frc {
22/**
23 * This class wraps Mecanum Drive Odometry to fuse latency-compensated
24 * vision measurements with mecanum drive encoder velocity measurements. It will
25 * correct for noisy measurements and encoder drift. It is intended to be an
26 * easy drop-in for MecanumDriveOdometry.
27 *
28 * Update() should be called every robot loop. If your loops are faster or
29 * slower than the default of 20 ms, then you should change the nominal delta
30 * time by specifying it in the constructor.
31 *
32 * AddVisionMeasurement() can be called as infrequently as you want; if you
33 * never call it, then this class will behave mostly like regular encoder
34 * odometry.
35 */
37 : public PoseEstimator<MecanumDriveWheelSpeeds,
38 MecanumDriveWheelPositions> {
39 public:
40 /**
41 * Constructs a MecanumDrivePoseEstimator with default standard deviations
42 * for the model and vision measurements.
43 *
44 * The default standard deviations of the model states are
45 * 0.1 meters for x, 0.1 meters for y, and 0.1 radians for heading.
46 * The default standard deviations of the vision measurements are
47 * 0.45 meters for x, 0.45 meters for y, and 0.45 radians for heading.
48 *
49 * @param kinematics A correctly-configured kinematics object for your
50 * drivetrain.
51 * @param gyroAngle The current gyro angle.
52 * @param wheelPositions The distance measured by each wheel.
53 * @param initialPose The starting pose estimate.
54 */
56 const Rotation2d& gyroAngle,
57 const MecanumDriveWheelPositions& wheelPositions,
58 const Pose2d& initialPose);
59
60 /**
61 * Constructs a MecanumDrivePoseEstimator.
62 *
63 * @param kinematics A correctly-configured kinematics object for your
64 * drivetrain.
65 * @param gyroAngle The current gyro angle.
66 * @param wheelPositions The distance measured by each wheel.
67 * @param initialPose The starting pose estimate.
68 * @param stateStdDevs Standard deviations of the pose estimate (x position in
69 * meters, y position in meters, and heading in radians). Increase these
70 * numbers to trust your state estimate less.
71 * @param visionMeasurementStdDevs Standard deviations of the vision pose
72 * measurement (x position in meters, y position in meters, and heading in
73 * radians). Increase these numbers to trust the vision pose measurement
74 * less.
75 */
77 MecanumDriveKinematics& kinematics, const Rotation2d& gyroAngle,
78 const MecanumDriveWheelPositions& wheelPositions,
79 const Pose2d& initialPose, const wpi::array<double, 3>& stateStdDevs,
80 const wpi::array<double, 3>& visionMeasurementStdDevs);
81
82 private:
83 MecanumDriveOdometry m_odometryImpl;
84};
85
86} // namespace frc
#define WPILIB_DLLEXPORT
Definition: SymbolExports.h:36
Helper class that converts a chassis velocity (dx, dy, and dtheta components) into individual wheel s...
Definition: MecanumDriveKinematics.h:44
Class for mecanum drive odometry.
Definition: MecanumDriveOdometry.h:29
This class wraps Mecanum Drive Odometry to fuse latency-compensated vision measurements with mecanum ...
Definition: MecanumDrivePoseEstimator.h:38
MecanumDrivePoseEstimator(MecanumDriveKinematics &kinematics, const Rotation2d &gyroAngle, const MecanumDriveWheelPositions &wheelPositions, const Pose2d &initialPose)
Constructs a MecanumDrivePoseEstimator with default standard deviations for the model and vision meas...
MecanumDrivePoseEstimator(MecanumDriveKinematics &kinematics, const Rotation2d &gyroAngle, const MecanumDriveWheelPositions &wheelPositions, const Pose2d &initialPose, const wpi::array< double, 3 > &stateStdDevs, const wpi::array< double, 3 > &visionMeasurementStdDevs)
Constructs a MecanumDrivePoseEstimator.
Represents a 2D pose containing translational and rotational elements.
Definition: Pose2d.h:25
This class wraps odometry to fuse latency-compensated vision measurements with encoder measurements.
Definition: PoseEstimator.h:35
A rotation in a 2D coordinate frame represented by a point on the unit circle (cosine and sine).
Definition: Rotation2d.h:26
Definition: AprilTagPoseEstimator.h:15
Represents the wheel positions for a mecanum drive drivetrain.
Definition: MecanumDriveWheelPositions.h:16