CTRE Phoenix 6 C++ 25.0.0-beta-4
Loading...
Searching...
No Matches
SwerveDrivetrainConstants.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) Cross The Road Electronics.  All rights reserved.
3 * License information can be found in CTRE_LICENSE.txt
4 * For support and suggestions contact support@ctr-electronics.com or file
5 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases
6 */
7#pragma once
8
10#include <optional>
11
12namespace ctre {
13namespace phoenix6 {
14namespace swerve {
15
16/**
17 * \brief Common constants for a swerve drivetrain.
18 */
20 constexpr SwerveDrivetrainConstants() = default;
21
22 /**
23 * \brief Name of the CAN bus the swerve drive is on. Possible CAN bus strings
24 * are:
25 *
26 * - empty string or "rio" for the native roboRIO CAN bus
27 * - CANivore name or serial number
28 * - "*" for any CANivore seen by the program
29 *
30 * Note that all devices must be on the same CAN bus.
31 */
32 std::string_view CANBusName = "rio";
33 /**
34 * \brief CAN ID of the Pigeon2 on the drivetrain.
35 */
36 int Pigeon2Id = 0;
37 /**
38 * \brief The configuration object to apply to the Pigeon2. This defaults to
39 * null. If this remains null, then the Pigeon2 will not be configured (and
40 * whatever configs are on it remain on it). If this is not null, the Pigeon2
41 * will be overwritten with these configs.
42 */
43 std::optional<configs::Pigeon2Configuration> Pigeon2Configs = std::nullopt;
44
45 /**
46 * \brief Modifies the CANBusName parameter and returns itself.
47 *
48 * Name of the CAN bus the swerve drive is on. Possible CAN bus strings are:
49 *
50 * - empty string or "rio" for the native roboRIO CAN bus
51 * - CANivore name or serial number
52 * - "*" for any CANivore seen by the program
53 *
54 * Note that all devices must be on the same CAN bus.
55 *
56 * \param newCANBusName Parameter to modify
57 * \returns this object
58 */
59 constexpr SwerveDrivetrainConstants &WithCANBusName(std::string_view newCANBusName)
60 {
61 this->CANBusName = newCANBusName;
62 return *this;
63 }
64
65 /**
66 * \brief Modifies the Pigeon2Id parameter and returns itself.
67 *
68 * CAN ID of the Pigeon2 on the drivetrain.
69 *
70 * \param newPigeon2Id Parameter to modify
71 * \returns this object
72 */
73 constexpr SwerveDrivetrainConstants &WithPigeon2Id(int newPigeon2Id)
74 {
75 this->Pigeon2Id = newPigeon2Id;
76 return *this;
77 }
78
79 /**
80 * \brief Modifies the Pigeon2Configs parameter and returns itself.
81 *
82 * The configuration object to apply to the Pigeon2. This defaults to null. If
83 * this remains null, then the Pigeon2 will not be configured (and whatever
84 * configs are on it remain on it). If this is not null, the Pigeon2 will be
85 * overwritten with these configs.
86 *
87 * \param newPigeon2Configs Parameter to modify
88 * \returns this object
89 */
90 #if __cpp_lib_optional >= 202106L || (defined(__APPLE__) && __cplusplus >= 202002L)
91 constexpr
92 #endif
93 SwerveDrivetrainConstants &WithPigeon2Configs(const std::optional<configs::Pigeon2Configuration>& newPigeon2Configs)
94 {
95 this->Pigeon2Configs = newPigeon2Configs;
96 return *this;
97 }
98
99};
100
101}
102}
103}
Definition StatusCodes.h:18
Common constants for a swerve drivetrain.
Definition SwerveDrivetrainConstants.hpp:19
int Pigeon2Id
CAN ID of the Pigeon2 on the drivetrain.
Definition SwerveDrivetrainConstants.hpp:36
SwerveDrivetrainConstants & WithPigeon2Configs(const std::optional< configs::Pigeon2Configuration > &newPigeon2Configs)
Modifies the Pigeon2Configs parameter and returns itself.
Definition SwerveDrivetrainConstants.hpp:93
std::string_view CANBusName
Name of the CAN bus the swerve drive is on.
Definition SwerveDrivetrainConstants.hpp:32
std::optional< configs::Pigeon2Configuration > Pigeon2Configs
The configuration object to apply to the Pigeon2.
Definition SwerveDrivetrainConstants.hpp:43
constexpr SwerveDrivetrainConstants & WithCANBusName(std::string_view newCANBusName)
Modifies the CANBusName parameter and returns itself.
Definition SwerveDrivetrainConstants.hpp:59
constexpr SwerveDrivetrainConstants & WithPigeon2Id(int newPigeon2Id)
Modifies the Pigeon2Id parameter and returns itself.
Definition SwerveDrivetrainConstants.hpp:73