|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: RoboRIO red comm light, not accepting code?
Commenting out the auto code I had added fixed the red comm light. Does anyone mind reading through the code to see what might be causing the error?
Code:
void AutonomousInit()
{
//gyro->Reset();
}
void AutonomousPeriodic()
{
/*
SmartDashboard::PutNumber("Gyro Angle:", Angle);
if (automode == 1)
{
gyro->GetAngle();
{
if (Angle == 90)
{
robottime = false;
} else {
robottime = true;
}
}
if(robottime == true)
{
robot->Drive(0,-1);
}
if (robottime == false)
{
robot->Drive(0,-1);
}
}
if (automode == 2)
{
gyro->GetAngle();
if (Angle == 45)
{
robottime = false;
} else {
robottime = true;
}
if (robottime == true)
{
robot->Drive(0, -.5);
}
if (robottime == false)
{
robot->Drive(0,0);
}
}
*/
}
|
|
#2
|
|||
|
|||
|
Re: RoboRIO red comm light, not accepting code?
I'd wager that either robot or gyro is an uninitialized pointer.
|
|
#3
|
||||
|
||||
|
Re: RoboRIO red comm light, not accepting code?
Quote:
Code:
#include "WPILib.h"
class Robot: public IterativeRobot
{
private:
//Initializing livewindow
LiveWindow *lw;
//Initializing stick
Joystick *stick;
//Initializing the Chassis parts
Talon *kFrontLeftMotor;
Talon *kFrontRightMotor;
RobotDrive *robot;
Relay *Fan;
DoubleSolenoid *shifter;
Encoder *ChassisEnc;
Encoder *OtherEnc;
//Initializing the values for Cheesy Drive
float Rotation;
float Acceleration;
float rightMultiplier;
float leftMultiplier;
double automode;
Gyro *gyro;
bool robottime;
double Angle;
void RobotInit()
{
SmartDashboard::init();
lw = LiveWindow::GetInstance();
stick = new Joystick(0);
kFrontLeftMotor = new Talon(0);
kFrontRightMotor = new Talon(1);
robot = new RobotDrive(kFrontRightMotor, kFrontLeftMotor);
Fan = new Relay (3);
/* Setting the shifter as a DoubleSolenoid
* Because we're using both pistons off of
* one Double Solenoid
*/
shifter = new DoubleSolenoid (0,1);
ChassisEnc = new Encoder (0,1, false, Encoder::EncodingType::k4X);
OtherEnc= new Encoder (8,9, false, Encoder::EncodingType::k4X);
//Setting it so the fan is off by default
Fan->Set(Relay::kOff);
//Setting the Rotation and Accel values
Rotation = stick->GetRawAxis(1);
Acceleration = stick->GetRawAxis(3);
/*Setting the multipliers
* so that they don't allow
* a robot to go full forward
* while going full turn
*/
rightMultiplier = Rotation + Acceleration;
leftMultiplier = Rotation - Acceleration;
//Setting the shifter to Low Gear
shifter->Set(DoubleSolenoid::kReverse);
robot->SetInvertedMotor(RobotDrive::kFrontLeftMotor, true);
robot->SetInvertedMotor(RobotDrive::kFrontRightMotor, true);
ChassisEnc->SetDistancePerPulse(11.04);
OtherEnc->SetDistancePerPulse(11.04);
/*gyro = new Gyro (2);
Angle = gyro->GetAngle();
if (stick->GetRawButton(1))
{
automode = 1;
}
if (stick->GetRawButton(2))
|
|
#4
|
|||
|
|||
|
Re: RoboRIO red comm light, not accepting code?
The gyro constructor is commented out in the code you just posted, and your gyro appears to be on a channel that won't work. It needs to be on Channels 0 or 1.
|
|
#5
|
||||
|
||||
|
Re: RoboRIO red comm light, not accepting code?
Yeah, it was commented out after deploying, along with the auto code. Confused about the second sentence, doesn't the gyro have four ports it can plug into? Sorry for slow replies BTW, school WiFi does not let me post on chief Delphi, other than starting threads.
|
|
#6
|
|||
|
|||
|
Re: RoboRIO red comm light, not accepting code?
Quote:
See Gyro: http://first.wpi.edu/FRC/roborio/rel...classGyro.html And AnalogInput kAccumulatorChannels : http://first.wpi.edu/FRC/roborio/rel...alogInput.html Last edited by RufflesRidge : 01-02-2015 at 23:10. |
|
#7
|
||||
|
||||
|
Re: RoboRIO red comm light, not accepting code?
Try looking at the logs on the Dashboard. Usually they'll give you an error.
|
|
#8
|
||||
|
||||
|
Re: RoboRIO red comm light, not accepting code?
Changing gyro port to 1 fixed it! Thanks. The only thing I can't figure out is how to have multiple auto modes without using the selectable chooser. It seems that only works with command based robot?
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|