Porting Talon SRX

So we are trying to program using CAN but for some reason everything that I try says that the CAN Talon is a null pointer. Is there a specific way of writing the ports for the CAN Talons?
(I would add my code to this post, but I forgot how to do that)

It sounds like your creating the CANTalon variable, but not calling the new operator.

Take a look at section 3.2.3 in the Talon SRX Software Reference Manual. See the line that reads…

CANTalon customMotorDescript = new CANTalon(0);

It sounds like you are just doing

CANTalon customMotorDescript;

The number you pass into new CANTalon(x), is the device ID of the Talon. Use the web-based config to set the IDs of the Talons so that each one is unique (See section 2 in the Talon software reference manual).

Link to get the Talon SRX Software reference manual…
http://www.ctr-electronics.com/control-system/talon-srx.html#product_tabs_technical_resources

Like I said, If I knew how to add my code to a reply you could see what I am doing. I did, in fact, write it just like that. (CANTalon motorDescirption = new CANTalon(x)

Is there some reason why you can’t just cut and paste the relevant portion(s)?

Well ok…but I have no way of knowing how you wrote it…

Ether is right, just copy/paste the important part. Or zip it up and email to [email protected], and I’ll bounce it back to this thread.

public class RobotMap {

public static SpeedController frontLeft;
public static CANTalon frontRight;
public static CANTalon backLeft;
public static CANTalon backRight;
public static RobotDrive robotDrive;

public static void init(){
	frontLeft = new CANTalon(3, 0);

// frontRight = new CANTalon(4);
// backLeft = new CANTalon(1);
// backRight = new CANTalon(0);

	robotDrive = new RobotDrive(frontLeft, frontRight, backLeft, backRight);
	robotDrive.setSafetyEnabled(false);
	
	
}

}

The frontRight, backLeft, and backRight pointers are null because those constructor lines are commented out. This would likely cause a null pointer exception in the robotDrive constructor. Also, if you wrap your code in code tags (highlight the block and click the # symbol), it’s easier to read.

I realize that they are commented out. Currently I am only calling on the single motor and it still says that it is a NullPointer

Yep GeeTwo is right. frontRight is being created but you are not assigning it to a new’d object instance, so it stays null.

Remember frontRight is just a reference. In java you must assign to the return of a new operator to actually create the relevent object. If you put a breakpoint just before the NullException occurs and add frontRight to your watch list, you’ll see it’s null.

Yeah but robotDrive is still created and used, which uses all four underneath.

The null pointer exception is probably being thrown by the new RobotDrive() constructor, which has three null pointers. If you just want to test one motor, use a manipulator sample code rather than drive code.