Go to Post Overpowered? You only took out half the building... Knock the rest down then get back to me. - sodizzle [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 22-12-2008, 21:14
Straberrie's Avatar
Straberrie Straberrie is offline
The Plague
AKA: Rebecca
FRC #0375 (Robotic Plague)
Team Role: Programmer
 
Join Date: Feb 2008
Rookie Year: 2007
Location: New York
Posts: 59
Straberrie will become famous soon enough
Axis Camera in C++; code error??

Hi! Currently, I am trying to program the camera and the bot so that when it detects green, it aligns itself with the traget, but since i epicly phailed at that, I decided to do something simpler and just make the bot go forward when it detects green! I made this code *well, technically I used the guide and didnt really MAKE it* and i am getting 2 errors.... And i cant figure out whats wrong! help would be appreciated! THANKS!


So here are the headers I used:

#include "WPILib.h"
#include "AxisCamera.h"
#include "Servo.h"
#include "SimpleRobot.h"
#include "SensorBase.h"
#include "Error.h"
#include "ErrorBase.h"
#include "FrcError.h"

This is the rest of the defining and stuff!

class RobotDemo : public SimpleRobot
{
RobotDrive *Bot; // robot drive system
Joystick *stickRight;
Joystick *stickLeft;
DriverStation *ds; // driver station


public:
RobotDemo(void)
{
if (StartCameraTask ()== -1) {
printf( "Failed to spawn camera task; Error code %s",
GetErrorText (GetLastError()) };

ds = DriverStation::GetInstance();
Bot = new RobotDrive(1, 2); // create robot drive base
stickRight = new Joystick(1);
stickLeft = new Joystick(2);
Range greenHue, greenSat, greenLum;
greenHue.minValue = 65; greenHue.maxValue = 80;
greenSat.minValue =100; greenSat.maxValue = 255;
greenLum.minValue = 100; greenLum.maxValue = 255;
GetWatchdog().SetExpiration(100);
}


and here is the autonomous:

void Autonomous(void)
{
GetWatchdog().SetEnabled(false);

while(IsAutonomous())
{
if( FindColor(IMAQ_HSL, &greenHue, &greenSat, &greenLum, &par)
&& par.particleToImagePercent < MAX_PARTICLE_TO_IMAGE_PERCENT
&& par.particleToImagePercent > MIN_PARTICLE_TO_IMAGE_PERCENT )

{Bot->Drive(1.0, (float)par.center_mass_x_normalized);}

else
Bot->Drive(0.0, 0.0);
Wait(50);
}

Bot->Drive(0.0, 0.0); // stop robot
}


and the very end line of the code:

START_ROBOT_CLASS(RobotDemo);


I highlighted the lines where i get an error; basically on the get error one, they say the function was not defined.... and it also highlights the Start Robot Class thing as wrong. And is camera initiated/used right? Because in the guide, there are different things on different pages and I did not know what to use... Sorry for the lengthy question.
__________________
Team 375: The Robotic Plague
Current Robot: I-Chihuahua
Last Event: Big Apple Breakaway
  #2   Spotlight this post!  
Unread 22-12-2008, 21:38
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: Axis Camera in C++; code error??

You're missing a closing round-bracket on the 1st line. You have a ')' for GetLastError, then a ')' for GetErrorText, but you're missing a ')' for printf. It should be
Code:
if (StartCameraTask ()== -1) 
{
  printf( "Failed to spawn camera task; Error code %s",
GetErrorText (GetLastError())) };
  #3   Spotlight this post!  
Unread 22-12-2008, 21:43
tdlrali tdlrali is offline
Registered User
FRC #0469 (Las Guerrillas)
Team Role: Programmer
 
Join Date: Sep 2006
Rookie Year: 2006
Location: MI
Posts: 377
tdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud of
Re: Axis Camera in C++; code error??

Change the lines
Code:
if (StartCameraTask ()== -1) {
printf( "Failed to spawn camera task; Error code %s",
GetErrorText (GetLastError()) };
to
Code:
if (StartCameraTask() == -1)
	printf("Failed to spawn camera task; Error code %s", GetVisionErrorText(GetLastVisionError()));
It should compile now (See FrcError.h for these declarations - the headers were probably changed after the documentation was written).

(P.S. Your #includes for servo.h, simplerobot.h, sensorbase.h, error.h and errorbase.h are extraneous, since they are included by wpilib.h)
  #4   Spotlight this post!  
Unread 22-12-2008, 21:52
Straberrie's Avatar
Straberrie Straberrie is offline
The Plague
AKA: Rebecca
FRC #0375 (Robotic Plague)
Team Role: Programmer
 
Join Date: Feb 2008
Rookie Year: 2007
Location: New York
Posts: 59
Straberrie will become famous soon enough
Re: Axis Camera in C++; code error??

THANK U!!!!!!!!!!

and really?? I thought maybe the get error thing would be in one of them, but YAY! ty!!!
__________________
Team 375: The Robotic Plague
Current Robot: I-Chihuahua
Last Event: Big Apple Breakaway
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
Program Axis Camera in c++ excel2474 Programming 5 22-12-2008 17:14
Axis Camera Testing help koo_04 Programming 7 20-12-2008 13:55
axis camera - problem s0crates FRC Control System 11 16-12-2008 09:34
Error in Compiling the Camera Code (B&W Version) VetteSlick Programming 7 20-01-2006 20:50
Code error on RC after downloading "bells and whistles" version of Kevins camera code DanDon Programming 6 10-01-2006 18:07


All times are GMT -5. The time now is 03:37.

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