Update
This commit is contained in:
parent
20cfd7e60c
commit
1505a4a24b
@ -48,7 +48,7 @@ logging.warning(f"Axis 1 encoder bandwidth: {odrv0.axis1.encoder.bandwidth}")
|
||||
|
||||
def controller_setup(odrv0: object, pos_gain: int = 1, vel_limit: int = 0.5): # Low vel limit (1 turn every 2s to avoid crsahing lol)
|
||||
# https://docs.oodrv0robotics.com/control
|
||||
odrv0.axis0.controller.config.pos_gain = pos_gain
|
||||
odrv0.axis0.controller.config.pos_gain = pos_gain # 20
|
||||
odrv0.axis1.controller.config.pos_gain = pos_gain
|
||||
logging.warning(f'Set positional gain to {pos_gain}')
|
||||
### NOTE: The VEL gain determines how fast the motor will move from point A to point B, may need to up/ tweak the value
|
||||
@ -182,3 +182,36 @@ odrv0.axis1.controller.input_pos = 0
|
||||
|
||||
odrv0.axis0.encoder.set_linear_count(0)
|
||||
odrv0.axis1.encoder.set_linear_count(0)
|
||||
|
||||
|
||||
# defaults:
|
||||
# gain_scheduling_width = 10.0 (float)
|
||||
# enable_vel_limit = True (bool)
|
||||
# enable_current_mode_vel_limit = True (bool)
|
||||
# enable_gain_scheduling = False (bool)
|
||||
# enable_overspeed_error = True (bool)
|
||||
# control_mode = 3 (int)
|
||||
# input_mode = 1 (int)
|
||||
# pos_gain = 50.0 (float)
|
||||
# vel_gain = 0.1666666716337204 (float)
|
||||
# vel_integrator_gain = 0.3333333432674408 (float)
|
||||
# vel_limit = 100.0 (float)
|
||||
# vel_limit_tolerance = 2.0 (float)
|
||||
# vel_ramp_rate = 1.0 (float)
|
||||
# torque_ramp_rate = 0.009999999776482582 (float)
|
||||
# circular_setpoints = False (bool)
|
||||
# circular_setpoint_range = 1.0 (float)
|
||||
# homing_speed = 0.25 (float)
|
||||
# inertia = 0.0 (float)
|
||||
# axis_to_mirror = 255 (int)
|
||||
# mirror_ratio = 1.0 (float)
|
||||
# load_encoder_axis = 0 (int)
|
||||
# input_filter_bandwidth = 2.0 (float)
|
||||
# anticogging:
|
||||
# index = 0 (int)
|
||||
# pre_calibrated = False (bool)
|
||||
# calib_anticogging = False (bool)
|
||||
# calib_pos_threshold = 1.0 (float)
|
||||
# calib_vel_threshold = 1.0 (float)
|
||||
# cogging_ratio = 1.0 (float)
|
||||
# anticogging_enabled = True (bool)
|
||||
|
||||
@ -51,6 +51,8 @@ class Controller:
|
||||
self.a0_t = 0
|
||||
self.a1_t = 0
|
||||
self.v_max = self.drive.get_max_speed()
|
||||
self.y_multiplier = 1.1
|
||||
# self.y_multiplier = 0.7
|
||||
|
||||
def calculate_angles(self, large_x, large_y):
|
||||
x = large_x / 10.0
|
||||
@ -92,7 +94,7 @@ class Controller:
|
||||
idkwhatthisis = self.font.render(f"X: {mouse_x} | Y: {500 - mouse_y}", True, (255, 255, 255))
|
||||
idkwhatthisis_3 = self.font.render(f"X: {mouse_x/100} | Y: {(500 - mouse_y)/100}", True, (255, 255, 255))
|
||||
idkwhatthisis_4 = self.font.render(f"M0: {self.a0:.3f} | M1: {self.a1:.3f}", True, (255, 255, 255))
|
||||
self.a0_t, self.a1_t = self.calculate_angles(mouse_y*1.1, 990 - mouse_x)
|
||||
self.a0_t, self.a1_t = self.calculate_angles(mouse_y*self.y_multiplier, 990 - mouse_x*2)
|
||||
idkwhatthisis_5 = self.font.render(f"M0: {self.a0_t:.3f} | M1: {self.a1_t:.3f}", True, (0, 255, 255))
|
||||
idkwhatthisis_6 = self.font.render(f"VMAX: {self.v_max}", True, (255, 100, 0))
|
||||
self.window.blit(idkwhatthisis, (0, 0))
|
||||
@ -104,7 +106,7 @@ class Controller:
|
||||
pygame.display.update()
|
||||
|
||||
if self.armed:
|
||||
self.a0, self.a1 = self.calculate_angles(mouse_y*1.1, 990 - mouse_x*2)
|
||||
self.a0, self.a1 = self.calculate_angles(mouse_y*self.y_multiplier, 990 - mouse_x*2)
|
||||
self.drive.goto(self.a0, self.a1)
|
||||
|
||||
self.drive.set_idle()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user