Пример #1
0
    def load_arduino(self):
        # for communication to arduino
        self.cmdMng = CommandManager.from_configfile(ARDUINO_CONFIG)

        # cooling fan
        self.Fan = self.cmdMng.Fan
        # each axis with Arduino communication, movement rate, min position, max position define
        self.X = Axis(self.cmdMng.X, 0.00937, 0, 510)
        self.Y = Axis(self.cmdMng.Y, 0.00937, 0, 270)
        self.Z = Axis(self.cmdMng.Z, 0.00253, 0, 100)
        self.CX = Axis(self.cmdMng.CX, 0.00937, 0, 510)
        self.CY = Axis(self.cmdMng.CY, 0.00937, 0, 270)

        # create multiaxes for concurrent movement
        self.XY = MultiAxis(self.X, self.Y)
        self.CXY = MultiAxis(self.CX, self.CY)
        self.XY_CXY = MultiAxis(self.X, self.Y, self.CX, self.CY)
        self.BOT = MultiAxis(self.X, self.Y, self.Z, self.CX, self.CY)

        self.BOT.home()
Пример #2
0
import time
import logging
logging.basicConfig(level=logging.INFO)

from commanduino import CommandManager

cmdMng = CommandManager.from_configfile('./demo.json')

for i in range(10):
    F = cmdMng.sht15.get_fahrenheit()
    C = cmdMng.sht15.get_celsius()
    H = cmdMng.sht15.get_humidity()
    print '###'
    print 'Temperature = {} F  /  {} C'.format(F, C)
    print 'Humidity = {}%'.format(H)
    time.sleep(1)
Пример #3
0
import time
import os
import logging
from commanduino import CommandManager

logging.basicConfig(level=logging.INFO)

script_dir = os.path.dirname(__file__)
cm_config = os.path.join(script_dir, 'demo.json')
cmdMng = CommandManager.from_configfile(cm_config)

stepper = cmdMng.stepper

stepper.set_current_position(0)

stepper.enable_acceleration()
stepper.set_acceleration(1000)
stepper.set_max_speed(10000)

print('Moving to 20000 with acceleration 1000')
stepper.move_to(-2000, wait=True)

print('Moving back to 0 with acceleration 5000...')
print('Should turn in the opposite direction no?')
stepper.set_acceleration(5000)
stepper.move_to(-1000, wait=True)


print('Disabling acceleration')
stepper.disable_acceleration()
stepper.set_max_speed(10000)
Пример #4
0
from commanduino import CommandManager

import logging
logging.basicConfig(level=logging.INFO)

# in your two board please load the arduino example OF:
# - CommandServo
# - CommandLinearAccelStepper
cmdMng = CommandManager.from_configfile('./two_boards.json')

s1 = cmdMng.devices['servo1']
s2 = cmdMng.devices['servo2']
m1 = cmdMng.devices['stepper1']

from commandruino.devices.axis import Axis

a = Axis(m1, 0.1)
Пример #5
0
import time
import logging
from commanduino import CommandManager

logging.basicConfig(level=logging.INFO)

cmdMng = CommandManager.from_configfile(
    './examples/commanddevices/commandlinearaccelstepper/demo.json')

stepper = cmdMng.stepper

stepper.set_current_position(0)

stepper.enable_acceleration()
stepper.set_acceleration(1000)
stepper.set_max_speed(10000)

print('Moving to 20000 with acceleration 1000')
stepper.move_to(20000, wait=True)

print('Moving back to 0 with acceleration 5000...')
print('Should turn in the opposite direction no?')
stepper.set_acceleration(5000)
stepper.move_to(0, wait=True)

print('Disabling acceleration')
stepper.disable_acceleration()
stepper.set_max_speed(10000)

print('Moving to 20000 with default speed 1000')
stepper.move_to(20000, wait=False)
Пример #6
0
import time
import logging
logging.basicConfig(level=logging.INFO)

from commanduino import CommandManager

cmdMng = CommandManager.from_configfile(
    './examples/commanddevices/commanddigitalwrite/demo.json')

for i in range(10):
    cmdMng.D1.high()
    time.sleep(1)
    cmdMng.D1.low()
    time.sleep(1)
Пример #7
0
from centripeta import Dispenser, Analyzer
from centripeta.utils import Logger
from pycont.controller import MultiPumpController
from commanduino import CommandManager
import pandas as pd
import logging
import time
import cv2

#Instantiate the command manager
mgr = CommandManager.from_configfile('platform_config_ports.json')
pumps = MultiPumpController.from_configfile('pycont_config.json')
a = Analyzer(mgr)
d = Dispenser(manager=mgr, pump_controller=pumps)

