{"id":5622,"date":"2017-05-31T04:01:29","date_gmt":"2017-05-31T08:01:29","guid":{"rendered":"https:\/\/qxf2.com\/blog\/?p=5622"},"modified":"2018-04-03T10:08:05","modified_gmt":"2018-04-03T14:08:05","slug":"a-configurable-pothole-for-testing-autonomous-cars-part-3","status":"publish","type":"post","link":"https:\/\/qxf2.com\/blog\/a-configurable-pothole-for-testing-autonomous-cars-part-3\/","title":{"rendered":"A configurable pothole for testing autonomous cars &#8211; Part 3"},"content":{"rendered":"<p>This is our third post about building a configurable pothole to test autonomous cars. We are making the configurable pothole with five independent <a href=\"https:\/\/en.wikipedia.org\/wiki\/Scotch_yoke\">Scotch Yoke units<\/a> controlled by servo motors and an Arduino UNO. For more background, please read the <a href=\"https:\/\/qxf2.com\/blog\/a-configurable-pothole-for-testing-autonomous-cars-part-2\">second post<\/a> of this series where we discuss two methods which convert angular movement to linear movement, why we selected the Scotch Yoke mechanism and why we used the combination of different materials for developing Scotch Yoke units. In this post, we cover how we drive and control Scotch Yoke units using Arduino UNO and servo motors.<br \/>\n<strong>NOTE:<\/strong> If you are wondering why anyone would ever bother building a configurable pothole, please read our <a href=\"https:\/\/qxf2.com\/blog\/a-configurable-pothole-for-testing-autonomous-cars-part-1\">first blog post<\/a>.<\/p>\n<hr \/>\n<h3>Interfacing of Arduino with Scotch Yoke Units<\/h3>\n<p>To control a up-down movement of Scotch Yoke units, we used a servo motor and an Arduino UNO. The shaft of the servo\u00a0motor is coupled with a circular wheel of Scotch Yoke unit. So, we can control the movement of the circular wheel by controlling servo motor shaft position which indirectly controls the up-down movement of Scotch Yoke unit.<\/p>\n<figure id=\"attachment_5617\" aria-describedby=\"caption-attachment-5617\" style=\"width: 599px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/pothole_testing_lab_view.png\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5617 size-full\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/pothole_testing_lab_view.png\" alt=\"\" width=\"599\" height=\"561\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/pothole_testing_lab_view.png 599w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/pothole_testing_lab_view-300x281.png 300w\" sizes=\"auto, (max-width: 599px) 100vw, 599px\" \/><\/a><figcaption id=\"caption-attachment-5617\" class=\"wp-caption-text\">Fig.1 Configurable Pothole Circuit- Lab View<\/figcaption><\/figure>\n<figure id=\"attachment_5618\" aria-describedby=\"caption-attachment-5618\" style=\"width: 597px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/pothole_testing_schematic_view.png\" data-rel=\"lightbox-image-1\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5618\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/pothole_testing_schematic_view-1024x506.png\" alt=\"\" width=\"597\" height=\"295\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/pothole_testing_schematic_view-1024x506.png 1024w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/pothole_testing_schematic_view-300x148.png 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/pothole_testing_schematic_view-768x379.png 768w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/pothole_testing_schematic_view.png 1114w\" sizes=\"auto, (max-width: 597px) 100vw, 597px\" \/><\/a><figcaption id=\"caption-attachment-5618\" class=\"wp-caption-text\">Fig. 2 Configurable Pothole Circuit &#8211; Schematic View<\/figcaption><\/figure>\n<p>We used five Tower Pro SG-90 servo motors to\u00a0drive five Scotch Yoke units. The SG-90 servo motor will rotate up to\u00a0180 degrees. In our case, 0 to 180 degrees of movement is sufficient to move the platform to lower peak and upper peak. Look at Fig. 1 and Fig. 2 for Lab View and Schematics of the circuit diagram. Signal pin of the five servo Motors is connected to D2 to D6 pins of Arduino UNO. Power pins of the servo motors (+Vcc and GND) are connected to an external 5V 2A DC power supply as the Arduino UNO was not able to drive all the five servo motors. The Arduino UNO was able to drive just two servo motors using its internal\/inbuilt power source.<\/p>\n<hr \/>\n<h3>Arduino Code:<\/h3>\n<pre lang=\"c\">\/*This is sample code for this blog post.\r\nThis code does not reflect Qxf2's coding habits*\/\r\n#include<servo.h>  \r\n\r\n\/\/ create servo object to control a servo \r\nServo servo_1;   \r\nServo servo_2;\r\nServo servo_3;\r\nServo servo_4;\r\nServo servo_5;\r\n\r\n\/\/Declare Variables \r\nint target_position = 0;    \/\/ variable to store the servo position\r\nint position_last_set = 0;  \/\/ variable to store the last servo position\r\nint servo_motor_selected = 0; \/\/ variable to store selected servo motor number\r\n\r\nint read_servo_position()\r\n{\r\n  Serial.print(\"Set servo position(1-179):\");  \/\/ print msg on monitor for user\r\n  while(Serial.available()==0) { }     \/\/ wait here until user enter input data\r\n  target_position= Serial.parseInt();   \/\/ Read integer value entered by user and store it in a varible\r\n  Serial.println(target_position);\r\n  if (target_position != 0)\r\n  {\r\n    return target_position;\r\n  }\r\n  else\r\n  {\r\n    return read_servo_position();\r\n  }\r\n}\r\n\r\nvoid setup() \r\n{ \r\n  Serial.begin(9600);   \/\/ Enable serial communication \r\n  servo_1.attach(2);  \/\/ attaches the servo on pin 2 to the servo object \r\n  servo_2.attach(3);  \/\/ attaches the servo on pin 3 to the servo object\r\n  servo_3.attach(4);  \/\/ attaches the servo on pin 4 to the servo object\r\n  servo_4.attach(5);  \/\/ attaches the servo on pin 5 to the servo object\r\n  servo_5.attach(6);  \/\/ attaches the servo on pin 6 to the servo object\r\n} \r\n  \r\nvoid loop() \r\n{ \r\n  Serial.println(\"Select servo motor by its row and column number(Enter 10 to select all motors): \");\r\n  while(Serial.available()==0) { }     \/\/ wait here until user enter input data\r\n  servo_motor_selected= Serial.parseInt();   \/\/ Read integer value entered by user and store it in a varible\r\n  Serial.print(\"Selected servo motor:\");\r\n  Serial.println(servo_motor_selected);\r\n  \r\n  switch (servo_motor_selected) {\r\n      case 11:\r\n        target_position = read_servo_position();   \/\/ Read target position from serial monitor\r\n        servo_1.write(target_position);   \/\/ Set servo motor position \r\n        delay(1000);\r\n        break;\r\n        \r\n      case 12:\r\n        target_position = read_servo_position();  \/\/ Read target position from serial monitor\r\n        servo_2.write(target_position);  \/\/ Read target position from serial monitor\r\n        delay(1000);\r\n        break;\r\n        \r\n      case 13:\r\n        target_position = read_servo_position();  \/\/ Read target position from serial monitor\r\n        servo_3.write(target_position);  \/\/ Read target position from serial monitor\r\n        delay(1000);\r\n        break; \r\n        \r\n      case 21:\r\n        target_position = read_servo_position();  \/\/ Read target position from serial monitor\r\n        servo_4.write(target_position);  \/\/ Read target position from serial monitor\r\n        delay(1000);\r\n        break;\r\n        \r\n      case 22:\r\n        target_position = read_servo_position();  \/\/ Read target position from serial monitor\r\n        servo_5.write(target_position);  \/\/ Read target position from serial monitor\r\n        delay(1000);\r\n        break; \r\n        \r\n      case 10:\r\n        target_position = read_servo_position();  \/\/ Read target position from serial monitor\r\n        servo_1.write(target_position);  \/\/ Read target position from serial monitor\r\n        servo_2.write(target_position);  \/\/ Read target position from serial monitor\r\n        servo_3.write(target_position);  \/\/ Read target position from serial monitor\r\n        servo_4.write(target_position);  \/\/ Read target position from serial monitor\r\n        servo_5.write(target_position);  \/\/ Read target position from serial monitor\r\n        delay(1000);\r\n        break;\r\n        } \r\n  } \r\n<\/pre>\n<hr \/>\n<h3>Configurable Pothole Setup for testing Autonomous Cars<\/h3>\n<figure id=\"attachment_5728\" aria-describedby=\"caption-attachment-5728\" style=\"width: 840px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/Gif_2_edited.gif\" data-rel=\"lightbox-image-2\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5728 size-large\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/Gif_2_edited-1024x512.gif\" alt=\"\" width=\"840\" height=\"420\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/Gif_2_edited-1024x512.gif 1024w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/Gif_2_edited-300x150.gif 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/Gif_2_edited-768x384.gif 768w\" sizes=\"auto, (max-width: 840px) 100vw, 840px\" \/><\/a><figcaption id=\"caption-attachment-5728\" class=\"wp-caption-text\">Fig. 3 Pothole Testing Setup for Autonomous Car (Click on image to see gif)<\/figcaption><\/figure>\n<p>We used five Scotch Yoke units to design a configurable pothole for testing autonomous car. Look at the GIF shown in Fig. 3 for the configurable pothole setup. With the help of Scotch Yoke units integrated\u00a0with Arduino UNO and servo motor, we can configure different pothole shapes. We can control depth and width of the pothole by providing different inputs to the Arduino. Look at following Fig. 4 for potholes configured using our prototype. This set of potholes could be the few test cases for testing autonomous cars.<\/p>\n<figure id=\"attachment_6008\" aria-describedby=\"caption-attachment-6008\" style=\"width: 840px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/configured_potholes.jpg\" data-rel=\"lightbox-image-3\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6008 size-large\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/configured_potholes-1024x767.jpg\" alt=\"\" width=\"840\" height=\"629\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/configured_potholes-1024x767.jpg 1024w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/configured_potholes-300x225.jpg 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/configured_potholes-768x575.jpg 768w\" sizes=\"auto, (max-width: 840px) 100vw, 840px\" \/><\/a><figcaption id=\"caption-attachment-6008\" class=\"wp-caption-text\">Fig 4. Configurable potholes using our prototype<\/figcaption><\/figure>\n<p>For prototyping purpose, \u00a0we used Scotch Yoke unit with the thermocol (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Polystyrene\">polystyrene<\/a>) platform as it is very light in weight and it will be easy for micro servo motor to drive low weight load. But in the case of real testing, we suggest you, to go for pneumatic\/hydraulic pistons with a metal platform. As pneumatic\/hydraulic pistons are capable of lifting and holding heavy weights. And you can add another layer of tar and sand over a metal platform.<\/p>\n<p>One more important thing about our prototype, our prototype is helpful when you want to test the pothole sensors and pothole sensing algorithms in isolation. The prototype is small enough to fit on a developer&#8217;s workbench. The developer can use our prototype for updated their algorithm and get a coarse sense of how the algorithm is performing.<\/p>\n<hr \/>\n<h3>Steps to configure the pothole<\/h3>\n<p>By setting multiple Scotch Yoke units, we can configure pothole width and depth as per requirement. Refer following steps to set width and depth of pothole.<\/p>\n<ol>\n<li>Connect Arduino Uno to your system and open serial monitor available in Arduino IDE<\/li>\n<li>Select the Scotch Yoke unit which you want to set by entering its number\n<p><figure id=\"attachment_5628\" aria-describedby=\"caption-attachment-5628\" style=\"width: 648px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/Select_servo_motor.png\" data-rel=\"lightbox-image-4\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-5628\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/Select_servo_motor.png\" alt=\"\" width=\"648\" height=\"468\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/Select_servo_motor.png 648w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/Select_servo_motor-300x217.png 300w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><\/a><figcaption id=\"caption-attachment-5628\" class=\"wp-caption-text\">Fig. Select Scotch Yoke unit by entering its number<\/figcaption><\/figure><\/li>\n<li>Set selected Scotch Yoke unit platform position (i.e. depth of a pothole) by assigning value between 1 to 179\n<p><figure id=\"attachment_5629\" aria-describedby=\"caption-attachment-5629\" style=\"width: 648px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/Set_servo_motor_position.png\" data-rel=\"lightbox-image-5\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-5629\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/Set_servo_motor_position.png\" alt=\"\" width=\"648\" height=\"468\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/Set_servo_motor_position.png 648w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/05\/Set_servo_motor_position-300x217.png 300w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><\/a><figcaption id=\"caption-attachment-5629\" class=\"wp-caption-text\">Fig. Set depth of pothole<\/figcaption><\/figure><\/li>\n<\/ol>\n<p><strong>Steps to set a width of the pothole:<\/strong><br \/>\nTo set a width of the pothole, we need to set a depth of multiple Scotch Yoke units by repeating step 2 and step 3 mentioned above. \u00a0Look at demo video below where we configured potholes by controlling 5 Scotch Yoke units.<\/p>\n<div class=\"tailor-responsive-embed\"><iframe src=\"https:\/\/www.youtube.com\/embed\/CIqNsnKVbY8?feature=oembed&#038;enablejsapi=1&#038;origin=https:\/\/qxf2.com\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/div>\n<p>In above video, we showed how easy it is to configure a number of potholes using our configurable pothole prototype. Just a few inputs from Arduino serial monitor and you are all set with a pothole!<\/p>\n<p>I hope you enjoyed following our creative attempt at designing a configurable pothole. If you liked this post, please check out <a href=\"https:\/\/qxf2.com\/blog\/a-configurable-pothole-for-testing-autonomous-cars-part-4\">the lessons<\/a> we learned by implementing this project.<\/p>\n<p><strong>If you are a startup finding it hard to hire technical QA engineers, learn more <a href=\"https:\/\/qxf2.com\/blog\/about-qxf2\/\">about Qxf2 Services<\/a>.<\/strong><\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>This is our third post about building a configurable pothole to test autonomous cars. We are making the configurable pothole with five independent Scotch Yoke units controlled by servo motors and an Arduino UNO. For more background, please read the second post of this series where we discuss two methods which convert angular movement to linear movement, why we selected [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38,117],"tags":[],"class_list":["post-5622","post","type-post","status-publish","format-standard","hentry","category-automation","category-hardware-testing"],"_links":{"self":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/5622","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/comments?post=5622"}],"version-history":[{"count":36,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/5622\/revisions"}],"predecessor-version":[{"id":6026,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/5622\/revisions\/6026"}],"wp:attachment":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/media?parent=5622"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/categories?post=5622"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/tags?post=5622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}