Go to Post If people really want to see "better" refereeing, they should see what they can do to help FIRST make better. - petek [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
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 05-02-2015, 11:02
droswell's Avatar
droswell droswell is online now
Registered User
FRC #2370 (iBots)
Team Role: Mentor
 
Join Date: Mar 2011
Rookie Year: 2009
Location: Rutland, VT
Posts: 72
droswell is a splendid one to beholddroswell is a splendid one to beholddroswell is a splendid one to beholddroswell is a splendid one to beholddroswell is a splendid one to beholddroswell is a splendid one to beholddroswell is a splendid one to behold
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!
Reply With Quote
  #2   Spotlight this post!  
Unread 05-02-2015, 11:21
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Assistance with RobotBuilder and Drive

Quote:
Originally Posted by droswell View Post
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)?
Reply With Quote
  #3   Spotlight this post!  
Unread 05-02-2015, 13:25
droswell's Avatar
droswell droswell is online now
Registered User
FRC #2370 (iBots)
Team Role: Mentor
 
Join Date: Mar 2011
Rookie Year: 2009
Location: Rutland, VT
Posts: 72
droswell is a splendid one to beholddroswell is a splendid one to beholddroswell is a splendid one to beholddroswell is a splendid one to beholddroswell is a splendid one to beholddroswell is a splendid one to beholddroswell is a splendid one to behold
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
Reply With Quote
  #4   Spotlight this post!  
Unread 05-02-2015, 14:24
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
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.
Reply With Quote
  #5   Spotlight this post!  
Unread 05-02-2015, 16:33
droswell's Avatar
droswell droswell is online now
Registered User
FRC #2370 (iBots)
Team Role: Mentor
 
Join Date: Mar 2011
Rookie Year: 2009
Location: Rutland, VT
Posts: 72
droswell is a splendid one to beholddroswell is a splendid one to beholddroswell is a splendid one to beholddroswell is a splendid one to beholddroswell is a splendid one to beholddroswell is a splendid one to beholddroswell is a splendid one to behold
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.
Reply With Quote
  #6   Spotlight this post!  
Unread 05-02-2015, 17:05
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Assistance with RobotBuilder and Drive

Quote:
Originally Posted by droswell View Post
"undefined reference to `DriveSystem::takeJoystickInputs(Joystick*)"
Did that backtick ` character get accidentally added to the code itself, or when you copied the error message?
Reply With Quote
  #7   Spotlight this post!  
Unread 05-02-2015, 18:05
droswell's Avatar
droswell droswell is online now
Registered User
FRC #2370 (iBots)
Team Role: Mentor
 
Join Date: Mar 2011
Rookie Year: 2009
Location: Rutland, VT
Posts: 72
droswell is a splendid one to beholddroswell is a splendid one to beholddroswell is a splendid one to beholddroswell is a splendid one to beholddroswell is a splendid one to beholddroswell is a splendid one to beholddroswell is a splendid one to behold
Re: Assistance with RobotBuilder and Drive

This is the exact error, including the tick: undefined reference to `DriveSystem::takeJoystickInputs(Joystick*, Joystick*)'
Reply With Quote
  #8   Spotlight this post!  
Unread 06-02-2015, 21:44
FleventyFive FleventyFive is offline
Registered User
FRC #4118
 
Join Date: Sep 2014
Location: Gainesville, FL
Posts: 23
FleventyFive is on a distinguished road
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

Last edited by FleventyFive : 06-02-2015 at 21:49. Reason: fixed
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 14:04.

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