WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
MecanumDrivePoseEstimator3d.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 MecanumDriveOdometry3d. It is also intended to be an easy
26 * replacement for PoseEstimator, only requiring the addition of a standard
27 * deviation for Z and appropriate conversions between 2D and 3D versions of
28 * geometry classes. (See Pose3d(Pose2d), Rotation3d(Rotation2d),
29 * Translation3d(Translation2d), and Pose3d.ToPose2d().)
30 *
31 * Update() should be called every robot loop. If your loops are faster or
32 * slower than the default of 20 ms, then you should change the nominal delta
33 * time by specifying it in the constructor.
34 *
35 * AddVisionMeasurement() can be called as infrequently as you want; if you
36 * never call it, then this class will behave mostly like regular encoder
37 * odometry.
38 */
40 : public PoseEstimator3d<MecanumDriveWheelSpeeds,
41 MecanumDriveWheelPositions> {
42 public:
43 /**
44 * Constructs a MecanumDrivePoseEstimator3d with default standard deviations
45 * for the model and vision measurements.
46 *
47 * The default standard deviations of the model states are
48 * 0.1 meters for x, 0.1 meters for y, 0.1 meters for z, and 0.1 radians for
49 * angle. The default standard deviations of the vision measurements are 0.45
50 * meters for x, 0.45 meters for y, 0.45 meters for z, and 0.45 radians for
51 * angle.
52 *
53 * @param kinematics A correctly-configured kinematics object for your
54 * drivetrain.
55 * @param gyroAngle The current gyro angle.
56 * @param wheelPositions The distance measured by each wheel.
57 * @param initialPose The starting pose estimate.
58 */
60 const Rotation3d& gyroAngle,
61 const MecanumDriveWheelPositions& wheelPositions,
62 const Pose3d& initialPose);
63
64 /**
65 * Constructs a MecanumDrivePoseEstimator3d.
66 *
67 * @param kinematics A correctly-configured kinematics object for your
68 * drivetrain.
69 * @param gyroAngle The current gyro angle.
70 * @param wheelPositions The distance measured by each wheel.
71 * @param initialPose The starting pose estimate.
72 * @param stateStdDevs Standard deviations of the pose estimate (x position in
73 * meters, y position in meters, z position in meters, and angle in
74 * radians). Increase these numbers to trust your state estimate less.
75 * @param visionMeasurementStdDevs Standard deviations of the vision pose
76 * measurement (x position in meters, y position in meters, z position in
77 * meters, and angle in radians). Increase these numbers to trust the vision
78 * pose measurement less.
79 */
81 MecanumDriveKinematics& kinematics, const Rotation3d& gyroAngle,
82 const MecanumDriveWheelPositions& wheelPositions,
83 const Pose3d& initialPose, const wpi::array<double, 4>& stateStdDevs,
84 const wpi::array<double, 4>& visionMeasurementStdDevs);
85
86 private:
87 MecanumDriveOdometry3d m_odometryImpl;
88};
89
90} // 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 MecanumDriveOdometry3d.h:29
This class wraps Mecanum Drive Odometry to fuse latency-compensated vision measurements with mecanum ...
Definition MecanumDrivePoseEstimator3d.h:41
MecanumDrivePoseEstimator3d(MecanumDriveKinematics &kinematics, const Rotation3d &gyroAngle, const MecanumDriveWheelPositions &wheelPositions, const Pose3d &initialPose)
Constructs a MecanumDrivePoseEstimator3d with default standard deviations for the model and vision me...
MecanumDrivePoseEstimator3d(MecanumDriveKinematics &kinematics, const Rotation3d &gyroAngle, const MecanumDriveWheelPositions &wheelPositions, const Pose3d &initialPose, const wpi::array< double, 4 > &stateStdDevs, const wpi::array< double, 4 > &visionMeasurementStdDevs)
Constructs a MecanumDrivePoseEstimator3d.
Represents a 3D pose containing translational and rotational elements.
Definition Pose3d.h:28
This class wraps odometry to fuse latency-compensated vision measurements with encoder measurements.
Definition PoseEstimator3d.h:49
A rotation in a 3D coordinate frame represented by a quaternion.
Definition Rotation3d.h:29
This class is a wrapper around std::array that does compile time size checking.
Definition array.h:26
Definition CAN.h:11
Represents the wheel positions for a mecanum drive drivetrain.
Definition MecanumDriveWheelPositions.h:16