![]() |
CANJaguar
Hello,
I am not new to Java, but I am new to the code for the wpi, so I was looking at the API and was especially looking at CANJaguar. My question is that in order to use CAN, do I make an instance of CANJaguar for each jaguar used, or is it only one instance, and I make an instance of Jaguar for the amount used? Also would I need to use it within the drive train? In the end, I am pretty much asking how to set up CAN withing Java. |
Re: CANJaguar
The CANJaguar class represents a jaguar. So yes, you need one for each physical jaguar. To set up the drive train, you create all of the jaguars needed and then call the robotDrive constructor with each of the jaguars.
For programming, the only practical difference between CANJaguar and Jaguar is that CANJaguar has more methods (for things like setting PID constants), so if you find a tutorial on how to set things up with normal Jaguars, you just replace the class names with CANJaguar and you should be set. |
Re: CANJaguar
Awesome, that makes it much simpler, also on the ID, its the id you issue the Jaguar when you update the firmware correct? or is in in order they are setup along the CAN
|
Re: CANJaguar
It's the one where you set the number and then press the button on the jaguar (the ID). The order makes absolutely no difference (except for the whole "wire can't be too long" thing)
|
Re: CANJaguar
Ha, how can the wire be too long? on such a short distance with data flying at 1mbs and the Jaguars acting as switches. Also I would like your input on this, for Joystick input, would it be best on Periodic or Continuous?
|
Re: CANJaguar
Quote:
Read joystick should probably go in Periodic. Continuous will read the joystick as fast as possible. Periodic will read the joystick at precise intervals (200Hz I think). Honestly, in reference to the system response time of "Joystick moved -> Joystick value read -> Joystick value interpreted -> Motor value sent -> Motor starts moving", the moving of the motor is the longest part (by quite a bit). Running in continuous only makes more requests and sends more control packets (unnecessarily) utilizing more system bandwidth. - Bryce |
Re: CANJaguar
Quote:
|
Re: CANJaguar
Quote:
Quote:
Quote:
This 20' limitation does have to do with the CAN driver: When all the Jaguars are responding at the same time to broadcast messages they drive the bus slightly higher than a single Jag would. It takes longer for the bus to return to 'zero' and therefor some Jaguars may not read the bit correctly if the bit hasn't had time to settle. The time from high to low depends on the termination resistance as well. This is the reason why we also specify a 100 ohm termination resistor. It helps snap the bus back to zero quickly so there aren't any bit timing errors. We found that 20' of cable, 100 ohm termination resistors, and ~16 Jags on a bus is a good limit for reliable operation. It may be possible to get more Jags, but the cable lengths will have to be shorter. -David |
Re: CANJaguar
Quote:
|
Re: CANJaguar
How do we know if we have regular jaguars or CAN jaguars? Also, if we use jaguars does this mean we actually need to declare 4 jaguar instances to drive the robot? Can we do something like
Code:
public void robotInit() { |
Re: CANJaguar
Quote:
And what I did with the jaguar is create an instance for each jaguar outside of any of the Init's. Then on the RobotInit(), I initialized them along with the drive train. Code:
public class Team3325 extends IterativeRobot { |
Re: CANJaguar
Besides variables going out of scope, the code you have posed there would do ok. To answer your question about creating Jaguar instances, you can create a RobotDrive both ways
Code:
RobotDrive(int frontLeftMotor, int rearLeftMotor, int frontRightMotor, int rearRightMotor);EDIT: Also, its more common to use the y axis of each joystick to control motor speeds than it is the throttle, but obviously you can do whatever you wish. |
Re: CANJaguar
Quote:
|
Re: CANJaguar
Thank you for your replies. No matter what we try we cannot seem to get our robot to move. This is the code I have been trying:
Code:
package edu.wpi.first.wpilibj.templates; |
Re: CANJaguar
Quote:
|
| All times are GMT -5. The time now is 08:44 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi