Go to Post The mission of FIRST is not just to promote science and technology, but to help every student involved to reach their full potential and achieve their dreams - Mike Ciance [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 13-01-2016, 14:12
VaneRaklan VaneRaklan is offline
Registered User
FRC #2557 (The SOTABots)
Team Role: Programmer
 
Join Date: Feb 2015
Rookie Year: 2014
Location: Tacoma, WA
Posts: 18
VaneRaklan is an unknown quantity at this point
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)
Reply With Quote
  #2   Spotlight this post!  
Unread 13-01-2016, 14:51
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 522
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
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);
It sounds like you are just doing
Code:
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).
Reply With Quote
  #3   Spotlight this post!  
Unread 13-01-2016, 15:02
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 522
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
Re: Porting Talon SRX

Link to get the Talon SRX Software reference manual...
http://www.ctr-electronics.com/contr...ical_resources
Reply With Quote
  #4   Spotlight this post!  
Unread 13-01-2016, 15:35
VaneRaklan VaneRaklan is offline
Registered User
FRC #2557 (The SOTABots)
Team Role: Programmer
 
Join Date: Feb 2015
Rookie Year: 2014
Location: Tacoma, WA
Posts: 18
VaneRaklan is an unknown quantity at this point
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)
Reply With Quote
  #5   Spotlight this post!  
Unread 13-01-2016, 15:52
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,077
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Porting Talon SRX

Quote:
Originally Posted by VaneRaklan View Post
Like I said, If I knew how to add my code to a reply you could see what I am doing.
Is there some reason why you can't just cut and paste the relevant portion(s)?


Reply With Quote
  #6   Spotlight this post!  
Unread 13-01-2016, 16:09
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 522
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
Re: Porting Talon SRX

Quote:
Originally Posted by VaneRaklan View Post
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)
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 support@crosstheroadelectronics.com, and I'll bounce it back to this thread.
Reply With Quote
  #7   Spotlight this post!  
Unread 13-01-2016, 16:33
VaneRaklan VaneRaklan is offline
Registered User
FRC #2557 (The SOTABots)
Team Role: Programmer
 
Join Date: Feb 2015
Rookie Year: 2014
Location: Tacoma, WA
Posts: 18
VaneRaklan is an unknown quantity at this point
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);


}
}
Reply With Quote
  #8   Spotlight this post!  
Unread 13-01-2016, 16:42
GeeTwo's Avatar
GeeTwo GeeTwo is online now
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,609
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Porting Talon SRX

Quote:
Originally Posted by VaneRaklan View Post
Code:
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.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
  #9   Spotlight this post!  
Unread 13-01-2016, 16:44
VaneRaklan VaneRaklan is offline
Registered User
FRC #2557 (The SOTABots)
Team Role: Programmer
 
Join Date: Feb 2015
Rookie Year: 2014
Location: Tacoma, WA
Posts: 18
VaneRaklan is an unknown quantity at this point
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
Reply With Quote
  #10   Spotlight this post!  
Unread 13-01-2016, 16:46
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 522
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
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.
Reply With Quote
  #11   Spotlight this post!  
Unread 13-01-2016, 16:47
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 522
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
Re: Porting Talon SRX

Quote:
Originally Posted by VaneRaklan View Post
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
Yeah but robotDrive is still created and used, which uses all four underneath.
Reply With Quote
  #12   Spotlight this post!  
Unread 13-01-2016, 16:49
GeeTwo's Avatar
GeeTwo GeeTwo is online now
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,609
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Porting Talon SRX

Quote:
Originally Posted by VaneRaklan View Post
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
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.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 22:36.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi