diff --git a/mintpatch/MINTlisten.py b/mintpatch/MINTlisten.py index a66409c..f8108a4 100644 --- a/mintpatch/MINTlisten.py +++ b/mintpatch/MINTlisten.py @@ -103,8 +103,8 @@ def listen(): # END LOOP - print("Thank you for using MintPatch!") + #rint("Thank you for using MintPatch!") listener.disconnect("tcp://127.0.0.1:4242") if __name__ == '__main__': - listen() \ No newline at end of file + listen() diff --git a/mintpatch/MINTpatchServer.py b/mintpatch/MINTpatchServer.py index ffdb825..adb8150 100644 --- a/mintpatch/MINTpatchServer.py +++ b/mintpatch/MINTpatchServer.py @@ -31,7 +31,7 @@ def print_servo(self): # Prints the info out in one line as a formatted string. # Every element is seperated by a space. - return '{id} {state} {voltage} {temp} {pos} {speed}'.format(id = self.output_name, + return '\"id\": {id}, \"state\": {state}, \"voltage\": {voltage}, \"temp\": {temp}, \"position\": {pos}, \"speed\": {speed}'.format(id = self.output_name, state = state, voltage = idict["voltage"], temp = idict["temperature"], pos = idict["position"], speed = idict["speed"]) @@ -158,9 +158,9 @@ def running_update(self, console_input, input_length): self.update_motor(rmotor) #Returns a string with all motor info - motor_info='' + motor_info=[] for servo_log in self.log_list: - motor_info=motor_info+self.log_list[servo_log].print_servo()+'\n' + motor_info.append(str(self.log_list[servo_log].print_servo())) return motor_info diff --git a/mintpatch/fakeProxy.py b/mintpatch/fakeProxy.py index ba762be..88de0eb 100644 --- a/mintpatch/fakeProxy.py +++ b/mintpatch/fakeProxy.py @@ -1,3 +1,4 @@ +#Nathan Moder from emulatedMotor import tm1 from emulatedMotor import tm2 @@ -17,15 +18,77 @@ def __init__(self, readback_echo=False, protocol_version=2.0): self.motors=[] + self.port_name=port_name if(port_namespace=='port_1'): #self.motors[0]=tm1 self.motors.append(1) #self.motors[1]=tm2 - self.motors.append(5) + self.motors.append(15) if(port_namespace=='port_2'): - self.motors.append(1) + self.motors.append(110) #print("proxy init") def connect(self): self.__find_motors() def __find_motors(self): a=1 + def set_goal_position(self, servo_id, goal): + #print(self.port) + if self.port_name=="/dev/port_1": + #print(servo_id) + if 1==int(servo_id): + #print("into if") + tm1.set_goal_speed(goal) + elif int(servo_id)==15: + tm2.set_goal_speed(goal) + elif self.port_name=="/dev/port_2": + if int(servo_id)==110: + tm3.set_goal_speed(goal) + + def get_feedback(self,servo_id): + if self.port_name=="/dev/port_1": + if int(servo_id)==1: + if tm1.moving: + tm1.check_while_running() + return { + 'id':tm1.id, + 'goal': 0, + 'position': tm1.angle, + 'error' : 0, + 'speed' : tm1.speed, + 'load' : 0, + 'voltage' : tm1.voltage, + 'temperature' : tm1.temperature, + 'moving' : tm1.moving + } + if int(servo_id)==15: + if tm2.moving: + tm2.check_while_running() + return { + 'id':tm2.id, + 'goal': 0, + 'position': tm2.angle, + 'error' : 0, + 'speed' : tm2.speed, + 'load' : 0, + 'voltage' : tm2.voltage, + 'temperature' : tm2.temperature, + 'moving' : tm2.moving + } + if self.port_name=="/dev/port_2": + if int(servo_id)==110: + if tm3.moving: + tm3.check_while_running() + return { + 'id':tm3.id, + 'goal': 0, + 'position': tm3.angle, + 'error' : 0, + 'speed' : tm3.speed, + 'load' : 0, + 'voltage' : tm3.voltage, + 'temperature' : tm3.temperature, + 'moving' : tm3.moving + } + return 'no such servo' + def set_torque_enabled(self, sid, thing): + a=1 diff --git a/mintpatch/fakeWrapper.py b/mintpatch/fakeWrapper.py index 7b28702..c8d0931 100644 --- a/mintpatch/fakeWrapper.py +++ b/mintpatch/fakeWrapper.py @@ -80,3 +80,4 @@ def get_feedback(self,servo_id): return 'no such servo' + diff --git a/mintpatch/startup.py b/mintpatch/startup.py index 2fca9be..c91c991 100644 --- a/mintpatch/startup.py +++ b/mintpatch/startup.py @@ -1,4 +1,3 @@ - """ The startup code for MintPatch. Nathan Moder & M. Arnett @@ -18,15 +17,18 @@ import zerorpc def main(): - # """ + """ # Setttings for configuring our pinging to the motors. settings_set = {} + # Get the port name through a system call raw_port_command = os.popen("ls /dev/ttyUSB*") raw_ports = raw_port_command.read() port_list_raw = raw_ports.split() port_list = [] + # Real motors, and matches the launch file simple_l_arm_controller_manager.launch + # port_list = {port} settings = { 'baudrate': 1000000, 'minID': 1, @@ -34,19 +36,20 @@ def main(): 'updateRate' : 20, 'diagnosticsRate' : 1 } + # Get Port List without /dev/ for raw_port in port_list_raw: port = raw_port.replace('/dev/', '') settings_set[port] = settings port_list.append(port) - # """ + """ #This seperate code with the emulated servos included in the directory. #Comment it out when using real motors """ DO NOT REMOVE THIS CODE! Our team has members without constant access to real motors. """ - """ + #""" settings_set = {} port_list={'port_1','port_2'} settings={ @@ -58,14 +61,16 @@ def main(): } settings_set['port_1']=settings settings_set['port_2']=settings - """ + #""" # Making robot manager, and basically listening in on the GUI translator manager = RobotManager(port_list, settings_set) - translator = zerorpc.Server(ServerManager(manager)) + SM_Instance=ServerManager(manager) + SM_Instance.scan(1,1) + translator = zerorpc.Server(SM_Instance) translator.bind("tcp://0.0.0.0:4242") translator.run() if __name__ == '__main__': - main() \ No newline at end of file + main()