View Single Post
  #18   Spotlight this post!  
Unread 04-01-2014, 07:55
Woolly's Avatar
Woolly Woolly is offline
Programming Mentor
AKA: Dillon Woollums
FRC #1806 (S.W.A.T.)
Team Role: Mentor
 
Join Date: Feb 2012
Rookie Year: 2012
Location: Springfield, MO
Posts: 512
Woolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond repute
Re: 95's Pre-season drive base done!

Actually, after thing about it, what I said probably would not work well at all, mainly because PID controllers don't work well when using speed as a set-point for something that isn't a flywheel.

However, you may be able to do something like this.(pardon my python-esque syntax, I'm not a C++ or Java programmer)
c is a constant set to make the robot not try to turn at say 13.5FPS at full turn.

if steering_axis_last != 0 AND steering_axis = 0
left_encoder.resetdistance()
right_encoder.resetdistance()
if steering_axis == 0:
left_error = ((left_encoder_distance + right_encoder_distance)/2 - left_encoder_distance) + (throttle_axis* robot_max_speed * dt)
right_error = ((left_encoder_distance + right_encoder_distance)/2 - right_encoder_distance) + (throttle_axis* robot_max_speed * dt)
else:
left_error = left_encoder_distance + (throttle_axis* robot_max_speed * dt) + (steering_axis * c * robot_max_speed)
if left_error > robot_max_speed * dt
left_error = robot_max_speed * dt
if left_error < -(robot_max_speed * dt)
left_error = -(robot_max_speed * dt)
right_error = right_encoder_distance + (throttle_axis* robot_max_speed * dt) - (steering_axis * c * robot_max_speed)
if right_error > robot_max_speed * dt
right_error = robot_max_speed * dt
elif right_error < -(robot_max_speed * dt)
right_error = -(robot_max_speed * dt)
left_motor = p_constant*left_error + i_constant*left_error
right_motor = p_constant*right_error + i_constant*right_error
steering_axis_last = steering_axis
__________________


Team 1806 Student: 2012-2013 | Mentor: 2013-Present