the stick2 would be the “refNum” names. But if you are serious about C++, call them objects or instances.
//note: the lines (or ends of lines) that start with a // are comments
//They don’t change the functionality of the code, but add to it’s understanding, and cleanness if used correctly (code below not an example)
class RobotDemo : public SimpleRobot //this is required,
{
//This area is where you put objects
RobotDrive driver;
Joystick stick;
Joystick stick2; //new Joystick
public:
RobotDemo() :
//this is the "init.vi" area
//this is where you assign pwm ports, analog ports, usb ports, etc...
driver(1,2),//creates the RobotDrive (a group of 2 or 4 Jaguars (but victors work as well)
//as having 2 motors, on PWM 1 and 2 (left and right
stick(1), stick2(4)
//stick is on usb 1, stick 2 is in usb 4
// these must be initialized in the same order
// as they are declared above.
//Note, the inits are a list of, comma, seperated, and,space,and, comments, as, nesescearry, but, the, last, item, does, not, end, with, a, comma
{
GetWatchdog().SetExpiration(0.9);
}
//Code ommited
Yes, the TankDrive is what you are expecting
I also notice you are using pointers (Joystick *joy vs Joystick joy)
the init area would be different:
class RobotDemo : public SimpleRobot //this is required,
{
//This area is where you put objects
RobotDrive *driver;
Joystick *stick;
Joystick *stick2; //new Joystick
public:
RobotDemo() :
{
//this is the "init.vi" area for pointers (after { above
driver = new RobotDrive(1,2);//creates the RobotDrive
//as having 2 motors, on PWM 1 and 2 (left and right
//note: this is not a comma sep. list, each thing ends with a semicolin ;
stick = new Joystick(1);
stick2 = new Joystick(4);
//stick is on usb 1, stick 2 is in usb 4
GetWatchdog().SetExpiration(0.9);
}
//Code ommited
Also note, you can have a mix of the two
One more point:
if using pointers:
stick->GetY();
if not using pointers:
stick.GetY();
One other tip:
Press Ctrl+Space for help completing or finding an item (ex: GetTwist). It is automatically launched for . -> and (