Quote:
Originally Posted by jhersh
If you get an error that is not "Time-out", the CANJaguar object will stop trying to talk to the device, since the calling code is clearly broken.
|
Is this still true with v101 of the firmware? I think this version of the firmware will bring the Jaguar back online after such a fault? Or is this a different set of circumstances?
Quote:
Originally Posted by jhersh
I clearly need to write some examples for using CANJaguar in C++. Feel free to contribute some if you like.
|
I did spend an hour last night figuring out that I needed to call EnableControl() before it would respond to my Set() commands.
This is the code I was playing with last night to get familiar with the Jaguar closed loop current control. Basically a tank drive that commands current:
Code:
#include "testBot.h"
#include "CANJaguar.h"
#include "Joystick.h"
testBot::testBot()
{
}
testBot::~testBot()
{
}
void testBot::OperatorControl()
{
printf("Entering Operator Control\n");
GetWatchdog().SetEnabled(true);
CANJaguar* pJag2 = new CANJaguar(2,CANJaguar::kCurrent);
CANJaguar* pJag3 = new CANJaguar(3,CANJaguar::kCurrent);
CANJaguar* pJag4 = new CANJaguar(4,CANJaguar::kCurrent);
CANJaguar* pJag5 = new CANJaguar(5,CANJaguar::kCurrent);
Joystick* pDriveStick1 = new Joystick(1);
Joystick* pDriveStick2 = new Joystick(2);
pJag2->SetPID(0.01,0.05,0);
pJag3->SetPID(0.01,0.05,0);
pJag4->SetPID(0.01,0.05,0);
pJag5->SetPID(0.01,0.05,0);
pJag2->ConfigNeutralMode(CANJaguar::kNeutralMode_Coast);
pJag3->ConfigNeutralMode(CANJaguar::kNeutralMode_Coast);
pJag4->ConfigNeutralMode(CANJaguar::kNeutralMode_Coast);
pJag5->ConfigNeutralMode(CANJaguar::kNeutralMode_Coast);
pJag2->EnableControl();
pJag3->EnableControl();
pJag4->EnableControl();
pJag5->EnableControl();
pJag2->Set(0, 0);
pJag3->Set(0, 0);
pJag4->Set(0, 0);
pJag5->Set(0, 0);
while(IsOperatorControl() && IsEnabled())
{
GetWatchdog().Feed();
pJag2->Set(pDriveStick1->GetY() * 50);
pJag4->Set(pDriveStick1->GetY() * 50);
pJag5->Set(pDriveStick2->GetY() * -1 * 50);
pJag3->Set(pDriveStick2->GetY() * -1 * 50);
}
printf("Leaving Operator Control\n");
}
void testBot::Autonomous()
{
GetWatchdog().SetEnabled(false);
while(IsAutonomous() && IsEnabled())
{
}
}
START_ROBOT_CLASS(testBot);