No announcement yet.

Robot Acceleration/Deceleration

  • Filter
  • Time
  • Show
Clear All
new posts

  • Robot Acceleration/Deceleration

    We want our robot to decelerate as it approaches it's target. We use encoders to determine the distance driven. Currently I am using a Sine graph, but this only allows for certain distances to be programmed. Is there an easier way to program this?
    -Thank You

  • #2
    I don't know what you mean by using a sine graph but it seems like you could create a subroutine that has two parameters: ticks and power and it would cause the robot to move forward at the given power for the given number of ticks. Your main program could make a series of calls to the subroutine. The ticks for each call could be the same for each call (a fraction of the total ticks needed) and the power level could be smaller for each call.


    • #3
      A simple way to do this is to use RUN_TO_POSITION mode, but use variables for the position values. Then use a PID function to control motor power. (there is built-in PID functionality in the REV controller but it doesn't work very well..) You would need to keep track of your beginning and ending values, then simply apply motor power based on the difference of your current position vs target position. For example, let's say you are are 0 position, and need to go to 2000. Set up two variables, current_position and target_position . Assign target_position = 2000. A simple proportional way is to apply a function like this motor_power = (((target_position - current_position)* .0005) +.04) You would need to poll for current position in your loop before the not_busy end.

      In the above example, when the bot is at position 0, the motor_power is at full power (1), but decreases as the bot approaches the 2000 position. (the additive .04 value allows the bot to hit the final position as the REV controller won't move the motor to the final point. I seem to recall a simple proportional function didn't quite achieve the decel ramp we expected, and seem to recall our girls putting in an exponential function that was non-linear to get the expected ramp.