camera = cv2.VideoCapture(0)

for i in range(8):
    return_value, image = camera.read()
    cv2.imwrite('sample' + str(i) + '.png', image)
    img = cv2.imread('sample' + str(i) + '.png')
    cv2.namedWindow('sample' + str(i) + '.png')
    cv2.imshow('sample' + str(i) + '.png', img)
    cv2.waitKey(0)
    a.turn_wheel(n_turns=1)
del (camera)
cv2.destroyAllWindows()
Пример #8
0
import time
import os
import logging
logging.basicConfig(level=logging.INFO)

from commanduino import CommandManager

script_dir = os.path.dirname(__file__)
abs_path = os.path.join(script_dir, 'demo.json')

cmdMng = CommandManager.from_configfile(abs_path)

stepper = cmdMng.stepper

print('Setting current position to 0')
stepper.set_current_position(0)

stepper.enable_acceleration()
stepper.set_acceleration(1000)
stepper.set_running_speed(5000)
stepper.set_max_speed(10000)

print('Moving to 20000 with acceleration 1000')
stepper.move_to(20000, wait=True)
print('Moving back to 0 with acceleration 5000')
stepper.set_acceleration(5000)
stepper.move_to(0, wait=True)

#
print('Disabling acceleration')
stepper.disable_acceleration()
Пример #9
0
import time
import logging
from commanduino import CommandManager

logging.basicConfig(level=logging.INFO)

cmdMng = CommandManager.from_configfile(
    './examples/commanddevices/commandservo/demo.json')

for i in range(2):
    cmdMng.servo1.set_angle(60)
    cmdMng.servo2.set_angle(60)
    print(cmdMng.servo1.get_angle())
    print(cmdMng.servo2.get_angle())
    time.sleep(1)
    cmdMng.servo1.set_angle(120)
    cmdMng.servo2.set_angle(120)
    print(cmdMng.servo1.get_angle())
    print(cmdMng.servo2.get_angle())
    time.sleep(1)
Пример #10
0
from commanduino import CommandManager

import logging
logging.basicConfig(level=logging.INFO)

cmdMng = CommandManager.from_configfile('./basics.json')

quit = False
while not quit:
    msg = input()
    if msg == "QUIT":
        isRunning = False
        quit = True
    elif msg == "REQUEST":
        print(cmdMng.devices['servo1'].get_angle())
    else:
        cmdMng.serialcommandhandlers[0].write(msg)
 def __init__(self, config):
     self.mgr = CommandManager.from_configfile(config)
     self.config = json_utils.read(config)
     # self.devices = self.config[DEVICES].keys()
     self.devices = self.mgr.devices.keys()
Пример #12
0
import time
import logging
from commanduino import CommandManager

logging.basicConfig(level=logging.INFO)

cmdMng = CommandManager.from_configfile('./examples/commanddevices/commandanalogread/demo.json')


for i in range(10):
    print(cmdMng.A1.get_level())
    time.sleep(1)
Пример #13
0
 def __init__(self, config: str):
     self.mgr = CommandManager.from_configfile(config)
     self.config = json_utils.read(config)
Пример #14
0
from commanduino import CommandManager

import logging
logging.basicConfig(level=logging.INFO)

# in your two board please load the arduino example OF:
# - CommandServo
# - CommandLinearAccelStepper
cmdMng = CommandManager.from_configfile('./examples/commandmanager/two_boards/two_boards.json')

s1 = cmdMng.devices['servo1']
s2 = cmdMng.devices['servo2']
m1 = cmdMng.devices['stepper1']

from commanduino.devices.axis import Axis

a = Axis(m1, 0.1)
Пример #15
0
from commanduino import CommandManager

import logging
logging.basicConfig(level=logging.INFO)

#cmdMng = CommandManager.from_configfile('./examples/commandmanager/basics/basics_serial.json')
cmdMng = CommandManager.from_configfile(
    './examples/commandmanager/basics/basics_tcpip.json')

p1, p2, p3 = True, True, True
while True:
    msg = input()
    if msg == "QUIT":
        break
    elif msg == "P1":
        # Devices can be accessed through devices dictionary
        cmdMng.devices['pin1'].set_level(int(p1))
        # Invert next state for this pin
        p1 = not p1
    elif msg == "P2":
        # Or directly as a CommandManager attribute
        cmdMng.pin2.set_level(int(p2))
        p2 = not p2
    elif msg == "P3":
        if p3 is True:
            cmdMng.pin3.high()
        else:
            cmdMng.pin3.low()
        p3 = not p3