|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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) |
|
#2
|
||||
|
||||
|
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; |
|
#3
|
||||
|
||||
|
Re: Porting Talon SRX
Link to get the Talon SRX Software reference manual...
http://www.ctr-electronics.com/contr...ical_resources |
|
#4
|
|||
|
|||
|
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)
|
|
#5
|
||||
|
||||
|
Re: Porting Talon SRX
Quote:
|
|
#6
|
||||
|
||||
|
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. |
|
#7
|
|||
|
|||
|
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); } } |
|
#8
|
|||||
|
|||||
|
Re: Porting Talon SRX
Quote:
|
|
#9
|
|||
|
|||
|
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
|
|
#10
|
||||
|
||||
|
Re: Porting Talon SRX
Yeah but robotDrive is still created and used, which uses all four underneath.
|
|
#11
|
|||||
|
|||||
|
Re: Porting Talon SRX
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.
|
|
#12
|
||||
|
||||
|
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. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|