WPILibC++ 2024.3.2
CoordinateSystem.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 <wpi/SymbolExports.h>
8
10#include "frc/geometry/Pose3d.h"
13
14namespace frc {
15
16/**
17 * A helper class that converts Pose3d objects between different standard
18 * coordinate frames.
19 */
21 public:
22 /**
23 * Constructs a coordinate system with the given cardinal directions for each
24 * axis.
25 *
26 * @param positiveX The cardinal direction of the positive x-axis.
27 * @param positiveY The cardinal direction of the positive y-axis.
28 * @param positiveZ The cardinal direction of the positive z-axis.
29 * @throws std::domain_error if the coordinate system isn't special orthogonal
30 */
32 const CoordinateAxis& positiveY,
33 const CoordinateAxis& positiveZ);
34
39
40 /**
41 * Returns an instance of the North-West-Up (NWU) coordinate system.
42 *
43 * The +X axis is north, the +Y axis is west, and the +Z axis is up.
44 */
45 static const CoordinateSystem& NWU();
46
47 /**
48 * Returns an instance of the East-Down-North (EDN) coordinate system.
49 *
50 * The +X axis is east, the +Y axis is down, and the +Z axis is north.
51 */
52 static const CoordinateSystem& EDN();
53
54 /**
55 * Returns an instance of the NED coordinate system.
56 *
57 * The +X axis is north, the +Y axis is east, and the +Z axis is down.
58 */
59 static const CoordinateSystem& NED();
60
61 /**
62 * Converts the given translation from one coordinate system to another.
63 *
64 * @param translation The translation to convert.
65 * @param from The coordinate system the translation starts in.
66 * @param to The coordinate system to which to convert.
67 * @return The given translation in the desired coordinate system.
68 */
69 static Translation3d Convert(const Translation3d& translation,
71 const CoordinateSystem& to);
72
73 /**
74 * Converts the given rotation from one coordinate system to another.
75 *
76 * @param rotation The rotation to convert.
77 * @param from The coordinate system the rotation starts in.
78 * @param to The coordinate system to which to convert.
79 * @return The given rotation in the desired coordinate system.
80 */
81 static Rotation3d Convert(const Rotation3d& rotation,
83 const CoordinateSystem& to);
84
85 /**
86 * Converts the given pose from one coordinate system to another.
87 *
88 * @param pose The pose to convert.
89 * @param from The coordinate system the pose starts in.
90 * @param to The coordinate system to which to convert.
91 * @return The given pose in the desired coordinate system.
92 */
93 static Pose3d Convert(const Pose3d& pose, const CoordinateSystem& from,
94 const CoordinateSystem& to);
95
96 /**
97 * Converts the given transform from one coordinate system to another.
98 *
99 * @param transform The transform to convert.
100 * @param from The coordinate system the transform starts in.
101 * @param to The coordinate system to which to convert.
102 * @return The given transform in the desired coordinate system.
103 */
104 static Transform3d Convert(const Transform3d& transform,
105 const CoordinateSystem& from,
106 const CoordinateSystem& to);
107
108 private:
109 // Rotation from this coordinate system to NWU coordinate system
110 Rotation3d m_rotation;
111};
112
113} // namespace frc
#define WPILIB_DLLEXPORT
Definition: SymbolExports.h:36
and restrictions which apply to each piece of software is included later in this file and or inside of the individual applicable source files The disclaimer of warranty in the WPILib license above applies to all code in and nothing in any of the other licenses gives permission to use the names of FIRST nor the names of the WPILib contributors to endorse or promote products derived from this software The following pieces of software have additional or alternate and or Google Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *Neither the name of Google Inc nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY OR CONSEQUENTIAL WHETHER IN STRICT OR EVEN IF ADVISED OF THE POSSIBILITY OF SUCH January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based or other modifications as a an original work of authorship For the purposes of this Derivative Works shall not include works that remain separable from
Definition: ThirdPartyNotices.txt:128
A class representing a coordinate system axis within the NWU coordinate system.
Definition: CoordinateAxis.h:19
A helper class that converts Pose3d objects between different standard coordinate frames.
Definition: CoordinateSystem.h:20
CoordinateSystem & operator=(CoordinateSystem &&)=default
static Pose3d Convert(const Pose3d &pose, const CoordinateSystem &from, const CoordinateSystem &to)
Converts the given pose from one coordinate system to another.
static const CoordinateSystem & NED()
Returns an instance of the NED coordinate system.
CoordinateSystem(const CoordinateSystem &)=default
CoordinateSystem & operator=(const CoordinateSystem &)=default
static Translation3d Convert(const Translation3d &translation, const CoordinateSystem &from, const CoordinateSystem &to)
Converts the given translation from one coordinate system to another.
static const CoordinateSystem & EDN()
Returns an instance of the East-Down-North (EDN) coordinate system.
CoordinateSystem(CoordinateSystem &&)=default
static Transform3d Convert(const Transform3d &transform, const CoordinateSystem &from, const CoordinateSystem &to)
Converts the given transform from one coordinate system to another.
CoordinateSystem(const CoordinateAxis &positiveX, const CoordinateAxis &positiveY, const CoordinateAxis &positiveZ)
Constructs a coordinate system with the given cardinal directions for each axis.
static Rotation3d Convert(const Rotation3d &rotation, const CoordinateSystem &from, const CoordinateSystem &to)
Converts the given rotation from one coordinate system to another.
static const CoordinateSystem & NWU()
Returns an instance of the North-West-Up (NWU) coordinate system.
Represents a 3D pose containing translational and rotational elements.
Definition: Pose3d.h:21
A rotation in a 3D coordinate frame represented by a quaternion.
Definition: Rotation3d.h:20
Represents a transformation for a Pose3d in the pose's frame.
Definition: Transform3d.h:18
Represents a translation in 3D space.
Definition: Translation3d.h:25
Definition: AprilTagPoseEstimator.h:15