Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endless Turn Mode Support #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,18 @@ def pos_rad_to_raw(self, pos_rad):
return self.rad_to_raw(pos_rad, self.initial_position_raw, self.flipped, self.ENCODER_TICKS_PER_RADIAN)

def spd_rad_to_raw(self, spd_rad):
if spd_rad < self.MIN_VELOCITY: spd_rad = self.MIN_VELOCITY
elif spd_rad > self.joint_max_speed: spd_rad = self.joint_max_speed
# velocity of 0 means maximum, make sure that doesn't happen
return max(1, int(round(spd_rad / self.VELOCITY_PER_TICK)))
if self.max_angle_raw == 0.0 and self.min_angle_raw == 0.0: # Endless Turn Mode
direction_flag = 0x0000 # Used when Endless Turn Mode
if spd_rad < 0:
direction_flag = 0x0400
spd_rad = -spd_rad
if spd_rad > self.joint_max_speed: spd_rad = self.joint_max_speed
return direction_flag | int(round(spd_rad / self.VELOCITY_PER_TICK))
else:
if spd_rad < self.MIN_VELOCITY: spd_rad = self.MIN_VELOCITY # In Endless Mode, Minimum speed is zero
elif spd_rad > self.joint_max_speed: spd_rad = self.joint_max_speed
# velocity of 0 means maximum, make sure that doesn't happen
return max(1, int(round(spd_rad / self.VELOCITY_PER_TICK)))

def set_torque_enable(self, torque_enable):
mcv = (self.motor_id, torque_enable)
Expand Down