本文整理汇总了Python中transform.Transform.transform方法的典型用法代码示例。如果您正苦于以下问题:Python Transform.transform方法的具体用法?Python Transform.transform怎么用?Python Transform.transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类transform.Transform
的用法示例。
在下文中一共展示了Transform.transform方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pwmControlThread
# 需要导入模块: from transform import Transform [as 别名]
# 或者: from transform.Transform import transform [as 别名]
def pwmControlThread():
# setup arduino serial comm
pwm.setPWMFreq(50)
t = Transform(True, False) #invert one motor and not the other when constructing
watchdog = time.time()
# thread main loop
while True:
time.sleep(.005)
# check for data that needs to be bridged to arduino
dataFlag = True
if not serialRealTimeQueue.empty():
data = serialRealTimeQueue.get()
else:
dataFlag = False
# if data was recieved parse and update pwm hat
if dataFlag:
data = data[5:-1]
print data
data_nums = [int(x) for x in data.split(':') if x.strip()]
print " ", data_nums[0], " ", data_nums[1]
leftMtr,rightMtr = t.transform(data_nums[0],data_nums[1])
print " ", leftMtr , " ", rightMtr
setServoPulse(LEFT_MOT, leftMtr)
setServoPulse(RIGHT_MOT, rightMtr)
Transform.MOTOR_MIN = data_nums[5]*10
Transform.MOTOR_IDLE = data_nums[6]*10
Transform.MOTOR_MAX = data_nums[7]*10
leftIntake = Transform.MOTOR_IDLE
rightIntake = Transform.MOTOR_IDLE
if data_nums[2] > 127 + 10: # if left trigger pressed (i think) spin motors in opposite direction
leftIntake = Transform.map_range(data_nums[2],127,255,Transform.MOTOR_IDLE,Transform.MOTOR_MAX)
rightIntake = Transform.map_range(data_nums[2],127,255,Transform.MOTOR_IDLE,Transform.MOTOR_MIN)
elif data_nums[3] > 127 + 10: # if right trigger pressed
leftIntake = Transform.map_range(data_nums[3],127,255,Transform.MOTOR_IDLE,Transform.MOTOR_MIN)
rightIntake = Transform.map_range(data_nums[3],127,255,Transform.MOTOR_IDLE,Transform.MOTOR_MAX)
else :
leftIntake = Transform.MOTOR_IDLE
rightIntake = Transform.MOTOR_IDLE
print " " , leftIntake, " ", rightIntake
setServoPulse(LEFT_MANIP,leftIntake)
setServoPulse(RIGHT_MANIP,rightIntake)
watchdog = time.time()
if watchdog + WATCHDOG_DELAY < time.time():
setServoPulse(LEFT_MOT, Transform.MOTOR_IDLE)
setServoPulse(RIGHT_MOT, Transform.MOTOR_IDLE)
setServoPulse(LEFT_MANIP, Transform.MOTOR_IDLE)
setServoPulse(RIGHT_MANIP, Transform.MOTOR_IDLE)
watchdog = time.time()
print "you need to feed the dogs"
示例2: transform
# 需要导入模块: from transform import Transform [as 别名]
# 或者: from transform.Transform import transform [as 别名]
def transform(args, x_queue, datadir, fname_index, joint_index, o_queue):
trans = Transform(args)
while True:
x = x_queue.get()
if x is None:
break
x, t = trans.transform(x.split(','), datadir, fname_index, joint_index)
o_queue.put((x.transpose((2, 0, 1)), t))