Go to Post The possibilities for zip ties are endless. - Elgin Clock [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 12-02-2010, 15:33
Tds123's Avatar
Tds123 Tds123 is offline
There is no I in team =]
AKA: Timothy Shub
FRC #1396 (Pyrobots)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2007
Location: Tottenville High School
Posts: 27
Tds123 is an unknown quantity at this point
Send a message via AIM to Tds123
Autonomous mode help

`Ok so i require help with autonmous mode please!!!

void Autonomous(void)
{
GetWatchdog().SetEnabled(false);
myRobot.Drive(0.0 , 0.0 );
Wait(0.0);
myRobot.Drive(0.0, 0.0);
}

we have tank drive

how would i edit this if i wanted to drive forward at half speed for 3 seconds
then turn right for 1 second
then drive foward full speed
__________________
ThE sCaLeS oF bAlAnCe (Team 1396)
  #2   Spotlight this post!  
Unread 12-02-2010, 15:44
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: Autonomous mode help

Have you read the "Getting started guide" in the WPILib documentation found here to try to understand what Drive() and Wait() do?

You should find the "Creating a Robot Program" starting on page 17 useful
http://first.wpi.edu/Images/CMS/Firs...artedWithC.pdf
  #3   Spotlight this post!  
Unread 18-02-2010, 14:14
Tds123's Avatar
Tds123 Tds123 is offline
There is no I in team =]
AKA: Timothy Shub
FRC #1396 (Pyrobots)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2007
Location: Tottenville High School
Posts: 27
Tds123 is an unknown quantity at this point
Send a message via AIM to Tds123
Re: Autonomous mode help

Well i did i just want an example , of that, to see if what i want to do is correct cause i am kinda confused right now using the links you gave me
__________________
ThE sCaLeS oF bAlAnCe (Team 1396)
  #4   Spotlight this post!  
Unread 18-02-2010, 15:08
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: Autonomous mode help

As I tell my students, if you're confused, ask a question that will get you unconfused. There are plenty of people here that are willing to help and answer questions. You won't learn anything if you're simply just given the answer.

The code that is in the getting started document starting at page 17 has an example autonomous program similar to what you're looking for. Look at the example on page 18 (example 5). The comments in the code spell out exactly what is going on. Try to see how the numbers in the comments map to the numbers in the code. Then go back to your original question and see how you can modify those numbers to do what you want them to do. Keep in mind, their RobotDrive object is called drivetrain while yours looks like it's called myRobot.

If you're still confused about what Drive() and Wait() do, read the comment in the the WPILib source code. I'll include the comments and prototypes here for reference. From RobotDrive.cpp
Code:
/**
 * Drive the motors at "speed" and "curve".
 *
 * The speed and curve are -1.0 to +1.0 values where 0.0 represents stopped and
 * not turning. The algorithm for adding in the direction attempts to provide a constant
 * turn radius for differing speeds.
 *
 * This function sill most likely be used in an autonomous routine.
 *
 * @param speed The forward component of the speed to send to the motors.
 * @param curve The rate of turn, constant for different forward speeds.
 */
void RobotDrive::Drive(float speed, float curve)
From Timer.cpp
Code:
/**
 * Pause the task for a specified time.
 * 
 * Pause the execution of the program for a specified period of time given in seconds.
 * Motors will continue to run at their last assigned values, and sensors will continue to
 * update. Only the task containing the wait will pause until the wait time is expired.
 * 
 * @param seconds Length of time to pause, in seconds.
 */
void Wait(double seconds)
  #5   Spotlight this post!  
Unread 22-02-2010, 18:58
whodatbat's Avatar
whodatbat whodatbat is offline
Astrotrumpetplayer
AKA: Astrotrumpetplayer
FRC #0021 (ComBBat21)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Titusville, Flordia
Posts: 17
whodatbat is an unknown quantity at this point
Send a message via ICQ to whodatbat
Re: Autonomous mode help

try this
RobotDemo() { GetWatchdog().SetEnabled(false); }
Example 4: Disabling the watchdog timer
Now the autonomous part of the program can be constructed that drives in a square pattern: void Autonomous() { for (int i = 0; i < 4; i++) { drivetrain.Drive(0.5, 0.0); // drive 50% of full forward with 0% turn Wait(2.0); // wait 2 seconds drivetrain.Drive(0.0, 0.75); // drive 0% forward and 75% turn } Drivetrain.Drive(0.0, 0.0); // drive 0% forward, 0% turn (stop) }
Example 5: Autonomous program that drives in a square pattern
Now look at the operator control part of the program: void OperatorControl() { while (1) // loop forever { drivetrain.TankDrive(leftStick, rightStick);// drive with the joysticks Wait(0.005); } }
Example 6: Simple tank drive with two joysticks
Putting it all together we get this very short program that accomplishes some autonomous task and provides operator control tank steering:
#include “WPILib.h” class RobotDemo : public SimpleRobot { RobotDrive drivetrain(1, 2); Joystick leftStick(1); Joystick rightStick(2); public: RobotDemo() { GetWatchdog().SetEnabled(false); } void Autonomous() { for (int i = 0; i < 4; i++) { drivetrain.Drive(0.5, 0.0); // drive 50% forward, 0% turn Wait(2.0); // wait 2 seconds drivetrain.Drive(0.0, 0.75); // drive 0% forward and 75% turn Wait(0.75); // turn for almost a second } drivetrain.Drive(0.0, 0.0); // stop the robot } void OperatorControl() { while (1) // loop forever { drivetrain.Tank(leftStick, rightStick); // drive with the joystick Wait(0.005); } } };
Example 7: Completed example program
Although this program will work perfectly with the robot as described, there were some details that were skipped:
 In the example drivetrain,leftStick and rightStick are member objects of the RobotDemo class. They were accessed using references, one of the ways of accessing object members. In the next section pointers will be introduced as an alternate technique.
 The drivetrain.Drive() method takes two parameters, a speed and a turn direction. See the documentation about the RobotDrive object for details on how that speed and direction really work.
 The Watchdog timer was disabled – in general a bad idea! You should enable the watchdog timer, set the feeding interval, and be sure to “Feed” it at least that often.
__________________
We lift things up and put them down
Closed Thread


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
autonomous mode help please... tomy NI LabVIEW 22 21-02-2009 10:04
Autonomous mode help Drake Hunter NI LabVIEW 3 12-02-2009 01:52
Autonomous Mode HELP! jesusescobar Programming 4 12-02-2007 12:02
Help - Making the autonomous mode razer Programming 5 31-01-2007 16:25
Simulating autonomous mode - i need help!! :( itay_ms Programming 5 21-01-2007 11:28


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

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