Some questions about async errors

I am setting up a controller to interface to the RVR, but running into some issues with async and await.
Not sure the suggested path, but all of my sensor data is coming in over async just like in, but now I want to drive with heading based on a command I am receving.

The problem is that I have a callback function that provides the message I want to convert to RVR drive command, and it isn’t an async, so I have done what I can to separate the async and non-async, but still not able to get commands to the rvr.

rvr = SpheroRvrAsync(

callback function:

def getCommandVel(message):
async def driveTheRobot(message):
     print("let's try")
     await rvr.drive_with_heading(

setting up callback in main:

If I try:

await driveTheRobot(message)

I get an error:

  File "", line 122
    await  driveTheRobot(message)
SyntaxError: invalid syntax

If I don’t await, then it runs, but doesn’t seem to call the driveTheRobot function.


1 Like

alright, figured it out. Just had to add something to the event loop:
This line is inside a normal method:
def function doSomething:

1 Like

Now I seem to be running out of memory. Anyone know how to clear a task to open up memory?

1 Like

the Observer way of controlling RVR in Python seems to be an easier way than async / await :sunglasses:

1 Like

right, but i want to stream the sensor data and based on that data drive the motors… but mixing async and observer can’t work because of how it ties up the serial port.

1 Like

you may stream with observer as well, see the examples like

1 Like

I ended up using observer…seems to work…

1 Like