I am using UART for Sphero RVR to run this over a Raspberry Pi. I am facing few issues with the turns. Sometimes after the turn it goes away from the path. From the mobile app I saw spin function, but couldn’t find the python API to spin. Could someone provide valid references.
Welcome to our community forum. Can you give some more details on your program (particularly which drive command you’re sending) and the unexpected behavior? It sounds like a quirk of the stop controller, but I’d like to confirm with more details before I suggest a workaround. (To learn more about RVR’s control systems, refer to the RVR Control System Manual.
Hi @Sphero_JimK ,
await rvr.drive_with_heading( speed=global_speed, # Valid speed values are 0-255 heading=global_heading, # Valid heading values are 0-359 flags=DriveFlagsBitmask.none.value )
I am using this snippet to drive my RVR and the global_heading will change when it detects a color(Using color sensor for this purpose). When it makes a turn, it doesn’t go in the exact heading.
For example if heading = 90, it will go with heading = 88 || 89 || 90 || 91 || 92, which is deviating from the actual path.
So I wanted to use spin function, which was working well when I tried it from the mobile app. So could you provide valid resources on how to use the spin API(Python).
Based on personal experience those angles may be the best you’ll get. Slippage of the tracks and inaccuracy in the gyro makes it a challenge to get the angle preciously.
You might try one of the drive-with_yaw_(si or noralized) versions. Set the yaw to a right angle and the velocity to zero. That should rotate (or spin).
May I know why am I getting this error
AttributeError: 'SpheroRvrAsync' object has no attribute 'drive_with_yaw_si' sphero rvr
The spin function in the EDU app actually just updates the heading target periodically in a loop and uses
drive_with_heading() You could replicate this yourself, but you also have other options to choose from on Raspberry Pi:
- RC drive allows you to specify a linear velocity and an angular velocity (turn rate) for any spin or arc that RVR is physically capable of driving.
- If you really just want to turn to a particular heading,
drive_with_heading()will be your most accurate option. Final heading accuracy is generally +/- 1 degree but may vary based on driving surface conditions.
To learn more about these, you can review the control system manual and the Getting_started examples included with the SDK.
drive_with_heading_si is the name of the method. It is important to note that heading and yaw have opposite sign conventions - the control system manual linked above goes into more detail on this.