Go to Post [Bring] programmers [to Championships], they may be small, quite and easy to miss while leaving for Atlanta but its hard to do anything robotic without them, I've tried. - Simon Strauss [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 20-02-2011, 16:48
tux tux is offline
Registered User
AKA: Lee Harr
FRC #3842 (Shock-a-Bots)
Team Role: Mentor
 
Join Date: Apr 2005
Rookie Year: 2005
Location: Rochester, NY
Posts: 91
tux is an unknown quantity at this point
Take a quick look at our code?

I won't be able to get to our robot again until ship day. I'd like to be able to walk in on Tuesday and deploy a working program.

This is our first time programming in C++ so we would appreciate any pointers (no pun intended).

What we need:

Tank drive
Compressor
Solenoids controlling 2 actuators

Here's what I have:

Code:
#include "WPILib.h"

class Robot3842 : public SimpleRobot
{
	RobotDrive rd; // robot drive system
	
	Joystick lstick;
	Joystick rstick;

	Compressor compress;
	
	Solenoid armUp;
	Solenoid armDn;
	
	Solenoid miniOut;
	Solenoid miniIn;
	
public:
	Robot3842(void):
		rd(1, 2),	// these must be initialized in the same order
		lstick(1),		// as they are declared above.
		rstick(2),

		compress(14, 1),
	
		armUp(8, 1),
		armDn(8, 2),
		
		miniOut(8, 3),
		miniIn(8, 4)
	{
		rd.SetExpiration(0.1);
		
		compress.Start();
		
		armUp.Set(true);
		armDn.Set(false);
		
		miniOut.Set(false);
		miniIn.Set(true);
	}


	void Autonomous(void)
	{
		rd.SetSafetyEnabled(false);
		rd.Drive(0.5, 0.0); 	// drive forwards half speed
		Wait(2.0); 				//    for 2 seconds
		rd.Drive(0.0, 0.0); 	// stop robot
	}

	void OperatorControl(void)
	{
		rd.SetSafetyEnabled(true);

		while (IsEnabled() && IsOperatorControl())
		{
			rd.TankDrive(lstick, rstick);
			Wait(0.005);				// wait for a motor update time
			
			if (rstick.GetRawButton(1)){
				armUp.Set(false);
				armDn.Set(true);
			} else if (rstick.GetRawButton(2)){
				armUp.Set(true);
				armDn.Set(false);
			}
			
			if (rstick.GetRawButton(10)){
				miniOut.Set(true);
				miniIn.Set(false);
			} else if (rstick.GetRawButton(7)){
				miniOut.Set(false);
				miniIn.Set(true);
			}
		}
	}
};

START_ROBOT_CLASS(Robot3842);

It compiles, so that is a start.

Thanks for your help!
Reply With Quote
 


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


All times are GMT -5. The time now is 17:45.

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