WPILibC++
2025.0.0-alpha-1-24-g6478ba6
TrajectoryUtil.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 <string>
8
#include <string_view>
9
10
#include <
wpi/SymbolExports.h
>
11
12
#include "
frc/trajectory/Trajectory.h
"
13
14
namespace
frc
{
15
/**
16
* Trajectory utilities.
17
*/
18
class
WPILIB_DLLEXPORT
TrajectoryUtil
{
19
public
:
20
TrajectoryUtil
() =
delete
;
21
22
/**
23
* Exports a Trajectory to a PathWeaver-style JSON file.
24
*
25
* @param trajectory the trajectory to export
26
* @param path the path of the file to export to
27
*/
28
static
void
ToPathweaverJson
(
const
Trajectory
& trajectory,
29
std::string_view
path);
30
/**
31
* Imports a Trajectory from a JSON file exported from PathWeaver.
32
*
33
* @param path The path of the json file to import from.
34
*
35
* @return The trajectory represented by the file.
36
*/
37
static
Trajectory
FromPathweaverJson
(
std::string_view
path);
38
39
/**
40
* Deserializes a Trajectory from JSON exported from PathWeaver.
41
*
42
* @param trajectory the trajectory to export
43
*
44
* @return the string containing the serialized JSON
45
*/
46
static
std::string
SerializeTrajectory
(
const
Trajectory
& trajectory);
47
48
/**
49
* Serializes a Trajectory to PathWeaver-style JSON.
50
*
51
* @param jsonStr the string containing the serialized JSON
52
*
53
* @return the trajectory represented by the JSON
54
*/
55
static
Trajectory
DeserializeTrajectory
(
std::string_view
jsonStr);
56
};
57
}
// namespace frc
SymbolExports.h
WPILIB_DLLEXPORT
#define WPILIB_DLLEXPORT
Definition:
SymbolExports.h:36
Trajectory.h
frc::Trajectory
Represents a time-parameterized trajectory.
Definition:
Trajectory.h:25
frc::TrajectoryUtil
Trajectory utilities.
Definition:
TrajectoryUtil.h:18
frc::TrajectoryUtil::SerializeTrajectory
static std::string SerializeTrajectory(const Trajectory &trajectory)
Deserializes a Trajectory from JSON exported from PathWeaver.
frc::TrajectoryUtil::ToPathweaverJson
static void ToPathweaverJson(const Trajectory &trajectory, std::string_view path)
Exports a Trajectory to a PathWeaver-style JSON file.
frc::TrajectoryUtil::TrajectoryUtil
TrajectoryUtil()=delete
frc::TrajectoryUtil::FromPathweaverJson
static Trajectory FromPathweaverJson(std::string_view path)
Imports a Trajectory from a JSON file exported from PathWeaver.
frc::TrajectoryUtil::DeserializeTrajectory
static Trajectory DeserializeTrajectory(std::string_view jsonStr)
Serializes a Trajectory to PathWeaver-style JSON.
frc
Definition:
AprilTagDetector_cv.h:11
string_view
basic_string_view< char > string_view
Definition:
base.h:601
frc
trajectory
TrajectoryUtil.h
Generated on Sun Jul 7 2024 13:45:43 for WPILibC++ by
1.9.4