MRDs Learning four--automatic machine car

Source: Internet
Author: User

Start by yourself and explore the simple machine car around you, assuming the car's walking path is as follows:

    

We're going to write the L-shaped path as an activity, and then enter the size of the l from the outside, and finally the activity will be able to spit out a larger l size when the walking path is completed.

Complete the first step forward action:

The first step: Drag an activity, rename to Runl, and then set the input to size, the category is double. and the output is notification. (Because the machine is finished using a notification to tell us, and our L-path is done by the notice to know)

How to write the flow inside: According to Genericdifferential Drive can accept the instruction, only forward a certain distance and rotation of an angle, so the L-shaped path should be 1, forward 2, rotation 90 degrees 3, forward, 4, rotation 90 degrees (for the next L) four part of the composition. And each part of the completion is by notification to achieve, not by the current genericdifferential drive output. So when we get notified, it's important to know what state we're in and decide how to proceed to the next step. In discrete mathematics, even finite state machines (finitestate machine), the problem of dealing with FSM in VPL can only be dependent on variables (Variables).

In addition to the 1, the forward is driven by external input, 2, 3, 4 are by Genericdifferential drive to complete the notification,

Then we rely on a currentstate variable to decide which action we should take:

Step Two: drag a variable from the basicactivity into the RUNL (not diagram). The right side of the property table can add a new variable, we add a currentstate, the category is int, as follows:

Step Three: when you enter data, a data value of 1 is used as the SetValue of the variable.

The Fourth step: the input size input to Genericdifferential drive (configuration Reference Learning II) Drivedistance settings are as follows: (at 100% of the speed forward value such a distance)

The fifth step: because wait also need to know the user input size, so also by the way the size is stored as currentsize. Is

The contents of the RUNL should be as follows:

Sixth Step: Enter a value of 0.5 on diagram (value) to the size of RUNL, as follows:

(Running, the machine car can automatically walk a short line and stop.) )

Complete the next two, three or four-step action:

For each user-defined activity, there is a specific activity called "start" that is used to write as a notification or as a startup process. There is no output and input in the START process, but the elements inside can be notification.

First step: in order to receive the notification of Genericdifferential Drive (configuration Reference Learning II), we put genericdifferential in start. As follows:

Second step: Next, we intend to receive only two notifications, namely forward (drivedistance) and rotation (rotationdegrees), so put two if to determine the two notifications, and then the two if the judgment to the merge, Output to a calculate, fill in state. Currentstate+1, and then give the result of this calculate to the CurrentState variable. As shown in the following:

In this way we are done with "status +1" after receiving the notification.

The third step:after the "state +1", according to the current state decide what to do: After the variable is set, in the other calculate, fill in. CurrentState. Plus switch judgment:

2 Give Genericdifferential drive a full (power=1) rotation of 90 degrees (DEGREES=90)

3 give Genericdifferential drive a full (power=1) advance (distance=state. CurrentSize)

4 give Genericdifferential drive a full (power=1) rotation of 90 degrees (DEGREES=90)

5 to RUNL (recommended to diagram) a value of size=-1, as the end

As shown in the following:

The third step: because the set Size=-1 to complete, so to go to action that the first to make a judgment, size=-1 when issued a notice, as shown:

Fourth Step: Finally, go back to diagram, set RUNL notification, and then calculate donesize+0.3 to RUNL, as shown:

Fourth Step: save and run.

(encountered a lot of difficulties, but all overcome, but each time the value of the save variable is not saved, the solution is only once set to run, know how to solve the friend can tell me.) )

2016-03-29

(data compiled in the Baidu Library of "Microsoft_robotics_developer_studio Chinese Course")

MRDs Learning four--automatic machine car

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.