Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   CANJaguar (http://www.chiefdelphi.com/forums/showthread.php?t=100713)

otherguy 24-01-2012 00:09

Re: CANJaguar
 
Quote:

Originally Posted by Kodiak (Post 1111683)
Yup, he is right, you having that is like pretty much trying to make two jaguars of the same variable name, and in any programming language you can't simply do that.

Just to be clear, you CAN do that in java, you're just not going to be referring to the same variable throughout the program. If every variable name had to be completely unique, you wouldn't be able to use the same variable names as any of the variables used in the classes you import. For any large scale program it would get difficult pretty quickly to keep track of what variable names were used where.

His code will compile and run as it was, it's just not going to do what he expected it to.

Kodiak 24-01-2012 09:55

Re: CANJaguar
 
Quote:

Originally Posted by otherguy (Post 1112430)
Just to be clear, you CAN do that in java, you're just not going to be referring to the same variable throughout the program. If every variable name had to be completely unique, you wouldn't be able to use the same variable names as any of the variables used in the classes you import. For any large scale program it would get difficult pretty quickly to keep track of what variable names were used where.

His code will compile and run as it was, it's just not going to do what he expected it to.

True, I did not clarify correctly, I have a problem of doing that, my bad, haha

emusteve 25-01-2012 14:39

Re: CANJaguar
 
Could someone kindly tell me where you found documentation on using CAN under Java? I've searched in the "Getting Started with JAVA", "WPI Robotics Library User’s Guide", and "WPI Library Cookbook" publications, but have somehow missed it if it is in there. Went back to First Forge, but couldn't locate any additional documentation that seemed like it would point me in the right direction.

If anyone knows of an example project, that would be appreciated as well.

Thanks,
Steve

nickpeq 25-01-2012 18:36

Re: CANJaguar
 
Quote:

Originally Posted by emusteve (Post 1113378)
Could someone kindly tell me where you found documentation on using CAN under Java? I've searched in the "Getting Started with JAVA", "WPI Robotics Library User’s Guide", and "WPI Library Cookbook" publications, but have somehow missed it if it is in there. Went back to First Forge, but couldn't locate any additional documentation that seemed like it would point me in the right direction.

If anyone knows of an example project, that would be appreciated as well.

Thanks,
Steve

This is the most I've ever been able to find: https://decibel.ni.com/content/docs/DOC-14865

Kodiak 25-01-2012 20:39

Re: CANJaguar
 
Quote:

Originally Posted by emusteve (Post 1113378)
Could someone kindly tell me where you found documentation on using CAN under Java? I've searched in the "Getting Started with JAVA", "WPI Robotics Library User’s Guide", and "WPI Library Cookbook" publications, but have somehow missed it if it is in there. Went back to First Forge, but couldn't locate any additional documentation that seemed like it would point me in the right direction.

If anyone knows of an example project, that would be appreciated as well.

Thanks,
Steve

http://www.wbrobotics.com/javadoc/in...e-summary.html

That should also help some what.

emusteve 25-01-2012 21:31

Re: CANJaguar
 
Thanks guys, I downloaded the NI doc and will look at that tonight.

I had found the wrobotics site via Google, but as I'm new to Java, it is still a bit cryptic to my eyes. I'm wondering where they found that reference. I do wish it gave some examples. Looks like it originated at WPI, but scouring FIRST Forge turned up nada. Thanks to them for putting it up.

I'll keep watching this thread to see what success you have. Share ours as well (assuming we achieve some.)

Thanks again,
Steve

otherguy 25-01-2012 22:55

Re: CANJaguar
 
the info posted on the wrobotics site is called a JavaDoc, and it's a standard form of documentation that can be generated from JAva code automatically (as long as it'a commented properly). The JAvadocs for WPILib is distributed with the plugin package that you installed.

You can access these files locally on your machine by clicking the first logo in the bar at the top of NetBeans (Assuming that's what you're using), it should be the first link on the page that loads.

Check out some helpful guides on my teams site on:
Getting started with Java: Lecture 1, Lecture 2
JavaDocs: Intro/Setup, Use
CAN Jaguars

You're going to want to focus on the CANJaguar class.

Use is as simple as placing the following lines in the right places in your code.
Code:

import edu.wpi.first.wpilibj.CANJaguar;
CANJaguar leftMotor = new CanJaguar(12); //where 12 is the CAN ID assigned to the motor controller
leftMotor.set(x.x);    //where x.x is a value between -1.0 and 1.0 (or your joystick axis...)

Note the default mode of operation is %VBus, which is comparable to PWM, read up on our site and the NI docs to learn about the other modes of operation if that's your goal.


All times are GMT -5. The time now is 11:16.

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