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.phoenixpro.sim; 008 009import com.ctre.phoenix6.StatusCode; 010import com.ctre.phoenixpro.hardware.core.CorePigeon2; 011import com.ctre.phoenixpro.hardware.Pigeon2; 012import com.ctre.phoenix6.jni.PlatformJNI; 013 014/** 015 * Class to control the state of a simulated {@link Pigeon2}. 016 * 017 * @deprecated Classes in the phoenixpro package will be removed in 2024. 018 * Users should instead use classes from the phoenix6 package. 019 */ 020@Deprecated(forRemoval = true) 021public class Pigeon2SimState { 022 private final DeviceType kDevType = DeviceType.PRO_Pigeon2Type; 023 024 private final int _id; 025 026 /** 027 * Creates an object to control the state of the given {@link Pigeon2}. 028 * 029 * @param device 030 * Device to which this simulation state is attached 031 * 032 * @deprecated Classes in the phoenixpro package will be removed in 2024. 033 * Users should instead use classes from the phoenix6 package. 034 */ 035 @Deprecated(forRemoval = true) 036 public Pigeon2SimState(CorePigeon2 device) { 037 _id = device.getDeviceID(); 038 } 039 040 /** 041 * Sets the simulated supply voltage of the Pigeon2. 042 * <p> 043 * The minimum allowed supply voltage is 4 V - values below this 044 * will be promoted to 4 V. 045 * 046 * @param volts 047 * The supply voltage in Volts 048 * @return Status code 049 */ 050 public StatusCode setSupplyVoltage(double volts) { 051 return StatusCode.valueOf(PlatformJNI.JNI_SimSetPhysicsInput(kDevType.value, _id, "SupplyVoltage", volts)); 052 } 053 /** 054 * Sets the simulated raw yaw of the Pigeon2. 055 * <p> 056 * Inputs to this function over time should be continuous, as user calls of {@link Pigeon2#setYaw} will be accounted for in the callee. 057 * <p> 058 * The Pigeon2 integrates this to calculate the true reported yaw. 059 * <p> 060 * When using the WPI Sim GUI, you will notice a readonly {@code yaw} and settable {@code rawYawInput}. 061 * The readonly signal is the emulated yaw which will match self-test in Tuner and the hardware API. 062 * Changes to {@code rawYawInput} will be integrated into the emulated yaw. 063 * This way a simulator can modify the yaw without overriding hardware API calls for home-ing the sensor. 064 * 065 * @param deg 066 * The yaw in degrees 067 * @return Status code 068 */ 069 public StatusCode setRawYaw(double deg) { 070 return StatusCode.valueOf(PlatformJNI.JNI_SimSetPhysicsInput(kDevType.value, _id, "RawYaw", deg)); 071 } 072 /** 073 * Adds to the simulated yaw of the Pigeon2. 074 * 075 * @param dDeg 076 * The change in yaw in degrees 077 * @return Status code 078 */ 079 public StatusCode addYaw(double dDeg) { 080 return StatusCode.valueOf(PlatformJNI.JNI_SimSetPhysicsInput(kDevType.value, _id, "AddYaw", dDeg)); 081 } 082 /** 083 * Sets the simulated pitch of the Pigeon2. 084 * 085 * @param deg 086 * The pitch in degrees 087 * @return Status code 088 */ 089 public StatusCode setPitch(double deg) { 090 return StatusCode.valueOf(PlatformJNI.JNI_SimSetPhysicsInput(kDevType.value, _id, "Pitch", deg)); 091 } 092 /** 093 * Sets the simulated roll of the Pigeon2. 094 * 095 * @param deg 096 * The roll in degrees 097 * @return Status code 098 */ 099 public StatusCode setRoll(double deg) { 100 return StatusCode.valueOf(PlatformJNI.JNI_SimSetPhysicsInput(kDevType.value, _id, "Roll", deg)); 101 } 102}