![]() You can type "get(g)" and "get(h)" again and see the functions now listed next to the corresponding conditions. between the "function main" and final "end" statement) we are now building.Ĭopy the following code lines under the above ones (and before the final "end" statement) and run the program again: This is accomplished by associating the figure window "f" with various functions we will write and then include in the same m-file (i.e. We can also tell whether a key on the keyboard has been pressed down or released up. We will use the figure as a virtual joystick by telling Matlab to track the location and state of the mouse cursor (i.e., whether clicked down or released up) in this figure. Once the figure "f" is defined, along with the red and blue lines, the "get" function tells all the properties associated with those lines. ![]() Also you can type "help line" or "help text" or "help axes" to the Matlab prompt for more information. You should understand what each of the above commands does (you can test them by typing each one individually into the command prompt, after a figure window is open). The program should then terminate, leaving the figure in a new window (which you can dismiss by clicking its red X). Under the horizontal axis, the words "left" and "right" should be printed, with "fast" and "slow" on the vertical axis. It should print on the screen a figure with X- and Y-axes that go between 0 and 1 with a horizontal blue line and a vertical red one centered on each axis. Type in the following lines between the "function main" line and the final "end" line, then Save and run the program. This program is a shell program into which you will insert program statements to control your robot. Place the word "end" on the last line of the file, directly underneath the word "function" and Save As the program with the name of your robot (don't forget the. Create the "virtual joystick" programĬreate a new "function" m-file with the name "main" after the word "function" on the first line of the file. Put the program(s) on your website so I can test them. Once you've got this working, experiment with putting the calls to individual motors together into one call with different Timing rates for each motor to create a less jerky, smoother motion. make the loop move forward or backward e.g. Make a new version of your forward/backward one-step motion by using a "FOR" loop to loop several steps (i.e. Making your robot move forward/backward n steps ![]() Put this reverse motion in a separate script/program/m-file from the forward motion. Start with 3 distinct calls (fprintf statements) to individual motors, allowing each motor to complete the movement before the next one starts (for debugging purposes).Įxtra credit: do the same for reverse motions, allowing the robot to put its foot on the ground close to the front and pushing down and forward to drive the robot backwards. Using the program sections in Matlab 3, write a program (script) that allows your robot to move forward by a sequence of motor movements starting from a known arm configuration that 1) extends the arm, 2) touches it to the ground ahead of the robot, 3) pulls the robot forward and up (by pulling down and back toward the robot), then 4) returns to the original arm postion. Making your robot move forward/backward one step
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |