Go to Post A robot is never "complete" - [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 24-01-2015, 16:02
Shaffer Shaffer is offline
Registered User
FRC #4610
 
Join Date: Jan 2015
Location: Bastrop, TX
Posts: 3
Shaffer is an unknown quantity at this point
Robot won't drive. Help with "command based" programming

Here's our code, including our subsystem (cassie), our command (dothedrive), and our Robot file. It just won't drive no matter what we do. We have one joystick and mecanum drive.

public class cassie extends Subsystem
{

public SpeedController leftfront = RobotMap.cassieleftfront;
public SpeedController rightfront = RobotMap.cassierightfront;
public SpeedController leftrear = RobotMap.cassieleftrear;
public SpeedController rightrear = RobotMap.cassierightrear;
public RobotDrive wholecassie = RobotMap.cassiewholecassie;


public void initDefaultCommand()
{

}

public void takeJoyStickInput(Joystick joy1)
{
wholecassie.mecanumDrive_Cartesian(joy1.getRawAxis (1), joy1.getRawAxis(2), joy1.getRawAxis(0),0);

}

public void stop()
{
wholecassie.mecanumDrive_Cartesian(0, 0, 0,0);
}

}


public class dothedrive extends Command
{

public dothedrive()
{

requires(Robot.cassie);
}


protected void initialize()
{
}

protected void execute()
{
Robot.cassie.takeJoyStickInput(Robot.oi.getSidewin der());
}


protected boolean isFinished()
{
return false;
}

protected void end()
{
Robot.cassie.stop();

}


protected void interrupted()
{
}
}



public class Robot extends IterativeRobot
{

Command autonomousCommand;

public static OI oi;

public static cassie cassie;
public static lift lift;
public static grip grip;
public static vision vision;

public void robotInit()
{
RobotMap.init();

cassie = new cassie();
lift = new lift();
grip = new grip();
vision = new vision();


oi = new OI();
autonomousCommand = new AutonomousCommand();
}

public void disabledInit()
{
}

public void disabledPeriodic()
{
Scheduler.getInstance().run();
}

public void autonomousInit()
{
if (autonomousCommand != null) autonomousCommand.start();
}

public void autonomousPeriodic()
{
Scheduler.getInstance().run();
}

public void teleopInit() {

if (autonomousCommand != null) autonomousCommand.cancel();

}

public void teleopPeriodic()
{
Scheduler.getInstance().run();
wholecassie.dothedrive(); //this is the line that I'm confused on

}

public void testPeriodic()
{
LiveWindow.run();
}
Reply With Quote
  #2   Spotlight this post!  
Unread 24-01-2015, 17:52
Jalerre's Avatar
Jalerre Jalerre is offline
Registered User
FRC #4965 (FIRE)
Team Role: Alumni
 
Join Date: Apr 2014
Rookie Year: 2013
Location: Anderson, SC
Posts: 147
Jalerre is on a distinguished road
Re: Robot won't drive. Help with "command based" programming

I believed the line you are concerned about should be
Code:
Scheduler.getInstance().add(teleopCommand);
Substitute teleopCommand with the drive command that you want to run. That command should be instantiated in robotInit. Also the line should be in teleopInit.

Last edited by Jalerre : 24-01-2015 at 17:54.
Reply With Quote
  #3   Spotlight this post!  
Unread 24-01-2015, 21:07
Camilo86's Avatar
Camilo86 Camilo86 is offline
Registered User
AKA: camilo
FRC #0125 (Nutrons)
Team Role: Programmer
 
Join Date: Jun 2013
Rookie Year: 2012
Location: Boston
Posts: 21
Camilo86 is a glorious beacon of lightCamilo86 is a glorious beacon of lightCamilo86 is a glorious beacon of lightCamilo86 is a glorious beacon of lightCamilo86 is a glorious beacon of lightCamilo86 is a glorious beacon of light
Re: Robot won't drive. Help with "command based" programming

If you were to make the command dothedrive the default command for the cassie subsystem, you wouldn't have to specifically call it in the Robot class as long as you have an object of the subsystem there. You can do this by adding this line inside your initDefaultCommand() inside your cassie subsystem

Code:
setDefaultCommand(new dothedrive());
It is best to add a default command inside your subsystem than calling all the commands from the Robot class

Last edited by Camilo86 : 24-01-2015 at 21:18.
Reply With Quote
  #4   Spotlight this post!  
Unread 25-01-2015, 13:32
Shaffer Shaffer is offline
Registered User
FRC #4610
 
Join Date: Jan 2015
Location: Bastrop, TX
Posts: 3
Shaffer is an unknown quantity at this point
Re: Robot won't drive. Help with "command based" programming

Thank you! I will try these solutions.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 22:24.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi