Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Still problem with classes...+img (http://www.chiefdelphi.com/forums/showthread.php?t=73439)

nadavsen2 02-02-2009 10:02

Still problem with classes...+img
 
I just can make that thing work.... :(

image:



GGCO 02-02-2009 15:06

Re: Still problem with classes...+img
 
It looks like you are trying to create an object for the "Drive" class....right??

I think you were trying to write:

RobotDrive *bba;

??

Maybe I'm missing something? Please elaborate.

nadavsen2 02-02-2009 17:53

Re: Still problem with classes...+img
 
Yes, im trying to creat a new object "Drive" (!!)

I defined a new object at the class "Drive" and i want to make a new
object in my code. Like "PWM" or "Jaguar" but from class that i created!

help :(

Redneck 04-02-2009 02:18

Re: Still problem with classes...+img
 
Mind showing us more of that MyRobot.cpp file you're using? If you could post that, along with your Drive.cpp and Drive.h files, then it'll be easier to figure out than working from just a screenshot.

wireties 04-02-2009 02:34

Re: Still problem with classes...+img
 
You want something like

RobotDrive *bba = new RobotDrive(1, 2);

There is no class Drive in the WPI libraries (I think).

nadavsen2 04-02-2009 03:31

Re: Still problem with classes...+img
 
Im trying to creat one....

I succeid to creat a new class but now when im trying to put the code
on the cRio the DS tells me "No Code".

why is that?

here is my code:


MainClass
PHP Code:

#include "WPILib.h"
#include "Functions.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 stick// only joystick
    

public:
    
RobotDemo(void):
        
myRobot(12),    // these must be initialized in the same order
        
stick(1)        // as they are declared above.
    
{
        
GetWatchdog().SetExpiration(100);
    }

    
/**
     * Drive left & right motors for 2 seconds then stop
     */
    
void Autonomous(void)
    {
        
GetWatchdog().SetEnabled(false);
        
myRobot.Drive(0.50.0);     // drive forwards half speed
        
Wait(2.0);                 //    for 2 seconds
        
myRobot.Drive(0.00.0);     // stop robot
    
}

    
/**
     * Runs the motors with arcade steering. 
     */
    
void OperatorControl(void)
    {
        
GetWatchdog().SetEnabled(true);
        
Functions r;
        
        
        
        
        while (
IsOperatorControl())
        {
            
GetWatchdog().Feed();
            
myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)
            
r.GetSomething();
        }
    }
};

START_ROBOT_CLASS(RobotDemo); 



Functions.h:
PHP Code:

#ifndef FUNCTIONS_H_
#define FUNCTIONS_H_
class Functions
{
public:
    
void GetSomething(void);
};
#endif 


Functions.cpp:

PHP Code:

#include "Functions.h"

void GetSomething(void)
{
    
    



wt200999 04-02-2009 06:44

Re: Still problem with classes...+img
 
Quote:

PHP Code:

#include "Functions.h"

void GetSomething(void)
{
    
    



That should be:
Functions
PHP Code:

#include "Functions.h"

void Functions::GetSomething(void)
{
    
    



nadavsen2 04-02-2009 16:54

Re: Still problem with classes...+img
 
Still not working..

wireties 04-02-2009 18:10

Re: Still problem with classes...+img
 
Does it compile? It looks like it should work (of course it does nothing).

Try downloading into RAM with the target console window up. Does it print any messages about undefined symbols? When you run it can you see the FRC_RobotTask running (type 'i' to see the running tasks).


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

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