View Single Post
  #13   Spotlight this post!  
Unread 22-07-2015, 15:39
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,680
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Generating Position Setpoints

Quote:
Originally Posted by martinrand View Post
I had originally thought of using the equations you suggested but a discrete method (such as the one I used in my code) would be more appropriate for the MCU I'll be using. It also seems to bet the preferred way of performing the calculations.
If you're going to stick with constant acceleration, the closed form solution suggested above is easier to use. If you just want samples on regular intervals but don't mind using closed form for calculations, I would suggest something like:

1) calculate time and distance to accelerate from stop to Max_Vel
2) calculate time and distance to accelerate from Max_Vel to stop (same, if max_accel is the same)
3) verify that the sum of these distances is less than Demand; adjust times and distances if too large.
4) Calculate time to begin deceleration
5) Start a loop over time
Within the loop, do a case or if/then/elseif structure based on whether time is within the acceleration phase, cruise phase, or deceleration phase.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.