Beispiel #1
0
 def srvMotorSetRotate(self, params):
     # print(params)
     cur_position = Lepi.motor_get_current_position(params.port)
     # print(cur_position,params.value*2+cur_position)
     Lepi.motor_set_target_position(params.port,
                                    params.value * 2 + cur_position)
     return SetInt32Response(params.port, params.value)
Beispiel #2
0
 def srvServoSetU8(self, params):
     if params.param_id == 0x99:
         status = Lepi.servo_reset(params.id)
     else:
         status = Lepi.servo_write_u8(params.id, params.param_id,
                                      params.value)
     return SetServoParamResponse(status)
Beispiel #3
0
	def srvMotorsGetInfo(self,msg):
		# return GetMotorsInfoResponse()
		# print(msg)
		infos = GetMotorsInfoResponse()
		# print(MotorInfo())
		for i in [1,2,3,4,5]:
			info = Lepi.motor_get_info(i)
			# print(info)
			infos.motors.append(MotorInfo(info[0],info[1],info[2],info[3]))
		return infos
Beispiel #4
0
 def srvSensorsGetInfo(self, params):
     # return GetMotorsInfoResponse()
     # print(params)
     infos = GetMotorsInfoResponse()
     # print(MotorInfo())
     for i in [1, 2, 3, 4, 5]:
         info = Lepi.sensor_get_info(6 - i)
         # print(info)
         infos.motors.append(MotorInfo(info[0], info[1], info[2], info[3]))
     return infos
Beispiel #5
0
 def srvServosGetInfo(self, params):
     # print(params)
     rsp = GetServosInfoResponse()
     if len(params.ids) == 0:
         ids = Lepi.servo_scan()
     else:
         ids = params.ids
     print(ids)
     for servo_id in ids:
         info = ServoInfo()
         info.id = servo_id
         # print(servo_id)
         info.min_position = Lepi.servo_read_u16(servo_id,
                                                 EEPROM.MIN_POSITION_H)
         info.cur_position = Lepi.servo_read_u16(servo_id,
                                                 EEPROM.CURRENT_POSITION_H)
         info.max_position = Lepi.servo_read_u16(servo_id,
                                                 EEPROM.MAX_POSITION_H)
         rsp.servos.append(info)
     return rsp
Beispiel #6
0
 def srvSensorSetMode(self, params):
     status = Lepi.sensor_set_mode(6 - params.port, params.value)
     return SetInt32Response(params.port, params.value)
Beispiel #7
0
 def srvServoGetU16(self, params):
     status = Lepi.servo_read_u16(params.id, params.param_id)
     return SetServoParamResponse(status)
Beispiel #8
0
 def srvSensorSetValue(self, params):
     data = Lepi.sensor_set_value(6 - params.port, params.value)
     return SetInt32Response(params.port, params.value)
Beispiel #9
0
 def srvMotorSetType(self, params):
     # print(params)
     res = Lepi.motor_set_type(params.port, params.value)
     # print(res)
     return SetInt32Response(params.port, params.value)
Beispiel #10
0
 def cbMotorSetAngle(self, msg):
     Lepi.motor_set_angle(msg.port, msg.value)
Beispiel #11
0
 def cbMotorSetSpeed(self, msg):
     Lepi.motor_set_speed(msg.port, msg.value)
Beispiel #12
0
 def cbMotorSetPulse(self, msg):
     Lepi.motor_set_pulse(msg.port, msg.value)
Beispiel #13
0
 def __init__(self):
     self.left = Lepi.MOTOR_2
     self.right = Lepi.MOTOR_3
     Lepi.motor_enable(self.left)
     Lepi.motor_enable(self.right)
Beispiel #14
0
 def setWheelsSpeed(self, left=0, right=0):
     Lepi.motor_set_speed(self.left, int(left * 60000))
     Lepi.motor_set_speed(self.right, int(right * 60000))
Beispiel #15
0
	def srvSensorGetValue(self,msg):
		data = Lepi.sensor_get_value(msg.port)
		return GetInt32Response(data)
Beispiel #16
0
 def srvMotorSetCurrentPosition(self, params):
     # print(params)
     Lepi.motor_set_current_position(params.port, params.value)
     return SetInt32Response(params.port, params.value)
Beispiel #17
0
 def srvMotorGetPosition(self, params):
     # print(params)
     position = Lepi.motor_get_current_position(params.port)
     return GetInt32Response(position)
Beispiel #18
0
 def srvMotorGetState(self, params):
     # print(params)
     value = Lepi.motor_get_state(params.port)
     return GetInt32Response(value)
Beispiel #19
0
 def srvSensorGetValue(self, params):
     data = Lepi.sensor_get_value(6 - params.port)
     return GetInt32Response(data)
Beispiel #20
0
 def srvMotorSetEnable(self, params):
     # print(params)
     Lepi.motor_set_enable(params.port, params.value)
     return SetInt32Response(params.port, params.value)
Beispiel #21
0
 def srvSensorGetInfo(self, params):
     sensor_id = Lepi.sensor_get_type(params.port)
     value = Lepi.sensor_get_value(params.port)
     return GetSensorInfoResponse(params.port, sensor_id, value)
Beispiel #22
0
 def srvMotorGetEnable(self, params):
     # print(params)
     enabled = Lepi.motor_get_enable(params.port)
     return GetInt32Response(enabled)
Beispiel #23
0
 def srvServoSetPosition(self, params):
     status = Lepi.servo_set_position(params.id, params.position, params.ms,
                                      params.speed)
     return SetServoPositionResponse(status)
Beispiel #24
0
 def srvMotorSetSpeed(self, params):
     # print(params)
     Lepi.motor_set_speed(params.port, params.value)
     return SetInt32Response(params.port, params.value)
Beispiel #25
0
 def srvServoSetU16(self, params):
     status = Lepi.servo_write_u16(params.id, params.param_id, params.value)
     return SetServoParamResponse(status)
Beispiel #26
0
 def srvMotorGetSpeed(self, params):
     # print(params)
     speed = Lepi.motor_get_speed(params.port)
     return GetInt32Response(speed)
Beispiel #27
0
 def srvSensorGetMode(self, params):
     status = Lepi.sensor_get_mode(6 - params.port)
     return GetInt32Response(status)
Beispiel #28
0
 def srvMotorGetPulse(self, params):
     value = Lepi.motor_get_pulse(params.port)
     return GetInt32Response(value)
Beispiel #29
0
 def srvGetFirmwareVersion(self, params):
     version = Lepi.system_get_version()
     return GetInt32Response(version)
Beispiel #30
0
	def srvMotorGetPosition(self,msg):
		print(msg)
		position = Lepi.motor_get_current_position(msg.port)
		return GetInt32Response(position)