WPILibC++ 2024.3.2
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
13#include "frc/geometry/Pose2d.h"
18#include "units/time.h"
19
20namespace frc {
21/**
22 * This class wraps Mecanum Drive Odometry to fuse latency-compensated
23 * vision measurements with mecanum drive encoder velocity measurements. It will
24 * correct for noisy measurements and encoder drift. It is intended to be an
25 * easy drop-in for MecanumDriveOdometry.
26 *
27 * Update() should be called every robot loop. If your loops are faster or
28 * slower than the default of 20 ms, then you should change the nominal delta
29 * time by specifying it in the constructor.
30 *
31 * AddVisionMeasurement() can be called as infrequently as you want; if you
32 * never call it, then this class will behave mostly like regular encoder
33 * odometry.
34 */
36 : public PoseEstimator<MecanumDriveWheelSpeeds,
37 MecanumDriveWheelPositions> {
38 public:
39 /**
40 * Constructs a MecanumDrivePoseEstimator with default standard deviations
41 * for the model and vision measurements.
42 *
43 * The default standard deviations of the model states are
44 * 0.1 meters for x, 0.1 meters for y, and 0.1 radians for heading.
45 * The default standard deviations of the vision measurements are
46 * 0.45 meters for x, 0.45 meters for y, and 0.45 radians for heading.
47 *
48 * @param kinematics A correctly-configured kinematics object for your
49 * drivetrain.
50 * @param gyroAngle The current gyro angle.
51 * @param wheelPositions The distance measured by each wheel.
52 * @param initialPose The starting pose estimate.
53 */
55 const Rotation2d& gyroAngle,
56 const MecanumDriveWheelPositions& wheelPositions,
57 const Pose2d& initialPose);
58
59 /**
60 * Constructs a MecanumDrivePoseEstimator.
61 *
62 * @param kinematics A correctly-configured kinematics object for your
63 * drivetrain.
64 * @param gyroAngle The current gyro angle.
65 * @param wheelPositions The distance measured by each wheel.
66 * @param initialPose The starting pose estimate.
67 * @param stateStdDevs Standard deviations of the pose estimate (x position in
68 * meters, y position in meters, and heading in radians). Increase these
69 * numbers to trust your state estimate less.
70 * @param visionMeasurementStdDevs Standard deviations of the vision pose
71 * measurement (x position in meters, y position in meters, and heading in
72 * radians). Increase these numbers to trust the vision pose measurement
73 * less.
74 */
76 MecanumDriveKinematics& kinematics, const Rotation2d& gyroAngle,
77 const MecanumDriveWheelPositions& wheelPositions,
78 const Pose2d& initialPose, const wpi::array<double, 3>& stateStdDevs,
79 const wpi::array<double, 3>& visionMeasurementStdDevs);
80
81 private:
82 MecanumDriveOdometry m_odometryImpl;
83};
84
85} // 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:37
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:23
This class wraps odometry to fuse latency-compensated vision measurements with encoder measurements.
Definition: PoseEstimator.h:38
A rotation in a 2D coordinate frame represented by a point on the unit circle (cosine and sine).
Definition: Rotation2d.h:23
Definition: AprilTagPoseEstimator.h:15
Represents the wheel positions for a mecanum drive drivetrain.
Definition: MecanumDriveWheelPositions.h:16