blob: 148f62929f38ab948390b11d2cf950e9d409dee0 [file] [log] [blame]
Brian Silverman26e4e522015-12-17 01:56:40 -05001/*----------------------------------------------------------------------------*/
Brian Silverman1a675112016-02-20 20:42:49 -05002/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
Brian Silverman26e4e522015-12-17 01:56:40 -05003/* Open Source Software - may be modified and shared by FRC teams. The code */
Brian Silverman1a675112016-02-20 20:42:49 -05004/* must be accompanied by the FIRST BSD license file in the root directory of */
5/* the project. */
Brian Silverman26e4e522015-12-17 01:56:40 -05006/*----------------------------------------------------------------------------*/
7
8
9#include "Jaguar.h"
10//#include "NetworkCommunication/UsageReporting.h"
11#include "LiveWindow/LiveWindow.h"
12
13/**
14 * @param channel The PWM channel that the Jaguar is attached to.
15 */
16Jaguar::Jaguar(uint32_t channel) : SafePWM(channel)
17{
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 * @param syncGroup Unused interface.
42 */
43void Jaguar::Set(float speed, uint8_t syncGroup)
44{
45 SetSpeed(speed);
46}
47
48/**
49 * Get the recently set value of the PWM.
50 *
51 * @return The most recently set value for the PWM between -1.0 and 1.0.
52 */
53float Jaguar::Get() const
54{
55 return GetSpeed();
56}
57
58/**
59 * Common interface for disabling a motor.
60 */
61void Jaguar::Disable()
62{
63 SetRaw(kPwmDisabled);
64}
65
66/**
67 * Write out the PID value as seen in the PIDOutput base object.
68 *
69 * @param output Write out the PWM value as was found in the PIDController
70 */
71void Jaguar::PIDWrite(float output)
72{
73 Set(output);
74}