WPILibC++ 2024.3.2
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
13
14namespace frc {
15/**
16 * Trajectory utilities.
17 */
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 */
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 */
56};
57} // namespace frc
#define WPILIB_DLLEXPORT
Definition: SymbolExports.h:36
Represents a time-parameterized trajectory.
Definition: Trajectory.h:25
Trajectory utilities.
Definition: TrajectoryUtil.h:18
static std::string SerializeTrajectory(const Trajectory &trajectory)
Deserializes a Trajectory from JSON exported from PathWeaver.
static void ToPathweaverJson(const Trajectory &trajectory, std::string_view path)
Exports a Trajectory to a PathWeaver-style JSON file.
static Trajectory FromPathweaverJson(std::string_view path)
Imports a Trajectory from a JSON file exported from PathWeaver.
static Trajectory DeserializeTrajectory(std::string_view jsonStr)
Serializes a Trajectory to PathWeaver-style JSON.
basic_string_view< char > string_view
Definition: core.h:501
Definition: AprilTagPoseEstimator.h:15