Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Assistance with RobotBuilder and Drive (http://www.chiefdelphi.com/forums/showthread.php?t=134019)

droswell 05-02-2015 11:02

Assistance with RobotBuilder and Drive
 
Greetings,

We're trying to use robotbuilder this year. We have PID and solenoids working, for some reason I'm having a lot of trouble getting the mecanum drivetrain code working.

I followed this tutorial http://wpilib.screenstepslive.com/s/...-and-joysticks

and got the drive subsystem all set. When I try to add the method to the execute() section of our DriveWithJoystick command, I get the error "No known conversion for argument 1 from 'Joystick*' to 'Joystick'.

From the command DriveWithJoystick
Code:

void DriveWithJoystick::Execute()
{
    Robot::driveSubsystem->takeJoystickInputs(Robot::io->getJoystick1() );
}



In my header file for my driveSubsystem, I added this
Code:

void takeJoystickInputs(Joystick stick);
void stop();


and finally in my driveSystem.cpp these are the two functions I added after InitDefaultCommand:

Code:

void  takeJoystickInputs(Joystick stick)
{
    Robot::driveSubsystem->robotDrive4->MecanumDrive_Cartesian(stick.GetX(), stick.GetY(), stick,GetZ() );
}

void stop()
{
      Robot::driveSubsystem->robotDrive4->StopMotor();
}

Thank you for any help you can provide!

Alan Anderson 05-02-2015 11:21

Re: Assistance with RobotBuilder and Drive
 
Quote:

Originally Posted by droswell (Post 1438708)
When I try to add the method to the execute() section of our DriveWithJoystick command, I get the error "No known conversion for argument 1 from 'Joystick*' to 'Joystick'.

From the command DriveWithJoystick
Code:

void DriveWithJoystick::Execute()
{
    Robot::driveSubsystem->takeJoystickInputs(Robot::io->getJoystick1() );
}


What type does getJoystick1() return? The error suggests that you're trying to give takeJoystickInputs() a pointer to a Joystick object, but the function expects an actual Joystick rather than a pointer to one.

Did you mean to call getJoystick(1)?

droswell 05-02-2015 13:25

Re: Assistance with RobotBuilder and Drive
 
getJoystick1() returns a Joystick*, but I don't see a way to return the actual joystick instance instead of just a pointer

Alan Anderson 05-02-2015 14:24

Re: Assistance with RobotBuilder and Drive
 
If you can't pass a Joystick, change the function to expect a Joystick * and change the stick.GetX() etc. to stick->GetX() instead.

droswell 05-02-2015 16:33

Re: Assistance with RobotBuilder and Drive
 
Thanks for your help!

I changed the function to expect *Joystick and swapped the call to ->GetX() instead of .GetX()

I'm down to one error -
"undefined reference to `DriveSystem::takeJoystickInputs(Joystick*)"

I included the drivesystem.h file in my driving command, so I'm unsure why its not defined.

Alan Anderson 05-02-2015 17:05

Re: Assistance with RobotBuilder and Drive
 
Quote:

Originally Posted by droswell (Post 1438883)
"undefined reference to `DriveSystem::takeJoystickInputs(Joystick*)"

Did that backtick ` character get accidentally added to the code itself, or when you copied the error message?

droswell 05-02-2015 18:05

Re: Assistance with RobotBuilder and Drive
 
This is the exact error, including the tick: undefined reference to `DriveSystem::takeJoystickInputs(Joystick*, Joystick*)'

FleventyFive 06-02-2015 21:44

Re: Assistance with RobotBuilder and Drive
 
Notice how for the InitDefaultCommand, the function is defined DriveSubsystem::InitDefaultCommand() { //whatever code }. (assuming you built with robotbuilder)

You need to say what class those functions are a part of, they don't know just because they have the same file name as the header file (they are becomming global functions and so are undefined when you call them as part of the DriveSubsystem class) . If the actuators you are calling functions on are part of that subsystem, you also don't need the Robot::driveSubsystem before each of them, though I suppose having it might not break it.

So I think doing this in your DriveSystem.cpp might fix it:
Code:

void  DriveSubsystem::takeJoystickInputs(Joystick *stick)
{
    robotDrive4->MecanumDrive_Cartesian(stick.GetX(), stick.GetY(), stick,GetZ() );
}

void DriveSubsystem::stop()
{
    robotDrive4->StopMotor();
}

I'm not sure about using a pointer or not for using a joystick as a parameter. I usually have joystick values called in the command, than passed into a subsystem function that takes generic floats for x,y, and rotation in the case of Mecanum drive so I can reuse that function in autonomous. Hope this helps, good luck!

Also, is it DriveSubsystem or DriveSystem? You seem to go back and forth in your comments, just make sure it's consistent in your code :)


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

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