antonvh / UartRemote

Facilitate communication between two hardware devices using a serial protocol: uart, sockets, rfcomm, ble serial,...
MIT License
20 stars 6 forks source link

error on newest version of uartremote #11

Closed pem120 closed 2 months ago

pem120 commented 2 months ago

the error message is: image

the code is : `` from mindstorms import MSHub, Motor,DistanceSensor from mindstorms.control import wait_for_seconds, Timer from projects.uartremote import *

create definitions

hub = MSHub() ur = UartRemote('E') steering_motor = Motor('A') driving_motor = Motor('B') distance = DistanceSensor('D')

def calibrate(): timer = Timer() timer.reset() steering_motor.start(80) wait_for_seconds(0.5) while steering_motor.get_speed() > 10 and timer.now() < 2: pass steering_motor.stop() wait_for_seconds(0.2) pos = ((15 - steering_motor.get_position()) % 30) steering_motor.set_degrees_counted(90 - pos) steering_motor.run_to_degrees_counted(0, 35)

calibrate()

def forward(distance,speed): driving_motor.run_for_rotations((speed/10)/175.92918860102841,speed) def backward(distance,speed): driving_motor.run_for_rotations(-((speed/10)/175.92918860102841),speed) def steer(angle,speed): steering_motor.run_to_degrees_counted(angle,speed) def get_distance(): distance.light_up_all(100) temp=distance.get_distance_cm() distance.light_up_all(0) return temp def distance_motor(angle_speed): motor_a.run_to_position(175, 'clockwise', 75)

def add_commands(): funcs=[[forward],[backward],[steer],[get_distance,"i"]] for func in funcs: if len(func)>0: ur.add_command(func[0],func[1]) else: ur.add_command(func[0])

add_command()

steering_motor.run_to_degrees_counted(50, 35)

driving_motor.set_default_speed(80)

driving_motor.run_for_rotations(-16)

``

antonvh commented 2 months ago

please use SerialTalk

antonvh commented 2 months ago

Legacy library