Interrupting the movement?

For Formula AllCode users to discuss projects, programs, and any other issues related to the Formula AllCode robotics platform.

Moderators: Benj, Mods

Posts: 1
Joined: Mon Nov 19, 2018 8:03 pm

Interrupting the movement?

Postby asperger » Mon Nov 19, 2018 8:07 pm

I currently purchased the AllCode and I am testing it in visual studio using C# as my language of choice.
Now, when I call the command:

FA_DLL.FA_Forwards(PortNumber, 100);

Then I want to stop the buggy as soon as it is near a wall. Setting Forwards to "0" doesnt work. It just keeps on moving until it reached the defined number of millimeters. Any advice?

User avatar
Matrix Staff
Posts: 3146
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 103 times
Been thanked: 412 times

Re: Interrupting the movement?

Postby Steve » Tue Nov 20, 2018 11:06 am

I can think of two ways around this:

1) Use a loop to repeat a set number of times (e.g. 20 times) and move a smaller amount within the loop, followed immediately with a check for a wall, and break out of the loop if the wall is detected.

2) Use SetMotor to set off driving and then continually monitor the encoders to determine how far you've gone (as well as keeping the buggy straight) at the same time as detecting for obstacles.

The first option should be a lot easier to implement though.
These users thanked the author Steve for the post:
medelec35 (Fri Dec 14, 2018 4:04 pm)
Rating: 5%