OCCRA
Go to Post And those who DO know won't talk, even for Krispy Kremes. - DonRotolo [more]
Home
Go Back   Chief Delphi > Technical > Programming > Python
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 02-06-2018, 06:12 PM
loveshark's Avatar
loveshark loveshark is offline
Registered User
FRC #3145 (Teraviks)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Coeur d'alene Idaho
Posts: 12
loveshark is an unknown quantity at this point
Can TalonSRX Motion Magic

Our team is looking to use PID with one of our talons, and from what we've researched Motion Magic is the simplest option. Our problem is that we don't seem to know exactly how to use the motion magic capabilities of the SRX. We tried out the following code but to no avail.

Code:
#configuration
self.talon.configSelectedFeedbackSensor(0,0,0)
self.talon.configMotionAcceleration(self.talon.getQuadraturePosition(), 0)
self.talon.configMotionCruiseVelocity(self.talon.getQuadraturePosition(), 0)

#some thing to run the motor
self.talon.set(self.talon.ControlMode.MotionMagicArc, ctre.wpi_talonsrx.MotionMagicArc.PercentOutput, 1)
This obviously doesn't work, but does anybody here have experience using motion magic with the CAN TalonSRX? What worked for you?

Thanks in advance.
Reply With Quote
  #2   Spotlight this post!  
Unread 02-06-2018, 09:29 PM
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #6367 (), FRC #7240 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,388
virtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond repute
Re: Can TalonSRX Motion Magic

Unfortunately, I've not used Motion Magic myself personally, but in theory the Python API should be really close to the Java API (and if it's not, please file a bug on github highlighting the discrepancy!).

You can find the CTRE SRX examples at https://github.com/CrossTheRoadElec/...ples-Languages . If you have specific pieces that you're finding difficult to translate, please let me know.
__________________
Maintainer of RobotPy (Python for FRC) & WPILib Contributor
Creator of pyfrc (Robot Simulator + utilities for Python), pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript), and lots more...

Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #3   Spotlight this post!  
Unread 02-06-2018, 09:47 PM
nickbrickmaster nickbrickmaster is offline
Human left pad
AKA: Nick Schatz
no team (3184 Alum)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2014
Location: Eagan MN
Posts: 440
nickbrickmaster has a reputation beyond reputenickbrickmaster has a reputation beyond reputenickbrickmaster has a reputation beyond reputenickbrickmaster has a reputation beyond reputenickbrickmaster has a reputation beyond reputenickbrickmaster has a reputation beyond reputenickbrickmaster has a reputation beyond reputenickbrickmaster has a reputation beyond reputenickbrickmaster has a reputation beyond reputenickbrickmaster has a reputation beyond reputenickbrickmaster has a reputation beyond repute
Re: Can TalonSRX Motion Magic

Quote:
Originally Posted by loveshark View Post
Our team is looking to use PID with one of our talons, and from what we've researched Motion Magic is the simplest option. Our problem is that we don't seem to know exactly how to use the motion magic capabilities of the SRX. We tried out the following code but to no avail.

Code:
#configuration
self.talon.configSelectedFeedbackSensor(0,0,0)
self.talon.configMotionAcceleration(self.talon.getQuadraturePosition(), 0)
self.talon.configMotionCruiseVelocity(self.talon.getQuadraturePosition(), 0)

#some thing to run the motor
self.talon.set(self.talon.ControlMode.MotionMagicArc, ctre.wpi_talonsrx.MotionMagicArc.PercentOutput, 1)
This obviously doesn't work, but does anybody here have experience using motion magic with the CAN TalonSRX? What worked for you?

Thanks in advance.
"Not working" is a very large class of things. Please expand on the behavior you're seeing and your expected behavior.

However I see a few problems right away.
1. You should be passing one of FeedbackDevice depending on what sensor you're using into configSelectedFeedbackSensor.

2. What do you expect to happen by feeding the current position of the sensor into configMotionAcceleration and configMotionCruiseVelocity? You should be giving these methods numbers related to the physical properties of your robot, not the current position of its wheels.

3. talon.set() takes a ControlMode (which you should be using MotionMagic, not MotionMagicArc probably) and a demand, which for MotionMagic is the distance you want to travel.

If you're interested, we used motion magic last year. Our code uses the old API, with different methods and units, but you may be able to get a general sense of what needs to happen. Please do not just copy this code, as it plain does not work any more.

Other than that I highly recommend reading the documentation as Dustin suggested. Read through the Motion Magic section of the Software Reference Manual, then check out the examples.
__________________
Proceed as if success is inevitable.
Reply With Quote
  #4   Spotlight this post!  
Unread 02-06-2018, 10:57 PM
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #6367 (), FRC #7240 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,388
virtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond repute
Re: Can TalonSRX Motion Magic

I put together one of the examples from the CTRE projects, but it doesn't function properly in simulation yet (though perhaps it works on a real robot?).

If you want to take a look, check out the magic-example branch on the robotpy-ctre project. Once I get the sim issues fixed, we'll push it to master too.
__________________
Maintainer of RobotPy (Python for FRC) & WPILib Contributor
Creator of pyfrc (Robot Simulator + utilities for Python), pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript), and lots more...

Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #5   Spotlight this post!  
Unread 02-08-2018, 11:35 AM
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #6367 (), FRC #7240 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,388
virtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond repute
Re: Can TalonSRX Motion Magic

The motion magic example has been pushed to master, and it even works in simulation now!
__________________
Maintainer of RobotPy (Python for FRC) & WPILib Contributor
Creator of pyfrc (Robot Simulator + utilities for Python), pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript), and lots more...

Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #6   Spotlight this post!  
Unread 06-22-2018, 05:10 PM
adamthekiwi adamthekiwi is offline
Registered User
FRC #6517
 
Join Date: Jan 2018
Location: Tennessee
Posts: 7
adamthekiwi is an unknown quantity at this point
Re: Can TalonSRX Motion Magic

Thanks for all the effort you put into this. For someone still learning Git, would you mind expanding on the easiest way for us to view the example? Thanks for the help.
Reply With Quote
  #7   Spotlight this post!  
Unread 06-22-2018, 07:08 PM
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #6367 (), FRC #7240 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,388
virtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond repute
Re: Can TalonSRX Motion Magic

https://github.com/robotpy/robotpy-c...s/motion_magic
__________________
Maintainer of RobotPy (Python for FRC) & WPILib Contributor
Creator of pyfrc (Robot Simulator + utilities for Python), pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript), and lots more...

Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
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 11:44 AM.

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


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