Let's move on and make the robot move little more distant. The robot here is the small car which is built using small booklet provided with NXT kit. Let's make it a point that the robot will come back from where it has started. So, I have made the robot move for 5 seconds, make it take a U-turn and return to its origin. Let's take a look at the steps that we are going to follow.
I will program the three steps mentioned above using NXT-G programming. Let's program for the first step Go Forward.
As shown in the figure above, drag and drop the Motor Block from the left palette to the Work Area. Click on the Motor Block and check its Configuration Panel in the bottom. Since we want to program it to move forward, we need to move both the rear wheels with the same speed for the same time. In my case, the rear wheels were powered on by Motor B and Motor C. So I have checked the ports B and C in the Configuration Panel. I want to drive the motor for 5 seconds, so I have specified the Duration to be 5 seconds. Next step for the robot is to take a U-turn (either from the left or from the right side). In order to do this, please drag and drop the Motor Block to the Work Area in succession with the first block shown in the above figure. The NXT-G program now looks like below.
Please click on the second Motor Block and check its configuration at the bottom. In order to take a U turn, stop one of the rear motors and power-on the other motor. In my case I am powering on the C Motor and stopping the B motor. That will make the robot take a turn. To take a complete U-Turn the motor has to be rorated through 810 degrees (We came up to this number through multiple trial-and-error). Keep rest of the configurations as they are. And let's move to configuration of the third step, which is Come Back to The Origin. The NXT-G program now looks like below.
As you can see the program now has three Motor Blocks in succession which correspond to the three steps which are required to return back to the origin. In order to configure the third Motor Block, click on to the block and check its Configuration Panel at the bottom. I have powered on both the rear motors for 5 seconds of duration as shown in the above figure. Now it's the time to run the NXT-G program and see the output in the below video. I have used the Line-Follower paper just as a baseline in order to get the correct start and end point of the robot.
No comments:
Post a Comment