USFirst.org
follow us on twitter
like us on facebookMNFTC.org
Bookmark and Share

Thanks

The team members of FRC Team 2220 would like to give a big thanks to all of the Sponsors, Mentors and Parents that make having this team possible.

Thank you!

Team Login



Collector.cpp Create PDF Send to Printer Email this Article
Written by TarinB   
Saturday, February 13 2010 16:36

#include "WPILib.h"

#include <iostream.h>

#include "math.h"

#include "BTCollector.h"

#include "BTRobot.h"

 

BTCollector::BTCollector(void)

{

collMotor = new Jaguar(PORTS::COLLECTOR_MOTOR);

jamLimit = new DigitalInput(PORTS::COLLECTOR_JAM_LIMIT);

collMotor->Set(0.0);

lastLimitChangeTime = GetClock();

lastLimitPosition = false;

}

 

void BTCollector::Enable(BTAutonomous *btauto)

{

enabled = true;

float actualCollSpeed = 0.0;

int ramp = 0;

collectorJammed = false;

while(ramp <= 100)

{

actualCollSpeed += 0.01;

collMotor->Set(actualCollSpeed);

ramp += 1;

}

}

 

void BTCollector::Reverse(void)

{

enabled = true;

collMotor->Set(COLLECTOR_FAST_REVERSE);

}

 

void BTCollector::Disable(void)

{

enabled = false;

collMotor->Set(0.0);

}

 

void BTCollector::DetectJam(void)

{

if (jamLimit->Get() != lastLimitPosition)

{

lastLimitChangeTime = GetClock();

}

lastLimitPosition = jamLimit->Get();

printf("Limit Position = %d\n", jamLimit->Get());

if (((GetClock() - lastLimitChangeTime) > COLL_LIMIT_TIMEOUT) && (enabled))

{

Disable();

enabled = true;

printf("COLLECTOR JAMMED!\n");

collectorJammed = true;

}

else

collectorJammed = false;

}

 

 

 

 

 

 

 

 
Lockheed Martin
Valid XHTML 1.0 Transitional Valid CSS!
Blanda
Blanda
Copyright © 2012 Eagan Robotics. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.