Assignment 4: Control and Collision Detection
Contact: asathyam@cs.umd.edu March 2020
1 PID Controller
1. [Use any programming language] [25 points] Implement a PID con- troller for a differential drive mobile robot similar to the Turtlebot. Your robot takes two control inputs which represent the angular velocity to each wheel (wL and wR). The state space of the robot is its position and orientation (x, y, θ). Your PID controller should take as inputs, a desired linear speed and turning rate and compute the necessary controls for the robot to achieve these desired values. As a caveat, assume that the angular velocity of each wheel has some noise and varies slightly every second, causing minor changes in the wheel motor response rates. This can be done by adding simulated (Gaussian or white) noise in your code. Your controller will need to compensate for these disturbances. The kinematic equations of motion for a differential drive robot are provided below:
x ̇ = rw (wL +wR)cosθ 2
y ̇ = rw (wL +wR)sinθ 2
θ ̇= rw (wR−wL). 2rrob
Here wL and wR are the robot’s left and right wheel’s angular velocities, and assume the following values for the other parameters:
Radius of the robot (rrob) = 0.25 meters
Radius of the robot’s wheels (rW ) = 0.102 meters
Max linear velocity of each wheel = ± 1.5 m/s (you must limit it in your code).
Deliverables:
a. Simulate the controller in action for different desired linear and angular
velocities. Provide graphs showing the robot’s velocity converging to the target 1
speeds. Tune the PID controller with appropriate values for the constants such that it converges quickly to the desired value.
b. Provide the list of kp,ki and kd gains for your controller(s) you used for the problem. Evaluate the performance of your controller for these varying gain values.
2 Collision Detection
2.(20 points) a. Consider two lines on the plane. Line 1 passes through the points a,b ∈ R2 and Line 2 passes through the points c,d ∈ R2. Give a for- mula or procedure to calculate for the intersection between two lines. Note that your answer should report “no intersection” if the lines are parallel. Hint: the intersection point x must satisfy the two line equations x = a + u(b − a) and x = c + v(d − c) for some parameters u, v ∈ R.
b. Consider the problem of checking collision between two segments on the plane. Segment 1 connects the points a,b ∈ R2 and Segment 2 connects the points c,d ∈ R2 (i.e., we want to check for collision between ab and cd). Using your solution to part A, give a method to report whether ab and cd are collid- ing. Hint: the intersection point of the two lines must lie within the range of the segment. Consider testing the values of u and v.
c. Describe an algorithm (in pseudocode) that uses your solution to part B to
test whether two general polygons A = (a1, …, am) and B = (b1, …, bn) are in
collision. Here a polygon is described as an ordered list of points walking around
the perimeter of the polygon. In other words, the edges of the polygon A are
the segments S = (a ̄a ,a ̄a ,…,a ̄a ,a ̄a ). Don’t forget to handle the k 1 2 2 3 m−1 m m 1
case where one polygon is contained completely within the other. You can use the fact that a point P lies within a polygon A if and only if a ray, whose source lies at P and whose direction is arbitrary, intersects A an odd number of times.
d. How many segment-segment collision tests does your algorithm perform, as a function of m and n?
3 Extra Credit
3. [15 points] Consider the system in Fig.1. Let the parameters of the system
showninFig.1bem=1kg,b=1N-s/m,andk=1N/m. Assumethatthe
block is released from the position x = 0 m with an initial velocity of dx = 0m/s. dt
2
Figure 1: Mass-Spring-Damper System.
a. Find gains kp(N/m) and kv(N-s/m) for a position control law (f = −kpx − kvx ̇) that results in the system being critically damped with a closed-loop stiff- ness (k + kp) of 25.0 N/m.
b. Double the values of all the system parameters. Keeping the gains same as (a), what is the new closed-loop stiffness? Determine the change in the nature of the closed-loop response i.e., has it become underdamped, overdamped or stayed critically damped?
3