![]() |
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) |
Re: Porting Talon SRX
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... Code:
CANTalon customMotorDescript = new CANTalon(0);Code:
CANTalon customMotorDescript; |
Re: Porting Talon SRX
Link to get the Talon SRX Software reference manual...
http://www.ctr-electronics.com/contr...ical_resources |
Re: Porting Talon SRX
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)
|
Re: Porting Talon SRX
Quote:
|
Re: Porting Talon SRX
Quote:
Ether is right, just copy/paste the important part. Or zip it up and email to support@crosstheroadelectronics.com, and I'll bounce it back to this thread. |
Re: Porting Talon SRX
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); } } |
Re: Porting Talon SRX
Quote:
|
Re: Porting Talon SRX
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
|
Re: Porting Talon SRX
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. |
Re: Porting Talon SRX
Quote:
|
Re: Porting Talon SRX
Quote:
|
| All times are GMT -5. The time now is 09:17. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi