001package com.ctre.phoenix.sensors; 002 003import com.ctre.phoenix.ErrorCode; 004import com.ctre.phoenix.platform.DeviceType; 005import com.ctre.phoenix.platform.PlatformJNI; 006 007public class BasePigeonSimCollection{ 008 private int _id; 009 private DeviceType _type; 010 011 public BasePigeonSimCollection(BasePigeon pigeon, boolean isRibbonCable){ 012 _id = pigeon.getDeviceID(); 013 _type = isRibbonCable ? DeviceType.RibbonPigeonIMU : DeviceType.PigeonIMU; 014 } 015 016 /** 017 * Sets the simulated input heading position of the Pigeon IMU. 018 * <p> 019 * The Pigeon IMU integrates the delta between each new raw heading value and uses 020 * this to calculate the true reported yaw and fused heading. 021 * <p> 022 * When using the WPI Sim GUI, you will notice a readonly 'yaw' and 023 * settable 'RawHeading'. The readonly signal is the emulated yaw 024 * which will match self-test in Tuner and the hardware API. Changes to 025 * 'RawHeading' will be integrated into the emulated yaw. This way 026 * a simulator can modify the heading without overriding your 027 * hardware API calls for home-ing your sensor. 028 * <p> 029 * Inputs to this function over time should be continuous, 030 * as user calls of setYaw() or setFusedHeading() 031 * will be accounted for in the calculation. 032 * 033 * @param newHeading the new input heading in degrees 034 * 035 * @return error code 036 */ 037 public ErrorCode setRawHeading(double newHeading) 038 { 039 int retval = PlatformJNI.JNI_SimSetPhysicsInput(_type.value, _id, "HeadingRaw", newHeading); 040 return ErrorCode.valueOf(retval); 041 } 042 043 /** 044 * Adds to the simulated heading of the Pigeon IMU 045 * 046 * @param dHeading the change in heading in degrees 047 * 048 * @return error code 049 */ 050 public ErrorCode addHeading(double dHeading) 051 { 052 int retval = PlatformJNI.JNI_SimSetPhysicsInput(_type.value, _id, "HeadingAdd", dHeading); 053 return ErrorCode.valueOf(retval); 054 } 055}