Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   C++ Robot Builder question (http://www.chiefdelphi.com/forums/showthread.php?t=130564)

Ken P. 17-09-2014 09:22

C++ Robot Builder question
 
The way that RobotBuilder sets up it references is not what I am used to using. I expected to be able to use refer to a RobotDrive method "ArcadeDrive". I typed in "robotDrive41" - the pointer to the instance of RobotDrive and expected to see the methods etc. Instead it complains that it does not know anything about robotDrive41 despite its reference earlier in the file. Any suggestions are appreciated. Here is the code:

#include "DriveTrain.h"
#include "../Robotmap.h"
#include "../Commands/ArcadeDrive.h"


DriveTrain::DriveTrain() : Subsystem("DriveTrain") {
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS
cANJaguar1 = RobotMap::driveTrainCANJaguar1;
cANJaguar2 = RobotMap::driveTrainCANJaguar2;
cANJaguar3 = RobotMap::driveTrainCANJaguar3;
cANJaguar4 = RobotMap::driveTrainCANJaguar4;
robotDrive41 = RobotMap::driveTrainRobotDrive41;
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS
}

void DriveTrain::InitDefaultCommand() {
// Set the default command for a subsystem here.
//SetDefaultCommand(new MySpecialCommand());
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DEFAULT_COMMAND
SetDefaultCommand(new ArcadeDrive());
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DEFAULT_COMMAND
}
// Put methods for controlling this subsystem
// here. Call these from Commands.
void DriveTrain::arcadeDrive(Joystick stick) {
robotDrive41
}

Jefferson 17-09-2014 14:03

Re: C++ Robot Builder question
 
Quote:

Originally Posted by Ken P. (Post 1400364)
The way that RobotBuilder sets up it references is not what I am used to using. I expected to be able to use refer to a RobotDrive method "ArcadeDrive". I typed in "robotDrive41" - the pointer to the instance of RobotDrive and expected to see the methods etc. Instead it complains that it does not know anything about robotDrive41 despite its reference earlier in the file. Any suggestions are appreciated. Here is the code:

#include "DriveTrain.h"
#include "../Robotmap.h"
#include "../Commands/ArcadeDrive.h"


DriveTrain::DriveTrain() : Subsystem("DriveTrain") {
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS
cANJaguar1 = RobotMap::driveTrainCANJaguar1;
cANJaguar2 = RobotMap::driveTrainCANJaguar2;
cANJaguar3 = RobotMap::driveTrainCANJaguar3;
cANJaguar4 = RobotMap::driveTrainCANJaguar4;
robotDrive41 = RobotMap::driveTrainRobotDrive41;
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS
}

void DriveTrain::InitDefaultCommand() {
// Set the default command for a subsystem here.
//SetDefaultCommand(new MySpecialCommand());
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DEFAULT_COMMAND
SetDefaultCommand(new ArcadeDrive());
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DEFAULT_COMMAND
}
// Put methods for controlling this subsystem
// here. Call these from Commands.
void DriveTrain::arcadeDrive(Joystick stick) {
robotDrive41
}

I'm guessing you're trying to use the period, as in robotDrive41.TankDrive(Joystick1, Joystick2)

What you need to use is the arrow to reference the functions inside RobotDrive like this...
robotDrive41->TankDrive(Joystick1, Joystick2)

Ken P. 19-09-2014 15:17

Re: C++ Robot Builder question
 
Thanks! I had tried it both ways but neither caused the color of the text to change and allow the editor to pull down information on the classes. At least that did not occur until I had saved the changes after using the arrows. When they typed in the text on the WPI RobotBuilder video it seemed to appear faster, so I thought something was wrong. I really appreciate your taking the time to help.
Cheers,
Ken


All times are GMT -5. The time now is 12:08.

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