Last active
November 26, 2019 23:26
-
-
Save dmalawey/e51e9d0cfd54f04dbdf6f1b6f089ea3b to your computer and use it in GitHub Desktop.
remo mods for Scuttle Robot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is the SCUTTLE replacement for the adafruit_pwm.py file | |
# Use this program to overwrite the original adafruit_pwm.py contents. | |
def setup(robot_config): # setup is a required function for the selected hardware program | |
return | |
# A function for sending command to a file in the temporary folder | |
def tmpFile(value): # this function takes a 2-element array called val | |
txt = open("/tmp/commandFile.txt",'w+') # file with specified name | |
txt.write(str(value)) | |
txt.close() | |
# "move" is the name of the function in the original adafruit_pwm.py program | |
def move(args): | |
command = args['button']['command'] | |
tmpFile(command) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# remoDriver.py | |
# run this program with python3 while the remo controller is operating | |
# Import external libraries | |
import time # only necessary if running this program as a loop | |
import numpy # for clip function | |
import os.path # for checking file paths | |
from os import path # for checking file paths | |
# import local programs | |
import L2_inverse_kinematics as inv | |
import L2_speed_control as sc | |
filename = "/tmp/commandFile.txt" # File path we will send our battery voltage data to. | |
while not path.exists(filename): # wait to see that the command file exists | |
time.sleep(0.25) | |
pass | |
while path.exists(filename): # Infinite loop, after the file is made | |
file = open(filename,"r") # Open command file. | |
cmd = file.read() # Read data in file and store in cmd | |
if len(cmd) > 0: # Makes sure the command holds a value | |
if cmd == "w": | |
targets = np.array([0.3,0]) # assign targets to x-dot, theta-dot (fwd) | |
elif cmd == "s": | |
targets = np.array([-0.3,0]) # assign targets to x-dot, theta-dot (reverse) | |
elif cmd == "a": | |
targets = np.array([0,1]) # assign targets to x-dot, theta-dot (left) | |
elif cmd == "d": | |
targets = np.array([0,-1]) # assign targets to x-dot, theta-dot (right) | |
else: # If file is empty move on. | |
Targets = np.array([0,0]) # [xd, td] | |
pass | |
pdTargets = inv.convert(targets) # convert [xd,td] to [pdl,pdr] | |
#sc.drive(pdTargets) # send the pd targets to the speed controller | |
print("pd targets:", pdTargets) | |
time.sleep(0.2) | |
txt = open("/tmp/commandFile.txt",'w+') # file with specified name | |
txt.write(str(0)) | |
txt.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment