blob: fab109d5782fd379ea13f4a797f43f8182762c8c [file] [log] [blame]
Brian Silverman26e4e522015-12-17 01:56:40 -05001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008. 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 $(WIND_BASE)/WPILib. */
5/*----------------------------------------------------------------------------*/
6
7
8#include "Jaguar.h"
9//#include "NetworkCommunication/UsageReporting.h"
10#include "LiveWindow/LiveWindow.h"
11
12/**
13 * @param channel The PWM channel that the Jaguar is attached to.
14 */
15Jaguar::Jaguar(uint32_t channel) : SafePWM(channel)
16{
17 /*
18 * Input profile defined by Luminary Micro.
19 *
20 * Full reverse ranges from 0.671325ms to 0.6972211ms
21 * Proportional reverse ranges from 0.6972211ms to 1.4482078ms
22 * Neutral ranges from 1.4482078ms to 1.5517922ms
23 * Proportional forward ranges from 1.5517922ms to 2.3027789ms
24 * Full forward ranges from 2.3027789ms to 2.328675ms
25 */
26 SetBounds(2.31, 1.55, 1.507, 1.454, .697);
27 SetPeriodMultiplier(kPeriodMultiplier_1X);
28 SetRaw(m_centerPwm);
29
30 LiveWindow::GetInstance()->AddActuator("Jaguar", GetChannel(), this);
31}
32
33/**
34 * Set the PWM value.
35 *
36 * The PWM value is set using a range of -1.0 to 1.0, appropriately
37 * scaling the value for the FPGA.
38 *
39 * @param speed The speed value between -1.0 and 1.0 to set.
40 * @param syncGroup Unused interface.
41 */
42void Jaguar::Set(float speed, uint8_t syncGroup)
43{
44 SetSpeed(speed);
45}
46
47/**
48 * Get the recently set value of the PWM.
49 *
50 * @return The most recently set value for the PWM between -1.0 and 1.0.
51 */
52float Jaguar::Get() const
53{
54 return GetSpeed();
55}
56
57/**
58 * Common interface for disabling a motor.
59 */
60void Jaguar::Disable()
61{
62 SetRaw(kPwmDisabled);
63}
64
65/**
66 * Write out the PID value as seen in the PIDOutput base object.
67 *
68 * @param output Write out the PWM value as was found in the PIDController
69 */
70void Jaguar::PIDWrite(float output)
71{
72 Set(output);
73}