Go to Post Cut it out with the paper airplanes! Frank hath spoken! - cgmv123 [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 19-01-2009, 16:13
raptorf22 raptorf22 is offline
Registered User
no team
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Mass
Posts: 1
raptorf22 is an unknown quantity at this point
Timing in Simple Robot

How can I create timed loops using the SimpleRobot? The teleop code in SimpleRobot seems to run as fast as it can, while the IterativeRobot is throttled at 200Hz.

Right now we have tried something like this, but would rather make this work with the SimpleRobot
PHP Code:
#include "WPILib.h"

class CustomRobot : public IterativeRobot
{
    
RobotDrive drive// robot drive system
    
Joystick stick// only joystick
    
    // Local variables to count the number of periodic loops performed
    
UINT32 m_telePeriodicLoops;

public:
    
CustomRobot(void): drive(1,3,2,4), stick(1)
    {
        
GetWatchdog().SetExpiration(100);
        
        
// Initialize counters to record the number of loops completed in autonomous and teleop modes
        
m_telePeriodicLoops 0;
    }

    
void TeleopPeriodic(void){
        
GetWatchdog().Feed();
        
m_telePeriodicLoops++;
        
        
//Lets check time over a few minutes
        
if(m_telePeriodicLoops 200 == 0){
            
printf("Seconds: %d\r\n",m_telePeriodicLoops 200);
        }
        
        
//Reset Timer
        
if(stick.GetRawButton(2)){
            
m_telePeriodicLoops 0;
        }
        
        
drive.ArcadeDrive(stick);
    }
};

START_ROBOT_CLASS(CustomRobot); 
Any ideas? Best practices?
Reply With Quote
  #2   Spotlight this post!  
Unread 19-01-2009, 16:57
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: Timing in Simple Robot

You can use the Timer class included in WPILib to get the number of seconds, returned as a double, since you called the Start() function of the class.
__________________
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
C++ Robot: Simple or Iterative? Abrakadabra Programming 3 14-01-2009 22:01
Robot Timing Code robotrobot2 Programming 8 19-01-2008 14:18
timing of re-contact Gary Dillard Rules/Strategy 16 19-01-2008 14:09
Demo: Simple robot arm with a PID controller mtomczak Programming 1 17-01-2008 02:17
autonomous timing seanl Programming 6 09-03-2007 09:42


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

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