I have spent some time trying to get the camera feed to the netbook to work. I have tried the 2010ImageDemo example code as well as my own code (see below). I am fairly sure that the camera is set up correctly because it worked last year, I can access it from it's web interface and I can successfully run the camera set up tool when I plug the camera into the classmate netbook. Does any one have any ideas as to what we need to do to make it work?
Code:
#include "WPILib.h"
#include "Target.h"
#include "DashboardDataSender.h"
/**
*2010 code
*/
class RobotDemo : public SimpleRobot
{
Joystick leftStick;
Joystick rightStick;
Victor right1;
Victor right2;
Victor left1;
Victor left2;
Victor bigmotor;
Victor babymotor;
int loop;
DashboardDataSender *dds;
public:
RobotDemo():
leftStick(1),
rightStick(2),
right1(2),
right2(1),
left1(4),
left2(3),
bigmotor(5),
babymotor(6),
loop(0)
{
dds = new DashboardDataSender();
GetWatchdog().SetExpiration(0.1);
}
/**
* Drive left & right motors for 2 seconds then stop
*/
void Autonomous(void)
{
GetWatchdog().SetEnabled(true);
GetWatchdog().SetExpiration(1.0);
}
/**
* Runs the motors with tank steering.
*/
void OperatorControl(void)
{
GetWatchdog().SetEnabled(true);
// Create and set up a camera instance. first wait for the camera to start
// if the robot was just powered on. This gives the camera time to boot.
printf("Getting camera instance\n");
AxisCamera &camera = AxisCamera::GetInstance();
printf("Setting camera parameters\n");
camera.WriteResolution(AxisCamera::kResolution_320x240);
camera.WriteCompression(20);
camera.WriteBrightness(0);
while (IsOperatorControl())
{
GetWatchdog().Feed();
GetWatchdog().SetExpiration(1.0);
// HSLImage *image = camera.GetImage();
right1.Set(rightStick.GetY());
right2.Set(rightStick.GetY());
left1.Set(-leftStick.GetY());
left2.Set(-leftStick.GetY());
if (leftStick.GetRawButton(1)==1)
{
bigmotor.Set(1.0);
}
else
{
bigmotor.Set(0.0);
}
if (rightStick.GetRawButton(1)==1)
{
babymotor.Set(0.3);
}
else
{
babymotor.Set(0.0);
}
loop++;
printf("Loop: %d", loop);
dds->sendIOPortData();
Wait(.005); // wait for a motor update time
}
}
};
START_ROBOT_CLASS(RobotDemo);