예제 #1
0
 def flipMotor(self):
     packet = tr2_msgs.Packet()
     packet.address = self._id
     packet.cmd = CMD_FLIP_MOTOR
     
     self._tr2._msgs.add(packet)
     self._tr2.step()
예제 #2
0
	def resetEncoderPosition(self):
		packet = tr2_msgs.Packet()
		packet.address = self._id
		packet.cmd = CMD_RESET_POS
		
		self._tr2._msgs.add(packet)
		self._tr2.step()
예제 #3
0
	def setMode(self, mode):
		packet = tr2_msgs.Packet()
		packet.address = self._id
		packet.cmd = CMD_SET_MODE
		packet.addParam(mode)
		
		self._tr2._msgs.add(packet)
		self._tr2.step()
예제 #4
0
	def stop(self):
		cmd = CMD_STOP_EMERGENCY
		
		packet = tr2_msgs.Packet()
		packet.address = self._id
		packet.cmd = cmd
		
		self._tr2._msgs.add(packet)
		self._tr2.step()
예제 #5
0
	def release(self):
		cmd = CMD_STOP_RELEASE
		
		packet = tr2_msgs.Packet()
		packet.address = self._id
		packet.cmd = cmd

		self._tr2._msgs.add(packet)
		self._tr2.step()
예제 #6
0
	def setPosition(self, pos, speed = 100):
		x = pos / (math.pi * 2) * 65535
	
		packet = tr2_msgs.Packet()
		packet.address = self._id
		packet.cmd = CMD_SET_POS
		packet.addParam(int(math.floor(x % 256)))
		packet.addParam(int(math.floor(x / 256)))
		packet.addParam(int(math.floor(speed / 100.0 * 255.0)))
		
		self._tr2._msgs.add(packet)
		self._tr2.step()
예제 #7
0
	def actuate(self, motorValue, motorDuration = 250):
		offsetBinary = 128
		x = int(math.floor(motorValue * 100.0))
			
		packet = tr2_msgs.Packet()
		packet.address = self._id
		packet.cmd = CMD_ROTATE
		packet.addParam(x + offsetBinary)
		packet.addParam(int(math.floor(motorDuration % 256)))
		packet.addParam(int(math.floor(motorDuration / 256)))
		
		self._tr2._msgs.add(packet)
		self._tr2.step()
예제 #8
0
    def drive(self, motorLeft, motorRight, motorDuration=250):
        offsetBinary = 100

        packet = tr2_msgs.Packet()
        packet.address = "b0"
        packet.cmd = CMD_ROTATE
        packet.addParam(int((motorLeft * 100.0) + offsetBinary))
        packet.addParam(int((motorRight * 100.0) + offsetBinary))
        packet.addParam(int(math.floor(motorDuration % 256)))
        packet.addParam(int(math.floor(motorDuration / 256)))

        self._msgs.add(packet)
        self.step()