Пример #1
0
	void UpdateDashboardStatus()
	{
		Dashboard &dashHigh = m_ds->GetHighPriorityDashboardPacker();
		dashHigh.AddCluster(); // PID (not used for now)
		dashHigh.AddDouble(0.0); // P
		dashHigh.AddDouble(0.0); // I
		dashHigh.AddDouble(0.0); // D
		dashHigh.FinalizeCluster();
		dashHigh.AddDouble(speedJag.GetSpeed()); // Current position
		dashHigh.AddDouble(speedJag.Get()); // Setpoint
		dashHigh.AddDouble(speedJag.GetOutputVoltage()); // Output Voltage
		dashHigh.Finalize();
	}
Пример #2
0
	void output (void)
	{
		REDRUM;
		if (IsAutonomous())
			driverOut->PrintfLine(DriverStationLCD::kUser_Line1, "blaarag");
		else if (IsOperatorControl())
		{	
			REDRUM;
		}
		outputCounter++;
					
					if (outputCounter % 30 == 0){
						REDRUM;
					driverOut->PrintfLine(DriverStationLCD::kUser_Line2, "Top Shooter RPM: %f",(float)LTop.GetSpeed());
					driverOut->PrintfLine(DriverStationLCD::kUser_Line3, "Bot Shooter RPM: %f",(float)LBot.GetSpeed());
			//		driverOut->PrintfLine(DriverStationLCD::kUser_Line6, "Pilot Z-Axis: %f",pilot.GetZ());
					
					}
					
					if (outputCounter % 60 == 0){
						REDRUM;
					driverOut->PrintfLine(DriverStationLCD::kUser_Line4, "Top CANJag Temp: %f Celcius",LTop.GetTemperature()*(9/5) + 32);
					driverOut->PrintfLine(DriverStationLCD::kUser_Line5, "Bot CANJag Temp: %f Celcius",LBot.GetTemperature()*(9/5) + 32);
				    outputCounter = 1;
					}
		driverOut->UpdateLCD();
	}//nom nom nom
