Home Community Blog Buy Now
Blog

Misty Community Forum

Official Python SDK Released

Misty Developers!

Today we’re excited to announce something that many of you have been asking for, the brand new and Official Misty Python SDK. The SDK has all of the commands available in the API Explorer, including an event system with callbacks similar to the JS and C# SDKs.

Download the SDK and see installation notes here: https://pypi.org/project/Misty-SDK/

In addition, you can run the SDK directly on Misty allowing you to run fully autonomous Python skills. Unfortunately, you won’t be able to load/unload these skills via Skill Runner but nevertheless this is a solid start.

Please let us know what you think and share your new Python skills with the community!

~The Misty Team

4 Likes

Hi @arobodude , will there be offical doucment update foy Python SDK too ? I’m thinking of migrating code from JS over to python and i also hope the API exploerer can provide python skill code just like the Javascript.

Currently it is still a REST and Websocket wrapper, but it is designed to be updated and new version generated automatically as new commands are added to the robot. Thanks to that all of the REST API documentation can still be employed. The API Explorer format can also be used since all parameters are keywords, so in Python you can specify by position or by keyword. The following bit of code has two different TakePicture calls that will behave exactly the same:

misty.TakePicture(True, None, 800, 600)
misty.TakePicture(width=800, height=600, base64=True)

Thanks to the keywords I hope it can be more clear what parameters are being set and the already available documentation for the REST API hopefully give a good explanation of how to use the commands and what to expect as a response from them.
If you use a modern IDE the doc string includes a link for every command to help you read up on how to use the command. Here is an example with the TakePicture command:
image

The event system is also based around the websockets which also have documentation available here.

Hello, Thanks for providing the Python SDK. I tried to use it. I am able to do basic things such as change LED, moveArms, etc… However, I am having problem with successful registering to events. As an example, I tried to register to the IMU Event Type as shown below. But I am not getting any data back even after waiting for a long time. Please a sample below.

************* RUN-able code after entering the right IP address ************
from mistyPy.Robot import Robot
from mistyPy.Events import Events
from mistyPy.EventFilters import EventFilters

if name == “main”:
try:
# First create the robot object
ip_address = “xx.xx.xx.xx”
misty = Robot(ip_address)

    _Data = misty.RegisterEvent(event_name="IMU_data", event_type=Events.IMU)
    print(misty.active_event_registrations)
    print(_Data.data)
    print(_Data.event_name)
    print(_Data.event_type)
    print(_Data.is_active)
    print(_Data.data["message"])

    misty.KeepAlive()

except Exception as ex:
    print(ex)
finally:
    # Unregister events if they aren't all unregistered due to an error
    misty.UnregisterAllEvents()

The result from the print() statements is as below.
{‘IMU_data’: <mistyPy.Events.Event object at 0x00000256BE942B20>}
{‘status’: ‘Not_Subscribed or just waiting for data’}
None
IMU
True
‘message’

If I am understanding it correctly, I am registration to the IMU event type is active (per the first print() statement result). Then in the next statement, it says ‘Not subscribed or waiting for data’. I have tried waiting for a very long time (~10minutes or so) and I don’t see any data coming back. For _Data.event_name, I am was expecting “IMU_data” but it is giving me None… Lastly, I don’t see the desired results in _Data.data["message].

I would really appreciate any help here. Thanks!

Sorry, some formatting got corrupted when I pasted it as seen in the if _ name _ statement.