View Single Post
  #12   Spotlight this post!  
Unread 26-01-2016, 22:15
TheHolyHades1 TheHolyHades1 is offline
Registered User
no team
 
Join Date: Jan 2014
Rookie Year: 2010
Location: usa
Posts: 145
TheHolyHades1 is a jewel in the roughTheHolyHades1 is a jewel in the roughTheHolyHades1 is a jewel in the rough
Re: Programming for TalonSRX without RoboRIO?

I realize it's been a while, but an update.

I've written a python module that works very similarly to the CanTalonSRX libraries in WPIlib. While I haven't gotten around to publishing documentation or usage yet, it should be feature complete as far as I know. If there's interest in me providing some documentation and thoroughly commenting the code, I can do that. That said, a bit of usage:

Code:
from PyCanTalonSRX import *
import can

bus = can.interface.Bus()

talon = CanTalonSRX(20) # dev id for talon
talon.set_mode(Mode.DutyCycle) # set mode

while True:

    # see if any messages need to be sent to the talon, and send them
    if not talon.txQueue.empty():
        msg = talon.txQueue.get_nowait()
        msg.timestamp = time.time()
        bus.send(msg)
    
    # see if we need to receive a message from the talon
    recv = bus.recv(0.0)
    if recv != None:
        talon.update(recv)

    # Other logic to run continuously
https://github.com/VasuAgrawal/PyCanTalonSRX

I can add additional functionality as desired, but in my application this has been enough. I've successfully used this package to control a couple Talons with ROS. Please PM me with any questions.

EDIT: Note, you'll also need a custom firmware, which I was able to get from Omar at CTRE.