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

Post Reply
asperger
Posts: 1
Joined: Mon Nov 19, 2018 8:03 pm
Contact:

Interrupting the movement?

Post by asperger »

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
Steve
Matrix Staff
Posts: 3418
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: Interrupting the movement?

Post by Steve »

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.

Post Reply