乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      A LEGO Mindstorms NXT Autonomous Killough Platform using 3x Sonars, Programmed with RobotC

       quasiceo 2016-01-18

      RobotC: Autonomous Holonomic Platform using 4x Sonars

      Rating: 9.3/10 (6 votes cast)

      This Autonomous Tri-Drive Holonomic Platform is fitted with Rotacaster? Omni-wheels and uses 4x Ultrasonic Sensors for navigation. The RobotC Code is based on my previous post on using multiple Sonar Sensors in RobotC. The main challenge is to use all 4 Ultrasonic Sensors without them interfering with each other, resulting in non-valid measurement readings for distance values to obstacles.

      Tri-Holomonic Platform with Sonar Navigation
      Autonomous Holonomic Platform using 4x Sonars for Navigation

      If you wish to use Multiple Ultrasonic Sensors on your NXT Robot, you need to program them so only ONE Sensor is taking a measurement at any  given time. As  mentioned above, if you have all the Ultrasonic Sensors on at once they interfere with each other and give incorrect readings. To get around this you need to take advantage of the Sensors Mode 1: Single Shot Mode. Refer to the Lego Mindstorms NXT Hardware Developer Kit, Appendix 7: LEGO MINDSTORMS NXT Ultrasonic Sensor I2C communication protocol for details. Consult the RobotC API for detailed information on using Digital I2C Command & Control with NXT Sensors.


      Autonomous Holonomic Platform using 4x Sonars for Navigation

      The video above shows the Robot randomly moving around the walled area. The Robot is programmed to moves no closer to the Walls than 40cm. After each encounter, a random direction away from the corresponding wall/s is generated. The “#define THRESHOLD 40” statement in the code below, controls the minimum distance to wall value the Robot uses.

      Third Party Driver Suite:
      The standard RobotC comes with a lot of built in drivers for a wide variety of sensors. However, the standard RobotC doesn’t expose all of the functions that some of the sensors have available. To use the Sonar Sensor in ‘Single Shot Mode’ with RobotC, you will need a copy of Xander Soldaat’s ‘Third Party Driver Suite‘.

      I also so suggest you download a copy of Xander Soldaat’s ‘RobotC Third Party Driver Suite Tutorial‘ which is an excellent resource. For more information relating to Xander Soldaat’s  ‘Third Party Driver Suite‘, visit his blog, ‘Bot Bench‘.

      RobotC Source Code:

      Download RobotC Source Code: TriHolonomicSonar.C

      1. #pragma config(Sensor, S1, US1, sensorI2CCustom9V)
      2. #pragma config(Sensor, S2, US2, sensorI2CCustom9V)
      3. #pragma config(Sensor, S3, US3, sensorI2CCustom9V)
      4. #pragma config(Sensor, S4, US4, sensorI2CCustom9V)
      5. #pragma config(Motor, motorA, tmotorNormal, tmotorNormal, openLoop)
      6. #pragma config(Motor, motorB, tmotorNormal, tmotorNormal, openLoop, reversed)
      7. #pragma config(Motor, motorC, tmotorNormal, tmotorNormal, openLoop)
      8. //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

      9. /*
      10. Original Code by Ray McNamara (www.)

      11. This program is free software: you can redistribute it and/or modify it under the terms
      12. of the GNU General Public License as published by the Free Software Foundation, either
      13. version 3 of the License, or (at your option) any later version. In particular, you must
      14. report the name of the original author.

      15. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
      16. without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
      17. See the GNU General Public License for more details.

      18. You can get a copy of the GNU General Public License from www.gnu.org.

      19. */

      20. /**********************************************************************************
      21. * Set Constants and Variables *
      22. **********************************************************************************/
      23. #include "drivers/LEGOUS-driver.h"

      24. #define THRESHOLD 40

      25. float V1, V2, V3;
      26. int Vx, Vy, PowerA, PowerB, PowerC;
      27. int Dist1, Dist2, Dist3, Dist4;

      28. /**********************************************************************************
      29. * Monitor the 3x Utrasonic Sonar Sensors *
      30. ***********************************************************************************/
      31. task MonitorUS()
      32. {
      33. while (true)
      34. {
      35. nxtDisplayClearTextLine(4);
      36. USsetSingleMode(US1); // Set US1 Sensor in Single Shot Mode
      37. wait1Msec(50); // Wait to Capture Distance Value
      38. Dist1 = USreadDist(US1); // Read the Sonar Sensor's Distance Value
      39. nxtDisplayTextLine(4, "Sonar 1: %d", Dist1);
      40. USsetOff(US1); // Turn off Sonar Sensor on Digital ports 1

      41. nxtDisplayClearTextLine(5);
      42. USsetSingleMode(US2); // Set US1 Sensor in Single Shot Mode
      43. wait1Msec(50); // Wait to Capture Distance Value
      44. Dist2 = USreadDist(US2); // Read the Sonar Sensor's Distance Value
      45. nxtDisplayTextLine(5, "Sonar 2: %d", Dist2);
      46. USsetOff(US1); // Turn off Sonar Sensor on Digital ports 1

      47. nxtDisplayClearTextLine(6);
      48. USsetSingleMode(US3); // Set US2 Sensor in Single Shot Mode
      49. wait1Msec(50); // Wait to Capture Distance Value
      50. Dist3 = USreadDist(US3); // Read the Sonar Sensor's Distance Value
      51. nxtDisplayTextLine(6, "Sonar 3: %d", Dist3);
      52. USsetOff(US3); // Turn off Sonar Sensor on Digital ports 2

      53. nxtDisplayClearTextLine(7);
      54. USsetSingleMode(US4); // Set US3 Sensor in Single Shot Mode
      55. wait1Msec(50); // Wait to Capture Distance Value
      56. Dist4 = USreadDist(US4); // Read the Sonar Sensor's Distance Value
      57. nxtDisplayTextLine(7, "Sonar 4: %d", Dist4);
      58. USsetOff(US4); // Turn off Sonar Sensor on Digital ports 3

      59. // Sonar 1
      60. if (Dist1 &lt; THRESHOLD &amp;&amp; Dist2 &gt; THRESHOLD &amp;&amp; Dist3 &gt; THRESHOLD &amp;&amp; Dist4 &gt; THRESHOLD)
      61. {
      62. Vx = -random(70)-30; // Object Found, Change Vx Direction
      63. }

      64. // Sonar 2
      65. if (Dist1 &gt; THRESHOLD &amp;&amp; Dist2 &lt; THRESHOLD &amp;&amp; Dist3 &gt; THRESHOLD &amp;&amp; Dist4 &gt; THRESHOLD)
      66. {
      67. Vx = random(70)+30; // Object Found, Change Vx Direction
      68. }

      69. // Sonar 3
      70. if (Dist1 &gt; THRESHOLD &amp;&amp; Dist2 &gt; THRESHOLD &amp;&amp; Dist3 &lt; THRESHOLD &amp;&amp; Dist4 &gt; THRESHOLD)
      71. {
      72. Vy = random(70)+30; // Object Found, Change Vy Direction
      73. }

      74. // Sonar 4
      75. if (Dist1 &gt; THRESHOLD &amp;&amp; Dist2 &gt; THRESHOLD &amp;&amp; Dist3 &gt; THRESHOLD &amp;&amp; Dist4 &lt; THRESHOLD)
      76. {
      77. Vy = -random(70)-30; // Object Found, Change Vy Direction
      78. }

      79. // Sonar 1 & 3
      80. if (Dist1 &lt; THRESHOLD &amp;&amp; Dist2 &gt; THRESHOLD &amp;&amp; Dist3 &lt; THRESHOLD &amp;&amp; Dist4 &gt; THRESHOLD)
      81. {
      82. Vx = -random(70)-30; // Object Found, Change Vx Direction
      83. Vy = random(70)+30; // Object Found, Change Vy Direction
      84. }

      85. // Sonar 1 & Sonar 4
      86. if (Dist1 &lt; THRESHOLD &amp;&amp; Dist2 &gt; THRESHOLD &amp;&amp; Dist3 &gt; THRESHOLD &amp;&amp; Dist4 &lt; THRESHOLD)
      87. {
      88. Vx = -random(70)-30; // Object Found, Change Vx Direction
      89. Vy = -random(70)-30; // Object Found, Change Vy Direction
      90. }

      91. // Sonar 2 & Sonar 3
      92. if (Dist1 &gt; THRESHOLD &amp;&amp; Dist2 &lt; THRESHOLD &amp;&amp; Dist3 &lt; THRESHOLD &amp;&amp; Dist4 &gt; THRESHOLD)
      93. {
      94. Vx = random(70)+30; // Object Found, Change Vx Direction
      95. Vy = random(70)+30; // Object Found, Change Vy Direction
      96. }

      97. // Sonar 2 & Sonar 4
      98. if (Dist1 &gt; THRESHOLD &amp;&amp; Dist2 &lt; THRESHOLD &amp;&amp; Dist3 &gt; THRESHOLD &amp;&amp; Dist4 &lt; THRESHOLD)
      99. {
      100. Vx = random(70)+30; // Object Found, Change Vx Direction
      101. Vy = -random(70)-30; // Object Found, Change Vy Direction
      102. }
      103. /* nxtDisplayClearTextLine(3);
      104. nxtDisplayTextLine(3, "Vx:%d Vy:%d", Vy, Vx); // Display 'X' & 'Y' Co-ordinates */

      105. Dist1 = 0; Dist2 = 0; Dist3 = 0; Dist4 = 0;
      106. wait1Msec(50);
      107. }
      108. }

      109. /**********************************************************************************
      110. * Main Killough Platform Control *
      111. ***********************************************************************************/
      112. task main()
      113. {
      114. eraseDisplay();
      115. nxtDisplayCenteredBigTextLine(0, "Killough");
      116. nxtDisplayCenteredBigTextLine(2, "Platform");

      117. StartTask(MonitorUS); // Start Monitoring the Ultrasonic Sonar Sensors

      118. Vx = 100;
      119. Vy = 100;

      120. while (true)
      121. {
      122. V1 = Vx; // Vector Calculation for MotorA(V1)'s Power

      123. V2 = -Vx / 2 - sqrt(3)/2 * Vy; // Vector Calculation for MotorB(V2)'s Power

      124. V3 = -Vx / 2 + sqrt(3)/2 * Vy; // Vector Calculation for MotorC(V3)'s Power

      125. if (V1 &lt; 30 &amp;&amp; V1 &gt; 0) {V1 = 30;} // Set Minimum MotorA's Forward Power
      126. if (V1 &lt; 0 &amp;&amp; V1 &gt; -30) {V1 = -30;} // Set Minimum MotorA's Reverse Power
      127. if (V2 &lt; 30 &amp;&amp; V2 &gt; 0) {V2 = 30;} // Set Minimum MotorB's Forward Power
      128. if (V2 &lt; 0 &amp;&amp; V2 &gt; -30) {V2 = -30;} // Set Minimum MotorB's Reverse Power
      129. if (V3 &lt; 30 &amp;&amp; V3 &gt; 0) {V3 = 30;} // Set Minimum MotorC's Forward Power
      130. if (V3 &lt; 0 &amp;&amp; V3 &gt; -30) {V3 = -30;} // Set Minimum MotorC's Reverse Power

      131. PowerA = V2; // Convert to an Integer Value for MotorA
      132. PowerB = V1; // Convert to an Integer Value for MotorB
      133. PowerC = V3; // Convert to an Integer Value for MotorC

      134. motor[motorA] = PowerA; // Set MotorA's Velocity (Power Setting)
      135. motor[motorB] = PowerB; // Set MotorB's Velocity (Power Setting)
      136. motor[motorC] = PowerC; // Set MotorC's Velocity (Power Setting)
      137. }
      138. }

       

       

       

      [buy rotacasters]
      Rating: 9.3/10 (6 votes cast)
      Rating: +6 (from 6 votes)
      RobotC: Autonomous Holonomic Platform using 4x Sonars, 9.3 out of 10 based on 6 ratings ShareThis
      Link to this post!

      Tags: , , , , , , , , , , , , , , , , , , , , ,

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多