View Single Post
  #6   Spotlight this post!  
Unread 04-02-2009, 03:31
nadavsen2 nadavsen2 is offline
Registered User
FRC #2231
 
Join Date: Jan 2009
Location: israel
Posts: 31
nadavsen2 is an unknown quantity at this point
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)
{
    
    

Reply With Quote