Tags:
create new tag
view all tags

Lab 5: Lets Make Something Engaging

In this lab, we used with the Pong software to experience haptic rendering using the twiddler. We also experimented with our own implementation of a controller that generated an output signal to the motor based on sensor readings from the encoder mounted on the rear shaft of twiddler's motor. Finally, we developed a model of a robot steering system and rendered its steering motion on the twiddler. Following sections describe them in details.

Motor Controller Implementation

We had to replace myPID.Compute() function with our own implementation. In the main loop of the program we replaced this function call with the following code snippet.

1. long pid_t = millis();

2. long pid_dt = pid_t - pid_last_time;

3. if(pid_dt>=1) // 1ms is the Sampling Time

4. {

5. prev_p_error=p_error;

6. p_error=pos-target;

7. d_error=pos-prev_pos;//p_error-prev_p_error;

8. PWMOut= p*p_error+d*d_error;

9. if (PWMOut>255) PWMOut=255;

10. else if (PWMOut<-255) PWMOut=-255;

11. pid_last_time=pid_t;

12. //SetPWMOut(PWMOut);

13. }

In lines 1-2, we track the current time and time difference from previous iteration of the PID loop in lines 3-13. When the time interval exceeded Sampling time of 1ms, we compute proportional and derivative errors in lines 6-7. Our spring mass damper type controller is implemented in line 8. Lines 9-10 assure PWM output to not exceed its extreme values. Initially, we did not have fixed time step. We ran this loop as fast as possible using the same value of p and d terms as originally used by myPID.Compute() expecting it to work. It did not work in the same manner as before. Then, we began tuning the controller and observed that the controller worked similar to myPID if the d term was scaled approximately 1000 times the value used by myPID.Compute(). Expecting the cause to be faster running loop and/or not fixed time, we used fixed times sampling as described in lines 1-3. The result did not change significantly. Still confused about why would the derivative gain have to be so high for the controller to work, we checked the PID library. We found that the derivative term and the integral term we scaled from milliseconds scale to seconds scale in the library. The reason behind that scaling is still not clear to us.

Rendering Steering Wheel motion on Twiddler

Fig 1. Rendering Steering Wheel Motion on Twiddler video

We used bezier curves to generate a trajectory that a mobile robot would take (see Fig 1) to accomplish its task. As we have shown in Fig 1, we used a circle and a pointing head to represent a robot that would follow the trajectory. When a mobile robot traverses through the path generated with the bezier curves, we compute the heading of the robot as atan2(y_pos_k1-y_pos_k0,x_pos_k1-x_pos_k0) using x and y position at instance k0 and k1 (k1>k0). This heading was then sent as a position command to the pid controller algorithm running on the arduino connected to the twiddler. In lab 4, we only observed the step response of a system. Now, as the robot's heading changes gradually over time while turning around the corners of the given trajectory, the desired orientation changes gradually. We tuned the PID controller from lab 4, but this time it was much more challenging than previously as the parameters had to suite the system such that it could constantly follow the trajectory especially around sharp corners. This video shows steering wheel in action.

In Fig 1, the robot is currently at position G. It started from the start point and went through smooth turns like the one at D and F as well as sharp turns likes A and B. The simulation graph shows spikes in red line pertaining to drastic change in target position. This spike occurs every time the robot reaches the end of its trajectory and continues to manoeuvre from the start point. Generating a continuously connected trajectory circuit between these two end points turned out to be a non-trivial problem.

We presented this haptic rendering to fellow labmates at LCI. Most of them found it interestingly mimicking steering wheels of fancy self-driving cars. Others were concerned about the zittery motion and possibility of the system going unstable. When loaded with hand in the middle of the circular disk, the controller was still successful to track its trajectory. However, the system did not have enough strength to hold a hand on its top. We could still manage to feel some shear force on our palms.

Next, we want to implement a touch sensitive twiddler steering assistance mechanism based on the software that we have built. We opened the Twiddler's controller box to integrate a touch sensitive sensor on top of the knob. We have identified some pins in the DB9 connection port (can we open the box to hack some cables/connectors without altering the existin hw/sw protocol?) that could be used to connect sensors into the module. We hypothesize that, using touch sensitive shear force, the robot can encourage its users to be guided in a certain direction such as towards destination, away from obstacles etc.

-- TWikiGuest - 28 Mar 2014

Topic revision: r1 - 2014-03-28 - TWikiGuest
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback