blob: 84c34706cb8b226bd51738abe9de8062cbc842f5 [file] [log] [blame]
Brian Silvermanf7f267a2017-02-04 16:16:08 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008-2017. All Rights Reserved. */
3/* Open Source Software - may be modified and shared by FRC teams. The code */
4/* must be accompanied by the FIRST BSD license file in the root directory of */
5/* the project. */
6/*----------------------------------------------------------------------------*/
7
8#include "Jaguar.h"
9
10#include "LiveWindow/LiveWindow.h"
11
12using namespace frc;
13
14/**
15 * @param channel The PWM channel that the Jaguar is attached to.
16 */
17Jaguar::Jaguar(int channel) : SafePWM(channel) {
18 /*
19 * Input profile defined by Luminary Micro.
20 *
21 * Full reverse ranges from 0.671325ms to 0.6972211ms
22 * Proportional reverse ranges from 0.6972211ms to 1.4482078ms
23 * Neutral ranges from 1.4482078ms to 1.5517922ms
24 * Proportional forward ranges from 1.5517922ms to 2.3027789ms
25 * Full forward ranges from 2.3027789ms to 2.328675ms
26 */
27 SetBounds(2.31, 1.55, 1.507, 1.454, .697);
28 SetPeriodMultiplier(kPeriodMultiplier_1X);
29 SetRaw(m_centerPwm);
30
31 LiveWindow::GetInstance()->AddActuator("Jaguar", GetChannel(), this);
32}
33
34/**
35 * Set the PWM value.
36 *
37 * The PWM value is set using a range of -1.0 to 1.0, appropriately
38 * scaling the value for the FPGA.
39 *
40 * @param speed The speed value between -1.0 and 1.0 to set.
41 */
42void Jaguar::Set(double speed) { SetSpeed(speed); }
43
44/**
45 * Get the recently set value of the PWM.
46 *
47 * @return The most recently set value for the PWM between -1.0 and 1.0.
48 */
49double Jaguar::Get() const { return GetSpeed(); }
50
51/**
52 * Common interface for disabling a motor.
53 */
54void Jaguar::Disable() { SetRaw(kPwmDisabled); }
55
56/**
57 * Write out the PID value as seen in the PIDOutput base object.
58 *
59 * @param output Write out the PWM value as was found in the PIDController
60 */
61void Jaguar::PIDWrite(double output) { Set(output); }