Пример #3
0
    void RunWheels()
    {
//	uint32_t t0, t1, t2, t3;

	// schedule updates to avoid overloading CAN bus or CPU
	switch (report++) {
	case 12:		// 240 milliseconds
	    report = 0;		// reset counter
	case 0:
	    // Update PID parameters
	    double newP = SmartDashboard::GetNumber("Shooter P");
	    double newI = SmartDashboard::GetNumber("Shooter I");
	    double newD = SmartDashboard::GetNumber("Shooter D");
	    if (newP != kP || newI != kI || newD != kD) {
		kP = newP;
		kI = newI;
		kD = newD;
#ifdef HAVE_TOP_WHEEL
		if (topPID) {
#ifdef HAVE_TOP_CAN1
		    ; // topWheel1->SetPID( kP, kI, kD );
#endif
#ifdef HAVE_TOP_CAN2
		    topWheel2->SetPID( kP, kI, kD );
#endif
		}
#endif
#ifdef HAVE_BOTTOM_WHEEL
		if (bottomPID) {
#ifdef HAVE_BOTTOM_CAN1
		    ; // bottomWheel1->SetPID( kP, kI, kD );
#endif
#ifdef HAVE_BOTTOM_CAN2
		    bottomWheel2->SetPID( kP, kI, kD );
#endif
		}
#endif
	    }
	    break;

	case 4:			// 80 milliseconds
#ifdef HAVE_TOP_WHEEL
//t0 = GetFPGATime();
	    // Get top output voltage, current and measured speed
#ifdef HAVE_TOP_CAN1
	    double topI1 = topWheel1->GetOutputCurrent();
#endif
#ifdef HAVE_TOP_CAN2
	    double topI2 = topWheel2->GetOutputCurrent();
	    topJagSpeed  = topWheel2->GetSpeed(); 
#endif
//t1 = GetFPGATime();
	    topTachSpeed = topTach->PIDGet();

#ifdef HAVE_TOP_CAN1
	    // stupid floating point!
	    Log(LOG_CURRENT, 1, (uint32_t)(topI1 * 1000 + 0.5));
#endif
#ifdef HAVE_TOP_CAN2
	    Log(LOG_CURRENT, 2, (uint32_t)(topI2 * 1000 + 0.5));
	    Log(LOG_SPEED,   2, (uint32_t)(topJagSpeed + 0.5));
#endif

	    // Send values to SmartDashboard
#ifdef HAVE_TOP_CAN1
	    SmartDashboard::PutNumber("Top Current 1", topI1);
#endif
#ifdef HAVE_TOP_CAN2
	    SmartDashboard::PutNumber("Top Current 2", topI2);
	    SmartDashboard::PutNumber("Top Jag      ", topJagSpeed);
#endif
	    SmartDashboard::PutNumber("Top Tach     ", topTachSpeed);

	    // Get setpoint
	    topSpeed = SmartDashboard::GetNumber("Top Set      ");
//t2 = GetFPGATime();

	    if (spinFastNow) {
		if (topPID) {
		    if (topJagSpeed < topSpeed * vbusThreshold) {
			topPID = false;
			// below threshold: switch both motors to full output
#ifdef HAVE_TOP_CAN1
			jagVbus(topWheel1, maxOutput);
			Log(LOG_MODE, 1, 1);
#endif
#ifdef HAVE_TOP_PWM1
			topWheel1->Set(maxOutput);
			Log(LOG_MODE, 1, 1);
#endif
#ifdef HAVE_TOP_CAN2
			jagVbus(topWheel2, maxOutput);
			Log(LOG_MODE, 2, 1);
#endif
		    } else {
			; // above threshold: run motor 1 off, PID on motor 2
#ifdef HAVE_TOP_CAN1
			topWheel1->Set(0.0);
#endif
#ifdef HAVE_TOP_PWM1
			topWheel1->Set(0.0);
#endif
#ifdef HAVE_TOP_CAN2
			topWheel2->Set(topSpeed);
#endif
		    }
		} else {
		    if (topJagSpeed >= topSpeed * pidThreshold) {
			; // above threshold: switch motor 1 off, motor 2 PID
			topPID = true;
#ifdef HAVE_TOP_CAN1
			topWheel1->Set(0.0);
#endif
#ifdef HAVE_TOP_PWM1
			topWheel1->Set(0.0);
#endif
#ifdef HAVE_TOP_CAN2
			jagPID(topWheel2, topSpeed);
			Log(LOG_MODE, 2, 2);
#endif
		    } else {
			; // below threshold: run both motors at full output
#ifdef HAVE_TOP_CAN1
			topWheel1->Set(maxOutput);
#endif
#ifdef HAVE_TOP_PWM1
			topWheel1->Set(maxOutput);
#endif
#ifdef HAVE_TOP_CAN2
			topWheel2->Set(maxOutput);
#endif
		    }
		}
//t3 = GetFPGATime();
//printf("%10u %10u %10u\n", (uint32_t)(t1 - t0), (uint32_t)(t2 - t1), (uint32_t)(t3 - t2));
	    }
#endif

	    break;

	case 8:		// 160 milliseconds
#ifdef HAVE_BOTTOM_WHEEL
	    // Get bottom output voltage, current and measured speed
//t0 = GetFPGATime();
#ifdef HAVE_BOTTOM_CAN1
	    double bottomI1 = bottomWheel1->GetOutputCurrent();
#endif
#ifdef HAVE_BOTTOM_CAN2
	    double bottomI2 = bottomWheel2->GetOutputCurrent();
	    bottomJagSpeed  = bottomWheel2->GetSpeed();
#endif
//t1 = GetFPGATime();
	    bottomTachSpeed = bottomTach->PIDGet();

#ifdef HAVE_BOTTOM_CAN1
	    Log(LOG_CURRENT, 3, (uint32_t)(bottomI1 * 1000 + 0.5));
#endif
#ifdef HAVE_BOTTOM_CAN2
	    Log(LOG_CURRENT, 4, (uint32_t)(bottomI2 * 1000 + 0.5));
	    Log(LOG_SPEED,   4, (uint32_t)(bottomJagSpeed + 0.5));
#endif

	    // Send values to SmartDashboard
#ifdef HAVE_BOTTOM_CAN1
	    SmartDashboard::PutNumber("Bottom Current 1", bottomI1);
#endif
#ifdef HAVE_BOTTOM_CAN2
	    SmartDashboard::PutNumber("Bottom Current 2", bottomI2);
	    SmartDashboard::PutNumber("Bottom Jag      ", bottomJagSpeed);
#endif
	    SmartDashboard::PutNumber("Bottom Tach     ", bottomTachSpeed);

	    // Get setpoint
	    bottomSpeed = SmartDashboard::GetNumber("Bottom Set      ");
//t2 = GetFPGATime();

	    if (spinFastNow) {
		if (bottomPID) {
		    if (bottomJagSpeed < bottomSpeed * vbusThreshold) {
			bottomPID = false;
			// below threshold: switch both motors to full output
#ifdef HAVE_BOTTOM_CAN1
			jagVbus(bottomWheel1, maxOutput);
			Log(LOG_MODE, 3, 1);
#endif
#ifdef HAVE_BOTTOM_PWM1
			bottomWheel1->Set(maxOutput);
			Log(LOG_MODE, 3, 1);
#endif
#ifdef HAVE_BOTTOM_CAN2
			jagVbus(bottomWheel2, maxOutput);
			Log(LOG_MODE, 4, 1);
#endif
		    } else {
			; // above threshold: run motor 1 off, PID on motor 2
#ifdef HAVE_BOTTOM_CAN1
			bottomWheel1->Set(0.0);
#endif
#ifdef HAVE_BOTTOM_PWM1
			bottomWheel1->Set(0.0);
#endif
#ifdef HAVE_BOTTOM_CAN2
			bottomWheel2->Set(bottomSpeed);
#endif
		    }
		} else {
		    if (bottomJagSpeed >= bottomSpeed * pidThreshold) {
			// above threshold: switch motor 1 off, motor 2 PID
			bottomPID = true;
#ifdef HAVE_BOTTOM_CAN1
			bottomWheel1->Set(0.0);
#endif
#ifdef HAVE_BOTTOM_PWM1
			bottomWheel1->Set(0.0);
#endif
#ifdef HAVE_BOTTOM_CAN2
			jagPID(bottomWheel2, bottomSpeed);
			Log(LOG_MODE, 4, 2);
#endif
		    } else {
			; // below threshold: run both motors at full output
#ifdef HAVE_BOTTOM_CAN1
			bottomWheel1->Set(maxOutput);
#endif
#ifdef HAVE_BOTTOM_PWM1
			bottomWheel1->Set(maxOutput);
#endif
#ifdef HAVE_BOTTOM_CAN2
			bottomWheel2->Set(maxOutput);
#endif
		    }
		}
//t3 = GetFPGATime();
//printf("%10u %10u %10u\n", (uint32_t)(t1 - t0), (uint32_t)(t2 - t1), (uint32_t)(t3 - t2));
	    }
#endif
	    break;
	}
    }