CTRE Phoenix 6 C++ 26.70.0-alpha-2
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 The network the swerve drive is on. Note that all devices must be on
24 * the same CAN bus.
25 */
27 /**
28 * \brief CAN ID of the Pigeon2 on the drivetrain.
29 */
30 int Pigeon2Id = 0;
31 /**
32 * \brief The configuration object to apply to the Pigeon2. This defaults to
33 * null. If this remains null, then the Pigeon2 will not be configured (and
34 * whatever configs are on it remain on it). If this is not null, the Pigeon2
35 * will be overwritten with these configs.
36 */
37 std::optional<configs::Pigeon2Configuration> Pigeon2Configs = std::nullopt;
38
39 /**
40 * \brief Modifies the Network parameter and returns itself.
41 *
42 * The network the swerve drive is on. Note that all devices must be on the same
43 * CAN bus.
44 *
45 * \param newNetwork Parameter to modify
46 * \returns this object
47 */
49 {
50 this->Network = newNetwork;
51 return *this;
52 }
53
54 /**
55 * \brief Modifies the Pigeon2Id parameter and returns itself.
56 *
57 * CAN ID of the Pigeon2 on the drivetrain.
58 *
59 * \param newPigeon2Id Parameter to modify
60 * \returns this object
61 */
62 constexpr SwerveDrivetrainConstants &WithPigeon2Id(int newPigeon2Id)
63 {
64 this->Pigeon2Id = newPigeon2Id;
65 return *this;
66 }
67
68 /**
69 * \brief Modifies the Pigeon2Configs parameter and returns itself.
70 *
71 * The configuration object to apply to the Pigeon2. This defaults to null. If
72 * this remains null, then the Pigeon2 will not be configured (and whatever
73 * configs are on it remain on it). If this is not null, the Pigeon2 will be
74 * overwritten with these configs.
75 *
76 * \param newPigeon2Configs Parameter to modify
77 * \returns this object
78 */
79 constexpr SwerveDrivetrainConstants &WithPigeon2Configs(const std::optional<configs::Pigeon2Configuration>& newPigeon2Configs)
80 {
81 this->Pigeon2Configs = newPigeon2Configs;
82 return *this;
83 }
84
85};
86
87}
88}
89}
Class for getting information about an available CAN bus.
Definition CANBus.hpp:142
Definition SwerveModule.hpp:28
Definition ExternalFeedbackConfigs.hpp:16
Definition motor_constants.h:14
CANBus Network
The network the swerve drive is on.
Definition SwerveDrivetrainConstants.hpp:26
constexpr SwerveDrivetrainConstants & WithPigeon2Configs(const std::optional< configs::Pigeon2Configuration > &newPigeon2Configs)
Modifies the Pigeon2Configs parameter and returns itself.
Definition SwerveDrivetrainConstants.hpp:79
int Pigeon2Id
CAN ID of the Pigeon2 on the drivetrain.
Definition SwerveDrivetrainConstants.hpp:30
constexpr SwerveDrivetrainConstants & WithNetwork(CANBus newNetwork)
Modifies the Network parameter and returns itself.
Definition SwerveDrivetrainConstants.hpp:48
std::optional< configs::Pigeon2Configuration > Pigeon2Configs
The configuration object to apply to the Pigeon2.
Definition SwerveDrivetrainConstants.hpp:37
constexpr SwerveDrivetrainConstants & WithPigeon2Id(int newPigeon2Id)
Modifies the Pigeon2Id parameter and returns itself.
Definition SwerveDrivetrainConstants.hpp:62