def __init__(self): # Initialise file data list self.gcode_data_list = [] # gcode_path = read_from_args # self.load_gcode_from_file("test.gcode") self.load_gcode_from_file(sys.argv[1]) # Instantiate motor controller objects self.mc = mc.MotorController() # Store the different axes in use self.axes = ('x', 'y', 'z') self.axes_thread = {} self.line_count = 0 self.line_counter = 0 self.interpret_data()
def __init__(self, axis_name, start, stop, step, hp_avgs=100, hp_range=0.1, mc=None, min_trigger_time=0.2): # usually would provide a motor controller instance to avoid permission errors self.mc = motor_controller.MotorController() if mc is None else mc if axis_name not in ('x', 'y', 'z'): raise InputError(f"can't scan along axis '{axis_name}'") self.axis_name = axis_name self.axis = self.mc.axis[axis_name] self.hp = hall_probe.MetrolabProbe() self.hp.setAverages(hp_avgs) self.hp.setRange(hp_range) self.start = start self.stop = stop self.step = step self.pos_values = arange(start, stop, step) self.n_steps = len(self.pos_values) self.field_values = np.zeros((len(self.pos_values), 3)) if axis_name in ('x', 'z'): self.on_the_fly = True ad8102 = adlink_card.AdlinkCard() self.enc_axis = ad8102.axis['z'] #axis_name] speed = min(self.step / min_trigger_time, self.axis.max_speed ) # set time longer if get MissedTriggerErrors print(f'speed = {speed:.3f} mm/s') self.speed = speed self.axis.setSpeed() # max speed to get to start position else: self.on_the_fly = False self.enc_axis = None
""" # -*- coding: utf-8 -*- Created on Fri Feb 16 02:54:09 2018 @author: Etcyl """ import motor_controller as MC import ultrasonic as US import RPi.GPIO as GPIO import support_funcs as sf #DO setup here #Set GPIO mode to BCM GPIO.setmode(GPIO.BCM) #Create objects for Vikingbot motor controller and HC-SR04 sensor vb_motor = MC.MotorController() HC_sensor = US.Ultrasonic() HC_sensor.setup_GPIO() vb_motor.setup_GPIO(1, 0) # setup and start PWM set the dulty cycles to 90 vb_motor.setup_PWM() vb_motor.start_PWM() vb_motor.set_motorSpeed(90, 90) # set the delay between motions to 2 seconds vb_motor.set_SleepTime(2) sensor_vals = [0] * 3 #...Finished setup
# 1: on board DIP switch (SW1) dll._8102_initial(card_id, 0) dll._8102_config_from_file( ) # set from C:\Windows\System32\8102.ini - use MotionCreatorPro to alter # Enable the Windows interrupt control for the card dll._8102_int_control(0, int(True)) self.axis = { 'z': Axis(dll, 0, card_id=0), 'x': Axis(dll, 1, card_id=0) } if __name__ == '__main__': import motor_controller mc = motor_controller.MotorController() ad8102 = AdlinkCard() for axis_name in 'x': #, 'z': axis = mc.axis[axis_name] enc_axis = ad8102.axis[axis_name] encoder_pos = axis.get_position(set_value=False) * axis.scale_factor print('\n', axis_name, 'encoder position (from MC):', encoder_pos) enc_axis.setPosition(encoder_pos) move_amount = 1 print('moving by', move_amount) axis.move(move_amount, relative=True, wait=True, tolerance=0.001) print('MC pos', axis.get_position(set_value=False) * axis.scale_factor) print('enc pos', enc_axis.getPosition())
import motor_controller as MC import ultrasonic as US import RPi.GPIO as GPIO import subprocess #set GPIO mode to BCM GPIO.setmode(GPIO.BCM) # create objects for motor controller and distance sensor vikingbotMotors = MC.MotorController() ultrasonicSensorBack = US.Ultrasonic() #GPIO.cleanup() # setup the motors vikingbotMotors.setup_GPIO(1, 0) # setup and start PWM set the dulty cycles to 90 vikingbotMotors.setup_PWM() vikingbotMotors.start_PWM() vikingbotMotors.set_motorSpeed(55, 100) # set the delay between motions to 2 seconds vikingbotMotors.set_SleepTime(2) #Test the movements #Test singing frog GPIO.setup(19, GPIO.OUT) GPIO.output(19, GPIO.HIGH) print "Frog is singing"
#!/usr/bin/env python #import required libraries import time import RPi.GPIO as GPIO import curses, sys import motor_controller import screen_controller #ssh [email protected] #cd /opt/agnostobot/AgnostobotController #python agnostobot_controller.py robot = motor_controller.MotorController() actions = { curses.KEY_UP: robot.forward, curses.KEY_DOWN: robot.backward, curses.KEY_LEFT: robot.left, curses.KEY_RIGHT: robot.right, ord('='): robot.increase_speed, ord('-'): robot.decrease_speed, } def Exit(): global robot robot.stop_motor_controller() def Agnostobot(screen):
import time import sys sys.path.insert(0, '/home/pi/boat-os/observing') sys.path.insert(0, '/home/pi/boat-os/control') import data_gatherer as dg import gather_test as gt import motor_controller as mc #gather = gt.DataGathererTest(0.1) #Create a data-gathering thread that runs with 0.1 s delays, not including motor-adjustment time dataGatherer = dg.DataGatherer(0.1) #Create a motor-controlling thread that runs with 0.1 s delays, not including data-gathering time motorControl = mc.MotorController(0.1, 1000) #gather.start() dataGatherer.start() motorControl.start() #gather.join() # dataGatherer.join() means that this script cannot do anything else until dataGatherer stops running dataGatherer.join() # motorControl.join() means that this script cannot do anything else until motorControl stops running motorControl.join()
import RPi.GPIO as GPIO import time import motor_controller pin1 = 3 pin2 = 4 GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(pin1, GPIO.OUT) GPIO.setup(pin2, GPIO.OUT) mc = motor_controller.MotorController(pin1, pin2) try: while True: tmp = input().split() speed = float(tmp[0]) steer = float(tmp[1]) mc.walk(speed, steer) except KeyboardInterrupt: pass finally: GPIO.cleanup() print('\rInterrupt received, exiting')