Go to Post Is FIRST making it too easy?... yes they are making it easier than years past. But I would also say that does that matter? If students are still inspired to pursue more advanced designs and eventually a career in the technology sector we still have met our ultimate goal. - MikeDubreuil [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 27-01-2017, 16:27
StrMNX StrMNX is offline
Registered User
no team
 
Join Date: Oct 2016
Location: Youngstown Ohio
Posts: 12
StrMNX is an unknown quantity at this point
CANTalon Python Help

So i'm trying to run a CANTalon at some RPM. i decided on PIDF control. i chose 1366 RPM because its the speed done in the Software Reference Manual. i've tried to convert the java code into python, but the shooter refuses to run. can anyone help me?

Code:
#!/usr/bin/env python3

import wpilib
import ctre
from networktables import NetworkTable

class MyRobot(wpilib.IterativeRobot):
    
    def robotInit(self):
        self.Shooter = ctre.CANTalon(1)
        self.Shooter.reverseOutput(False)
        
        self.Shooter.setFeedbackDevice(ctre.CANTalon.FeedbackDevice.CtreMagEncoder_Relative)
        
        self.Shooter.configNominalOutputVoltage(float(+0.0), float(-0.0))
        self.Shooter.configPeakOutputVoltage(float(+12.0), float(-12.0))
        
        self.Shooter.setProfile(0)
        self.Shooter.setF(0.1097)
        self.Shooter.setP(0)
        self.Shooter.setI(0)
        self.Shooter.setD(0)
        
        self.Shooter.changeControlMode(ctre.CANTalon.ControlMode.Speed)
        self.xb = wpilib.Joystick(2)
        
    
        
        self.sd = NetworkTable.getTable('SmartDashboard')
    def teleopPeriodic(self):
        
        self.sd.putNumber("Velocity", self.Shooter.getSpeed())
        if(self.xb.getRawButton(5)):
            self.Shooter.set(1366)
            
        else:
            self.Shooter.set(0)

if __name__ == "__main__":
    wpilib.run(MyRobot)
Reply With Quote
 


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 05:10.

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