WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
ComputerVisionUtil.hpp
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
10
11namespace wpi::math {
12
13/**
14 * Returns the robot's pose in the field coordinate system given an object's
15 * field-relative pose, the transformation from the camera's pose to the
16 * object's pose (obtained via computer vision), and the transformation from the
17 * robot's pose to the camera's pose.
18 *
19 * The object could be a target or a fiducial marker.
20 *
21 * @param objectInField An object's field-relative pose.
22 * @param cameraToObject The transformation from the camera's pose to the
23 * object's pose. This comes from computer vision.
24 * @param robotToCamera The transformation from the robot's pose to the camera's
25 * pose. This can either be a constant for a rigidly mounted camera, or
26 * variable if the camera is mounted to a turret. If the camera was mounted 3
27 * inches in front of the "origin" (usually physical center) of the robot,
28 * this would be wpi::math::Transform3d{3_in, 0_in, 0_in,
29 * wpi::math::Rotation3d{}}.
30 * @return The robot's field-relative pose.
31 */
34 const wpi::math::Pose3d& objectInField,
35 const wpi::math::Transform3d& cameraToObject,
36 const wpi::math::Transform3d& robotToCamera) {
37 const auto objectToCamera = cameraToObject.Inverse();
38 const auto cameraToRobot = robotToCamera.Inverse();
39 return objectInField + objectToCamera + cameraToRobot;
40}
41
42} // namespace wpi::math
#define WPILIB_DLLEXPORT
Definition SymbolExports.hpp:36
Represents a 3D pose containing translational and rotational elements.
Definition Pose3d.hpp:28
Represents a transformation for a Pose3d in the pose's frame.
Definition Transform3d.hpp:23
constexpr Transform3d Inverse() const
Invert the transformation.
Definition Transform3d.hpp:152
Definition LinearSystem.hpp:20
WPILIB_DLLEXPORT constexpr wpi::math::Pose3d ObjectToRobotPose(const wpi::math::Pose3d &objectInField, const wpi::math::Transform3d &cameraToObject, const wpi::math::Transform3d &robotToCamera)
Returns the robot's pose in the field coordinate system given an object's field-relative pose,...
Definition ComputerVisionUtil.hpp:33