Monday, March 28, 2016

Sensei-Sensing and Proportional Control




What is proportional control?

Proportional control is a type of feedback control system. As opposed to bang-bang control which is either all on or all off, the amount of power is proportional to how far we are from the goal/ideal. For example, if we are going from one stoplight to the next, it doesn't make sense to go full power from point A to point B, does it? It is better to go fast in the beginning (when you have the full distance to go), but as you get closer to your goal, slow down so that you can inch towards the goal.

Error = Goal - sensor measurement
Kp = proportional gain (constant,  depends on the problem)

Output of the proportional controller = Kp (error) + (controller output with zero error)

One of the problems with proportional control is that at some point, the goal value minus the error (how far we have yet to go) is so miniscule that we will never approach the target. At this point you can create a nudge that inches towards the goal is achieved.

Partner: Rachel Hwang

Task 1: Ramp(aging) & Straight Line Proportional Control 
For this task, we worked on getting Stew to go in a (relatively) straight line up and down the ramp. We were not entirely successful in getting the Sciborg to go perfectly straight up the ramp, but we were able to get it to go straight on both the carpet and most of the way up.

One of the main difficulties in completing this task was that the ramp would bend due to the weight of the Sciborg. Over many trials, Stew tended to head a little to the left, but we could still find a way to get him to go straight-ish up the ramp. Another problem we dealt with was that one of the engines would turn off seemingly randomly, causing Stew to spin around in a circle (this was eventually fixed by replacing the batteries). Overall, this was more effective than using bang bang control because we were able to adjust in smaller amounts.




Defeats:






Victories:








Task 2: Proportional Power to Tim-Buck-Ten-Feet

The key to deconstructing this problem was in setting up the right equation. When the distance from the goal (the error value) was large we wanted the power to be large and decrease proportionally as we got closer to the goal. As expected, eventually, the power became so low that it could not overcome the coefficient of static friction, and the Sciborg would no longer be moving forward, despite the loop() still going. We then wrote a nudge function to inch towards the target, and then stop.

One of the main problems in approaching this problem was setting up the equation in the first place, understanding which values should increase/decreased based on how big the error was. In addition, we wanted the value of for the error to be an average between the two positions of the two wheels powering Stew's forward motion. Lastly, but not leastly, we had to create a conditional that dealt with a power that was greater than 255, because if we set the power to be >255, they would just stop.

*Here we set the power to be proportional to the distance we had yet to go and added a constant of abour 110. The difference between 110 and 113 accounting for the differences in age/efficiency of the motors*
12643 was the value that we had previously determined was the position of the motor after having travelled approximately 10 feet.
**note the delay of 50ms was the duration of the nudge. During testing, this could be adjusted for how long we needed to nudge forward. Another way to deal with this would be to leave the delay at some arbitrary constant value and then call nudge repeatedly until we have reached our goal.

Before we wrote nudge, Stew would stop about 8 inches from the line.

Overall, I think that proportional control would be much more effective for real life driving/controlling a car (fuel efficiency and such). However, in the case of the Sciborg, it was much easier to program how far the Sciborg needed to drive and then stop than to adjust the Kp factor through trial and error.

Wait, wait, re-iterate(?)





Success!!! (within 1 centimeter of the goal line)



Task 3: Ultrasonic Sensing (Follow The Leader)
Basically for this task, we were supposed to get Stew to use the ultrasonic sensor to find the distance to the object (a piece of delrin board in front of him) and proportionally set his speed (fast for far, slow for close). The proportional control was much better than bang-bang control for this because Stew was adjusting the speed to what was appropriate to more accurately and precisely follow a board/other Sciborg. Whilst writing this code, we realized that we had written a mishmash of bang-bang and proportional control for our Conga Line assignment previously (we had three if statements for far, medium, and close distances). Oops. Anyways, we now fully understand the difference between bang-bang control (all on or all off) and proportional.




Task 4: Proportional Line Following
For this task, we were asked to use the NXT Brightness sensor to proportionally follow the white lines on the melamine. The key to understanding this problem was in not just proportionally adjusting one motor's speed but both motor's speeds, so that Stew could turn both left and right to follow the line. This was the clearest example of when proportional control is MUCH PREFERRED over bang-bang control because it was able to most efficiently compensate for changes in the environment it was sensing. (see bang-bang follow the line) Again, we also had to set up a case to deal with a power greater than 255 so that Stew would just turn until he found the line again.




Skills learned/worked-on:

  • proportional control
  • sci-borg coding in c
  • sensing, input and output
  • light sensors
  • ultrasonic sensors
  • motor encoders

2 comments:

  1. Oh my goodness the puppy is adorable!
    I really like how concise your codes are, it made them very easy to read. I'm also very impressed by how well your nudge function worked!

    ReplyDelete