MCPcopy Create free account
hub / github.com/DexterInd/GoPiGo3 / offset_motor_encoder

Method offset_motor_encoder

Software/Python/gopigo3.py:571–584  ·  view source on GitHub ↗

Offset a motor encoder Keyword arguments: port -- The motor port(s). MOTOR_LEFT and/or MOTOR_RIGHT. offset -- The encoder offset Zero the encoder by offsetting it by the current position

(self, port, offset)

Source from the content-addressed store, hash-verified

569 return int(encoder / self.MOTOR_TICKS_PER_DEGREE)
570
571 def offset_motor_encoder(self, port, offset):
572 """
573 Offset a motor encoder
574
575 Keyword arguments:
576 port -- The motor port(s). MOTOR_LEFT and/or MOTOR_RIGHT.
577 offset -- The encoder offset
578
579 Zero the encoder by offsetting it by the current position
580 """
581 offset = int(offset * self.MOTOR_TICKS_PER_DEGREE)
582 outArray = [self.SPI_Address, self.SPI_MESSAGE_TYPE.OFFSET_MOTOR_ENCODER, int(port),\
583 ((offset >> 24) & 0xFF), ((offset >> 16) & 0xFF), ((offset >> 8) & 0xFF), (offset & 0xFF)]
584 self.spi_transfer_array(outArray)
585
586 def reset_motor_encoder(self, port):
587 """

Callers 6

reset_motor_encoderMethod · 0.95
reset_encodersMethod · 0.45
Motor_Position.pyFile · 0.45
Motor_Speed.pyFile · 0.45
Motor_Follow.pyFile · 0.45
Motor_Encoder.pyFile · 0.45

Calls 1

spi_transfer_arrayMethod · 0.95

Tested by

no test coverage detected