Cant multitask in python fron robotmesh, need hel0

I am using robot mesh studio python to code multitasking but cant figure it out. Does anyone have an example of how to multitask in this code?

Hello 244, Take a look at this document from RobotMesh. It includes a sample program.


This didnt work either. What I’m trying to do is make a macro but when I have the else statements to stop my intakes, it affects the macro too and wont run the intakes during the macro

Hi RD244.

Could you make your program public, and then post a link to it in this thread?

Cheers, Sam

The motors will follow the most recent command. If you have one task that is constantly sending commands to a motor, other tasks won’t have much of an opportunity to do anything with that motor. One way around this would be a variable that tracks whether or not the motor is in use by another task. In the larger world of programming, this kind of variable is called a mutex.

You could do something like this:

intake_in_use = False

def macro ():
  while intake_in_use:
  intake_in_use = True
  #macro code goes here
  intake_in_use = False

def drivercontrol():
  while True:
    if not intake_in_use:
      #drivercontrol intake code (i.e. if...elif..else style)

Where would I put the macro function so that it runs?

Doesn’t it have to be in driver control to run?

Did you look at the examples and documentation linked by @jrp62 earlier in this thread?