Trapezoidal Velocity Profile
Implement trapezoidal_profile(distance, v_max, a_max) for a non-negative , returning the array [total_time, cruise_time, peak_velocity].
Examples
A long move: ramp up, cruise for 3 s, ramp down
- Input
- trapezoidal_profile(10, 2, 1)
- Output
- [7, 3, 2]
A short move: triangular, and the speed limit is never reached
- Input
- trapezoidal_profile(1, 2, 1)
- Output
- [2, 0, 1]
Exactly at the boundary: a trapezoid with no cruise phase
- Input
- trapezoidal_profile(4, 2, 1)
- Output
- [4, 0, 2]
Hints
Hint 1
Take the square root at the end, not inside the sum.
Hint 2
Watch for this: assumed the cruise phase always exists and returned a negative cruise time.
Requirements
: move length, >= 0
v_max: speed limita_max: acceleration limitReturn (3,) array [total_time, cruise_time, peak_velocity]
Constraints
Allowed library: NumPy only
Time limit: 200 ms, Memory: 64 MB
Try similar problems(4)
Industrial Robotics: Kinematics and Control · ~16 min
Industrial Robotics: Kinematics and Control · ~14 min
Industrial Robotics: Kinematics and Control · ~16 min
Industrial Robotics: Kinematics and Control · ~18 min
Where this shows up
6 employers weight this skill
4 autonomy companies, 2 defense companies. Top match scores 92.
import numpy as np
def trapezoidal_profile(distance, v_max, a_max):
"""
Timing of a trapezoidal (or triangular) velocity profile.
Args:
distance: move length, >= 0
v_max: speed limit
a_max: acceleration limit
Returns:
(3,) array [total_time, cruise_time, peak_velocity]
"""
# YOUR CODE HERE
pass