Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Python (http://www.chiefdelphi.com/forums/forumdisplay.php?f=187)
-   -   CAN Jaguar (http://www.chiefdelphi.com/forums/showthread.php?t=133736)

Pramizle 30-01-2015 20:59

CAN Jaguar
 
My team is having extreme difficulty in regards to using the CAN Jaguar class. The current code that we are using to initialize it is:

self.jaguar = wpilib.CANJaguar(1,4)

From this line of code we get an error saying that two values are needed but that the code is entering in three.

Please help. We are completely lost and are losing hair as well as sleep.

ozrien 30-01-2015 22:15

Re: CAN Jaguar
 
did you mean...
self.jaguar = new CANJaguar(1);
... your using java right?

Also I only see one param for the constructor. What is '4' supposed to be. I assume '1' is the device ID.

virtuald 31-01-2015 00:10

Re: CAN Jaguar
 
Quote:

Originally Posted by Pramizle (Post 1436377)
My team is having extreme difficulty in regards to using the CAN Jaguar class. The current code that we are using to initialize it is:

self.jaguar = wpilib.CANJaguar(1,4)

From this line of code we get an error saying that two values are needed but that the code is entering in three.

Please help. We are completely lost and are losing hair as well as sleep.

The error message is correct. In python there is an implicit first parameter called 'self', so when you pass it 2 parameters, you actually passed it three.

Instead, you should initialize the CANJaguar like so:

Code:

self.jaguar = wpilib.CANJaguar(1)
As referenced in the RobotPy CANJaguar documentation, there's only a single parameter you need to pass to the CANJaguar object, which is the deviceNumber.

Make sure that you're using the very latest version of RobotPy, as the CANJaguar object has had a lot of bugfixes this season!

Quote:

Originally Posted by ozrien (Post 1436398)
did you mean...
self.jaguar = new CANJaguar(1);
... your using java right?

Also I only see one param for the constructor. What is '4' supposed to be. I assume '1' is the device ID.

This is the python forum. :)

NegaNexus 31-01-2015 01:38

Re: CAN Jaguar
 
I am also from the TeraViks. I knew that 'self' was implied, but how does one specify the use of the different Control Modes without this method.

virtuald 31-01-2015 01:56

Re: CAN Jaguar
 
I imagine you'd probably want to call the appropriate method. Maybe... changeControlMode?

To be fair, the documentation is a bit confusing in its format. The ControlMode displayed at the top is just enumerating what types are available, and does not indicate that it's a parameter you can pass to the constructor.

ozrien 31-01-2015 16:00

Re: CAN Jaguar
 
Quote:

Originally Posted by virtuald (Post 1436436)
This is the python forum. :)

Haha oops, sorry Dustin...doing to many things at once. I'll shut up now...

NegaNexus 01-02-2015 20:06

Re: CAN Jaguar
 
Now, when I try this:

Code:

self.jaguar = wpilib.CANJaguar(1)
self.jaguar.setVoltageModeEncoder(360)
self.jaguar.enableControl()

I get:
Code:

raise frccan.CANMessageNotFound("message not found")
hal.exceptions.CANMessageNotFound: message not found

How do I prevent this?

virtuald 01-02-2015 23:47

Re: CAN Jaguar
 
That sounds like a bug in RobotPy's WPILib. Do you have a stack trace you can paste?

NegaNexus 01-02-2015 23:55

Re: CAN Jaguar
 
Code:

16:07:23:251 INFO    : wpilib              : WPILib version 2015.0.8
16:07:23:253 INFO    : wpilib              : HAL base version 2015.0.8; roboRIO platform version 2015.0.8
16:07:23:254 INFO    : wpilib              : HAL library version jenkins-stable-2015.326
16:07:23:549 WARNING : robotpy            : Robots don't quit!
16:07:23:551 ERROR  : robotpy            : ---> The startCompetition() method (or methods called by it) should have handled the exception.
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/wpilib/robotbase.py", line 185, in main
    robot.startCompetition()
  File "/usr/local/lib/python3.4/site-packages/wpilib/iterativerobot.py", line 75, in startCompetition
    self.robotInit()
  File "robot.py", line 21, in robotInit
    self.jaguar = wpilib.CANJaguar(1)
  File "/usr/local/lib/python3.4/site-packages/wpilib/canjaguar.py", line 293, in __init__
    raise frccan.CANMessageNotFound("message not found")
hal.exceptions.CANMessageNotFound: message not found


Locals at innermost frame:

{ 'data': [225, 31, 0, 0],
  'deviceNumber': 1,
  'i': 49,
  'receivedFirmwareVersion': True,
  'self': <wpilib.canjaguar.CANJaguar object at 0x42c2c810>}


virtuald 02-02-2015 00:12

Re: CAN Jaguar
 
Interesting. That error message is terrible -- but the code seems to indicate that it can't find the CANJaguar. Are you sure ID 1 is the right ID for the Jaguar -- or that perhaps there's another device on ID 1? Most of the time it is recommended to not use ID 1, as that's the default ID for a lot of devices.

NegaNexus 02-02-2015 01:46

Re: CAN Jaguar
 
Though I can't truly verify it, I checked it today and it said on the web interface that the PCM was assigned to Device ID #0 and the PDP was Device #2 and the Jaguar was assigned to Device #1. I will be back there on Tuesday.

RufflesRidge 02-02-2015 07:05

Re: CAN Jaguar
 
Quote:

Originally Posted by NegaNexus (Post 1437183)
Though I can't truly verify it, I checked it today and it said on the web interface that the PCM was assigned to Device ID #0 and the PDP was Device #2 and the Jaguar was assigned to Device #1. I will be back there on Tuesday.

If you do find the PDP is ID = 2, I would change the PDP back to ID = 0 in case you want to use any of the CAN features of it. ID = 0 is all that is currently supported in C++, Java and Python: http://robotpy.readthedocs.org/en/la...tionPanel.html

Devices of different types do not conflict so having the PCM and PDP both at 0 is not an issue.

Another thing to check would be your CAN error counts on the last tab on the left side of the DS.

NegaNexus 08-02-2015 00:45

Re: CAN Jaguar
 
A week ago it decided to work. One of the problems was that the Jaguar Device ID # couldn't ever be changed. We pressed the user button within 5 seconds. We just mucked with stuff, and eventually, the Jaguar worked, though we still were unable to change the ID.

I don't have any idea why it did that, but I just know to muck around with some semblance of method from what I learned and it might work.

Pramizle 16-02-2015 19:04

Re: CAN Jaguar
 
Thank you so much for all of your help. We were able to get it moving and moved on to bigger and better things... Like using PID :P


All times are GMT -5. The time now is 19:50.

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