Go to Post Now really, who would want to try and go against Andy Baker? That's like trying to single-handedly outscore 25, 254, and your choice of triplet with a shopping cart. - Billfred [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 04-01-2011, 17:22
Cody Trey's Avatar
Cody Trey Cody Trey is offline
Programing = hard + fun
FRC #2582 (Panther Bots)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2009
Location: US
Posts: 31
Cody Trey is an unknown quantity at this point
Send a message via Yahoo to Cody Trey
Question c++ motor control

I need help controlling a jaguar using the Y-axis of a joystick. I am trying to complete code for last year's robot in c++ to have a working base to program on this year. I have most of my code done, if you'd like to see it just ask and i'll post, I can also post the error that wind river is giving me.

Thank you all in advanced!
__________________
Love, Peace, and Robot Grease
Reply With Quote
  #2   Spotlight this post!  
Unread 04-01-2011, 17:26
gvarndell's Avatar
gvarndell gvarndell is offline
Software Engineer
AKA: Addi's and Georgie's Dad
FRC #1629 (GaCo)
Team Role: Parent
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Grantsville, Maryland
Posts: 350
gvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond repute
Re: c++ motor control

Quote:
Originally Posted by Cody Trey View Post
I need help controlling a jaguar using the Y-axis of a joystick. I am trying to complete code for last year's robot in c++ to have a working base to program on this year. I have most of my code done, if you'd like to see it just ask and i'll post, I can also post the error that wind river is giving me.

Thank you all in advanced!
I'm predicting no useful replies to this unless you post the error messages -- at least.
__________________
Robots never, ever, ever, ever break -- The Robot Repairman (Backyardigans)
Reply With Quote
  #3   Spotlight this post!  
Unread 04-01-2011, 18:34
Cody Trey's Avatar
Cody Trey Cody Trey is offline
Programing = hard + fun
FRC #2582 (Panther Bots)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2009
Location: US
Posts: 31
Cody Trey is an unknown quantity at this point
Send a message via Yahoo to Cody Trey
Re: c++ motor control

My Code is:
#include "WPILib.h"

/**
* This is a demo program showing the use of the RobotBase class.
* The SimpleRobot class is the base of a robot application that will automatically call your
* Autonomous and OperatorControl methods at the right time as controlled by the switches on
* the driver station or the field controls.
*/
class RobotDemo : public SimpleRobot
{
RobotDrive *myRobot; // robot drive system
Joystick *m_rollerstick;
DriverStation *ds; // driver station
Joystick *m_leftstick;
Joystick *m_rightstick;
Jaguar *RollerMotor;
Solenoid *Sol1;
Jaguar *rollermotor;


public:
RobotDemo(void)
{
ds = DriverStation::GetInstance();
myRobot = new RobotDrive(1, 2); // create robot drive base
m_leftstick = new Joystick(1); // create the joysticks
m_rightstick = new Joystick (2);
m_rollerstick = new Joystick (3);
RollerMotor = new Jaguar (3); // create the Jaguar for the roller
Compressor *c = new Compressor(4, 2); //creates the compressor object
c->Start(); //starts compressor
Sol1 = new Solenoid(1); // creates solenoid obects
GetWatchdog().SetExpiration(100);
}

/**
* Drive left & right motors for 2 seconds then stop
*/
void Autonomous(void)
{
GetWatchdog().SetEnabled(false);
myRobot->Drive(0.5, 0.0); // drive forwards half speed
Wait(2000); // for 2 seconds
myRobot->Drive(0.0, 0.0); // stop robot
Wait(2000);
myRobot->Drive (-0.5, 0.0); //drive backwards half speed
Wait(2000);
myRobot->Drive (0.0, 0.0);
Wait (2000);
}

/**
* Runs the motors with tank steering.
*/
void OperatorControl(void)
{
GetWatchdog().SetEnabled(true);
while (IsOperatorControl())
{
GetWatchdog().Feed();
myRobot->TankDrive(m_leftstick, m_rightstick); //sets the left and right joysticks to control the left and right motors
RollerMotor.Set( m_rollerstick.GetY() ); //sets joystick 3 y-axis to controll the roller motor
if (m_rollerstick->GetRawButton(4)) //gets button 4 from joystick 3 to control the soleniod on port 1, note: it is port one in the code, but is labeled port 0 on the hardware
{Sol1->Set(true);}

}
}
};

START_ROBOT_CLASS(RobotDemo);

the red section of code gives the error:
error: request for member `Set' in `((RobotDemo*)this)->RobotDemo::RollerMotor', which
is of non-class type `Jaguar*'
__________________
Love, Peace, and Robot Grease
Reply With Quote
  #4   Spotlight this post!  
Unread 04-01-2011, 19:15
gvarndell's Avatar
gvarndell gvarndell is offline
Software Engineer
AKA: Addi's and Georgie's Dad
FRC #1629 (GaCo)
Team Role: Parent
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Grantsville, Maryland
Posts: 350
gvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond repute
Re: c++ motor control

Quote:
Originally Posted by Cody Trey View Post
RollerMotor.Set( m_rollerstick.GetY() ); //sets joystick 3 y-axis to controll the roller motor

the red section of code gives the error:
error: request for member `Set' in `((RobotDemo*)this)->RobotDemo::RollerMotor', which
is of non-class type `Jaguar*'
This is a shot in the dark from a die-hard C programmer who simply can't understand why people use C++.

Can you try this instead?

float foo = m_rollerstick.GetY();
RollerMotor.Set(foo); //sets joystick 3 y-axis to controll the roller motor
__________________
Robots never, ever, ever, ever break -- The Robot Repairman (Backyardigans)
Reply With Quote
  #5   Spotlight this post!  
Unread 04-01-2011, 19:56
Cody Trey's Avatar
Cody Trey Cody Trey is offline
Programing = hard + fun
FRC #2582 (Panther Bots)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2009
Location: US
Posts: 31
Cody Trey is an unknown quantity at this point
Send a message via Yahoo to Cody Trey
Re: c++ motor control

I just tried that, it seems that the error isn't in how i had it set up, it doesn't like something about the GetY and the Set, because its still returning the same errors. but it does separate the two errors into different lines which should make them easier to deal with.

errors:

GetY error:
error: request for member `GetY' in `((RobotDemo*)this)->RobotDemo::m_rollerstick',
which is of non-class type `Joystick*'
Set error:
error: request for member `Set' in `((RobotDemo*)this)->RobotDemo::RollerMotor', which
is of non-class type `Jaguar*'
__________________
Love, Peace, and Robot Grease
Reply With Quote
  #6   Spotlight this post!  
Unread 04-01-2011, 19:58
demosthenes2k8's Avatar
demosthenes2k8 demosthenes2k8 is offline
Graduated but not gone
AKA: Matt Soucy
FRC #0166 (Chop Shop 166)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Merrimack, NH
Posts: 589
demosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to behold
Send a message via AIM to demosthenes2k8 Send a message via Yahoo to demosthenes2k8
Re: c++ motor control

Oh, that's just because they're pointers.
Instead of m_rollerstick.GetY(), do m_rollerstick->GetY()
Same with the jaguar.

EDIT: Ninja!
__________________


GSR Dean's List Finalist 2011
Reply With Quote
  #7   Spotlight this post!  
Unread 04-01-2011, 20:11
Cody Trey's Avatar
Cody Trey Cody Trey is offline
Programing = hard + fun
FRC #2582 (Panther Bots)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2009
Location: US
Posts: 31
Cody Trey is an unknown quantity at this point
Send a message via Yahoo to Cody Trey
Re: c++ motor control

YAY!! you guys are my heros! it worked, and i did the same motor.Set
__________________
Love, Peace, and Robot Grease

Last edited by Cody Trey : 04-01-2011 at 20:30.
Reply With Quote
  #8   Spotlight this post!  
Unread 04-01-2011, 20:33
Cody Trey's Avatar
Cody Trey Cody Trey is offline
Programing = hard + fun
FRC #2582 (Panther Bots)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2009
Location: US
Posts: 31
Cody Trey is an unknown quantity at this point
Send a message via Yahoo to Cody Trey
Thumbs up Re: c++ motor control

Now tomorrow after final's I'll try to get it on the bot, i may be back with some more problems, but hopefully it will all go smoothly
__________________
Love, Peace, and Robot Grease
Reply With Quote
  #9   Spotlight this post!  
Unread 04-01-2011, 19:58
Radical Pi Radical Pi is offline
Putting the Jumper in the Bumper
AKA: Ian Thompson
FRC #0639 (Code Red Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York
Posts: 655
Radical Pi has a spectacular aura aboutRadical Pi has a spectacular aura aboutRadical Pi has a spectacular aura about
Re: c++ motor control

It's a simple mistake. You need to replace RollerMotor.Set with RollerMotor->Set because you're using a pointer. Probably just a typo.

edit: same thing for the joystick error
__________________

"To have no errors would be life without meaning. No strugle, no joy"
"A network is only as strong as it's weakest linksys"
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Spike motor control kansattica NI LabVIEW 5 30-01-2012 11:37
encoder motor control pauldemonkey NI LabVIEW 1 19-02-2010 13:10
Motor Control Systems Astronouth7303 Programming 3 05-04-2005 19:35
Four motor control judson Programming 1 14-02-2005 20:17
Motor Control archiver 2000 1 23-06-2002 23:01


All times are GMT -5. The time now is 02:47.

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