001/* 002 * Copyright (C) Cross The Road Electronics. All rights reserved. 003 * License information can be found in CTRE_LICENSE.txt 004 * For support and suggestions contact support@ctr-electronics.com or file 005 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases 006 */ 007package com.ctre.phoenix6.mechanisms.swerve; 008 009import com.ctre.phoenix6.configs.Pigeon2Configuration; 010 011/** 012 * Common constants for a swerve drivetrain. 013 */ 014public class SwerveDrivetrainConstants { 015 /** CAN ID of the Pigeon2 on the drivetrain. */ 016 public int Pigeon2Id = 0; 017 /** 018 * Name of the CAN bus the swerve drive is on. 019 * Possible CAN bus strings are: 020 * <ul> 021 * <li>"rio" for the native roboRIO CAN bus 022 * <li>CANivore name or serial number 023 * <li>"*" for any CANivore seen by the program 024 * </ul> 025 */ 026 public String CANbusName = "rio"; 027 /** 028 * The Pigeon2 configuration object to apply to 029 * the Pigeon2. This defaults to null. If this remains 030 * null, then the Pigeon2 will not be configured 031 * (and whatever configs are on it remain on it). 032 * If this is non-null, the Pigeon2 will be 033 * overwritten with these configs. 034 */ 035 public Pigeon2Configuration Pigeon2Configs = null; 036 037 /** 038 * Sets the CAN ID of the Pigeon2 on the drivetrain. 039 * 040 * @param id CAN ID of the Pigeon2 on the drivetrain 041 * @return this object 042 */ 043 public SwerveDrivetrainConstants withPigeon2Id(int id) { 044 this.Pigeon2Id = id; 045 return this; 046 } 047 048 /** 049 * Sets the name of the CAN bus the swerve drive is on. 050 * Possible CAN bus strings are: 051 * <ul> 052 * <li>"rio" for the native roboRIO CAN bus 053 * <li>CANivore name or serial number 054 * <li>"*" for any CANivore seen by the program 055 * </ul> 056 * 057 * @param name Name of the CAN bus the swerve drive is on 058 * @return this object 059 */ 060 public SwerveDrivetrainConstants withCANbusName(String name) { 061 this.CANbusName = name; 062 return this; 063 } 064 065 /** 066 * The Pigeon2 configuration object to apply to 067 * the Pigeon2. This defaults to null. If this remains 068 * null, then the Pigeon2 will not be configured 069 * (and whatever configs are on it remain on it). 070 * If this is non-null, the Pigeon2 will be 071 * overwritten with these configs. 072 * 073 * @param configs The configs to apply to the Pigeon2 074 * @return this object 075 */ 076 public SwerveDrivetrainConstants withPigeon2Configs(Pigeon2Configuration configs) { 077 this.Pigeon2Configs = configs; 078 return this; 079 } 080}