CTRE Phoenix 6 C++ 26.0.0-beta-1
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 * - "rio" for the native roboRIO CAN bus
27 * - CANivore name or serial number
28 * - SocketCAN interface (non-FRC Linux only)
29 * - "*" for any CANivore seen by the program
30 * - empty string (default) to select the default for the system:
31 * - "rio" on roboRIO
32 * - "can0" on Linux
33 * - "*" on Windows
34 *
35 * Note that all devices must be on the same CAN bus.
36 */
37 std::string_view CANBusName = "";
38 /**
39 * \brief CAN ID of the Pigeon2 on the drivetrain.
40 */
41 int Pigeon2Id = 0;
42 /**
43 * \brief The configuration object to apply to the Pigeon2. This defaults to
44 * null. If this remains null, then the Pigeon2 will not be configured (and
45 * whatever configs are on it remain on it). If this is not null, the Pigeon2
46 * will be overwritten with these configs.
47 */
48 std::optional<configs::Pigeon2Configuration> Pigeon2Configs = std::nullopt;
49
50 /**
51 * \brief Modifies the CANBusName parameter and returns itself.
52 *
53 * Name of the CAN bus the swerve drive is on. Possible CAN bus strings are:
54 *
55 * - "rio" for the native roboRIO CAN bus
56 * - CANivore name or serial number
57 * - SocketCAN interface (non-FRC Linux only)
58 * - "*" for any CANivore seen by the program
59 * - empty string (default) to select the default for the system:
60 * - "rio" on roboRIO
61 * - "can0" on Linux
62 * - "*" on Windows
63 *
64 * Note that all devices must be on the same CAN bus.
65 *
66 * \param newCANBusName Parameter to modify
67 * \returns this object
68 */
69 constexpr SwerveDrivetrainConstants &WithCANBusName(std::string_view newCANBusName)
70 {
71 this->CANBusName = newCANBusName;
72 return *this;
73 }
74
75 /**
76 * \brief Modifies the Pigeon2Id parameter and returns itself.
77 *
78 * CAN ID of the Pigeon2 on the drivetrain.
79 *
80 * \param newPigeon2Id Parameter to modify
81 * \returns this object
82 */
83 constexpr SwerveDrivetrainConstants &WithPigeon2Id(int newPigeon2Id)
84 {
85 this->Pigeon2Id = newPigeon2Id;
86 return *this;
87 }
88
89 /**
90 * \brief Modifies the Pigeon2Configs parameter and returns itself.
91 *
92 * The configuration object to apply to the Pigeon2. This defaults to null. If
93 * this remains null, then the Pigeon2 will not be configured (and whatever
94 * configs are on it remain on it). If this is not null, the Pigeon2 will be
95 * overwritten with these configs.
96 *
97 * \param newPigeon2Configs Parameter to modify
98 * \returns this object
99 */
100 constexpr SwerveDrivetrainConstants &WithPigeon2Configs(const std::optional<configs::Pigeon2Configuration>& newPigeon2Configs)
101 {
102 this->Pigeon2Configs = newPigeon2Configs;
103 return *this;
104 }
105
106};
107
108}
109}
110}
Definition motor_constants.h:14
Common constants for a swerve drivetrain.
Definition SwerveDrivetrainConstants.hpp:19
constexpr SwerveDrivetrainConstants & WithPigeon2Configs(const std::optional< configs::Pigeon2Configuration > &newPigeon2Configs)
Modifies the Pigeon2Configs parameter and returns itself.
Definition SwerveDrivetrainConstants.hpp:100
int Pigeon2Id
CAN ID of the Pigeon2 on the drivetrain.
Definition SwerveDrivetrainConstants.hpp:41
std::string_view CANBusName
Name of the CAN bus the swerve drive is on.
Definition SwerveDrivetrainConstants.hpp:37
std::optional< configs::Pigeon2Configuration > Pigeon2Configs
The configuration object to apply to the Pigeon2.
Definition SwerveDrivetrainConstants.hpp:48
constexpr SwerveDrivetrainConstants & WithCANBusName(std::string_view newCANBusName)
Modifies the CANBusName parameter and returns itself.
Definition SwerveDrivetrainConstants.hpp:69
constexpr SwerveDrivetrainConstants & WithPigeon2Id(int newPigeon2Id)
Modifies the Pigeon2Id parameter and returns itself.
Definition SwerveDrivetrainConstants.hpp:83