Go to Post It will be really cool if it works, sad if if doesn't. We got our fingers crossed! - falconmaster [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 30-01-2013, 21:20
adanmoran adanmoran is offline
Registered User
FRC #2809 (Kbotics)
Team Role: Coach
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Kingston, ON
Posts: 4
adanmoran is an unknown quantity at this point
Calling Joysticks from Command Group

My team is trying to make a Velocity-controlled Drive Train using PID systems; what we've done is created two separate PID subsystems and controllers, one for the Left Motor/Encoder and one for the Right Motor/Encoder. We then created two PID-Commands, one for the Left Side and one for the Right Side. These commands are called from a Command Group called TankDrive; the purpose is to call our Xbox axis values from the Command Group and pass them to the commands, so we can easily use the Group on non-test robots.

We plan to extend this to Arcade Drive, which is why we chose this structure; it minimizes the number of Commands we have to create, and is more easily ported to other bots.

--------------------------------------------------------------------------
The code for the Group looks something like this:

#include "TankDrive.h"
#include "../Robot.h"
#include "LeftMotor.h"
#include "RightMotor.h"

TankDrive::TankDrive() {
double left = Robot:: oi->getXbox->getRawAxis(1); //Getting left axis' Y
double right = Robot:: oi->getXbox->getRawAxis(3); //Getting right axis' Y

AddParallel(new LeftMotor(left));
AddParallel(new RightMotor(right));
}

--------------------------------------------------------------------------
While the code for the Commands both look something like this:

#include "LeftMotor.h"
#include "../Robot.h"

LeftMotor::LeftMotor(double point) {
Requires(Robot::leftPID);
setpoint = point; //setpoint defined in header
}

...

LeftMotor::Execute() {
Robot::leftPID->SetSetpoint(setpoint);
}

LeftMotor::IsFinished() {
return fabs(Robot::leftPID->getSetpoint() - Robot::leftPID->getPosition()) < 0.1;
}

--------------------------------------------------------------------------

The Command Group thus gets the value of the Xbox axes, sends them to the commands, and the command keeps resetting the setpoint so the velocity is controlled. However, when we upload this to the CRIO we get a fatal error, and we've narrowed it down to the actual calling of the Xbox axis in TankDrive::TankDrive()... when we call it in LeftMotor::Execute(), everything works fine.

My question is if there is anything we can do to make it work in the Command Group, or if we are going to have to call the Xbox in the commands themselves?
 


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 21:45.

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