|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
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. |
|
#2
|
||||
|
||||
|
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
|
|||
|
|||
|
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()) };
Code:
if (StartCameraTask() == -1)
printf("Failed to spawn camera task; Error code %s", GetVisionErrorText(GetLastVisionError()));
(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
|
||||
|
||||
|
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!!! |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |