Hi all - just starting to get to grips with Formula Allcode through VB and connecting to the robot via Bluetooth.
Does anybody know if it's possible to multithread? For example to have a siren sounding as the robot moves? I've given it a whirl but it doesn't seem to like it.
Thanks
Mark
Multi threading
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Multi threading
Hi Mark,
You should be able to use the SetMotors function and then call the PlayNote function while the robot is moving. The SetMotors function does not use encoder feedback and so will immediately return allowing you to call other functions.
Note that using SetMotors if using speeds below 20 the motor may not start or may be less balanced as it just controls the PWM signals to the motors.
You should be able to use the SetMotors function and then call the PlayNote function while the robot is moving. The SetMotors function does not use encoder feedback and so will immediately return allowing you to call other functions.
Note that using SetMotors if using speeds below 20 the motor may not start or may be less balanced as it just controls the PWM signals to the motors.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 2
- Joined: Thu Sep 29, 2016 2:51 pm
Re: Multi threading
Thanks Benj
What's the tactic for getting more than one robot to 'dance' in time with another? If you can't multithread then how do you send simultaneous commands to the different ports? Or would you have to run the code from an SD card and sync them by pressing a button on them all at the same time?
cheers
Mark
What's the tactic for getting more than one robot to 'dance' in time with another? If you can't multithread then how do you send simultaneous commands to the different ports? Or would you have to run the code from an SD card and sync them by pressing a button on them all at the same time?
cheers
Mark
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Multi threading
Hi Mark,
Getting multiple robots to dance together is usually a case of giving each robot a command at high speed. Usually this is enough to make it appear that the robots are exactly in sync even though there could be a few nano/micro/milliseconds between each robot. As you can send out commands at high speed but generally the robot is moving for seconds the illusion of dancing in sync should be easy to achieve.
e.g.
Your method of storing commands on an SD card and pressing each switch at the same time would also work but in manually pressing the switch you will likely incur larger delays then using the API method.
Getting multiple robots to dance together is usually a case of giving each robot a command at high speed. Usually this is enough to make it appear that the robots are exactly in sync even though there could be a few nano/micro/milliseconds between each robot. As you can send out commands at high speed but generally the robot is moving for seconds the illusion of dancing in sync should be easy to achieve.
e.g.
Code: Select all
FA1 = OpenCom (0)
FA2 = OpenCom (1)
FA1.SetMotors(50, 50)
FA2.SetMotors(50, 50)
Delay 1 Second
FA1.SetMotors(-50, 50)
FA2.SetMotors(-50, 50)
Delay 1 Second
Your method of storing commands on an SD card and pressing each switch at the same time would also work but in manually pressing the switch you will likely incur larger delays then using the API method.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel