Control of a mobile robot
...X]” where X is sonar number Gs() Gets the current state of the robot and updates state vector Pr(right wheel, left wheel, dummy variable = 0) Moves the robot wheels in according to the Sp and Ac specifications Sp(right wheel, left wheel, dummy variable = 0) Sets speed of robot in 1/10th in/s St() Brings robot to controlled stop with appropriate accelerations Vm(right wheel, left wheel, dummy variable = 0) Moves the robot at the specified velocities (1/10th in/s) WS(right wheel, left wheel, dummy variable, time out) Waits for the stop of motors if =1 Time out from 0 to 255s Used after the pr and st command Ex. Ws(1,1,0,255) – stop left and right, timeout of 255s Source Code The code we have written for our robot is on the hard drive of the robot. Programming Issues We used code from the examples in the User’s Manual as a starting point. To program the robot to move in a square, we used the code found in the example on page 64. To program the sonar sensors, we used the code found in the example on page 65. These provided a good starting point to learn to program the robot. However, not all the code that was given in the examples worked with our robot. Some errors we found and their solutions are presented below. When programming the robot to move in a square, one of the errors we found was in the zr command. The zr command zeroes the robot by aligning the steering and turret with bumper #0. This command didn’t work with our code so we looked for something else that would do the same thing. We decided to use the da command instead, setting the angles at zero. The da command defines the robot’s steering and turret angles, which is synonymous with the zr command when the angles are set equal to zero as we did. Another issue we encountered was the use of the sleep command. After the robot moves forward, we programmed it to sleep for 2 seconds before turning and moving again. This created problems in not allowing enough time between when the robot stopped moving forward and when it began to turn. So, instead of making perfect 90 degree turns as programmed, it would continue to move forward and turn, making 60 – 70 degree turns. The easy way to correct for this was to set the sleep time at 5 seconds instead of 2 seconds. This gave plenty of time for the robot to make its turn. However, we think that using the ws command after a line of code for movement would have worked better. The ws command waits for the motors of the robot to stop before beginning the next command. This could have solved the problem we encountered and would protect against similar problems in the future. The advantage of using this command over the sleep command is that there is no guessing of how long to sleep for. The ws command automatically waits for the motors to stop before beginning, whereas the sleep command requires some guess and check to see what time period is long enough. Our main error wasn’t in programming the code for the robot, but rather in using the Linux commands. Since files are writable on the partition, a clean shutdown of the system is required each time. There were times when the battery ran out before we could do a clean shutdown of the system, which caused startup errors. These startup errors slowed us down considerably. Many of the errors were fixed and not encountered again. However, a kernel error was most recently encountered, which would not allow us to proceed. This is discussed more in the Results & Discussion section of the report below. Results & Discussion Two of the three objectives were completed. We successfully learned to program in Linux and successfully programmed the robot to move in a straight line across the room. In addition to this, we were able to program the robot to move in a square with varying velocity and acceleration and begin work on setting up the sonar sensors. In learning to program the Nomadic Scout, consideration was taken to learn the characteristics of the robot and programming syntax using extensive manuals and trial and error. Linux was unfamiliar as was C-code at the start, which made the programming and understanding of the robot functions difficult and challenging. As time progressed and more time was spent being familiarized with the robot, the common commands, C-code compiling, and programming logic became second nature and easily reasoned and justified. After becoming familiar with Linux and C-code, we programmed the robot to move in a straight line. Using the commands shown above, we were able to adjust the velocity and acceleration of the robot as desired. The code for this movement was very easy to learn and was a good building block to work from. After we got the robot to move in a straight line, the next goal was to get it to move in a square. As mentioned above, we used some sample code from the User’s Manual to get us started. Using the code shown above, we were able to write a for-loop, making the robot turn 90 degrees to complete a square. We tried different commands to try to minimize the amount of code used and came up with what is shown above. Minimizing the code used is desirable for programming purposes. It uses the least abo...