Skip to main content

Controller library for robotmoose robots.

Project description

logo

MoosePy

A python robotics library for interfacing with RobotMoose

Summary

MoosePy offers functionality for driving and retreiving sensors values from robots deployed using RobotMoose. It supports arbitrary robot configurations using the JSON structure found on the Superstar server.

Installation

  1. Download the latest supported version of Python3

  2. Install the library with following pip command:

     pip3 install moosepy
    

    MoosePy uses the requests library, which can be installed using the following command if you are experiencing dependency issues:

    pip3 install requests
    

Setup

Instantiating a robot object is dependent on two parameters:

Required Parameter Description
superstar_path The path after https://robotmoose.com/superstar/ For example, if the path to your robot is https://robotmoose.com/superstar/robots/20xx-yy/uaf/robotName then superstar_path = robots/20xx-yy/uaf/robotName
password The robot's password

Usage

import moosepy

# The path after https://robotmoose.com/superstar/
superstar_path = "robots/20xx-yy/uaf/robotName"
password = "password"

robot = moosepy.Robot(superstar_path, password) 

Examples

Drive Forward

import moosepy
import time

robot = moosepy.Robot("superstar_path", "password")

# Drive forward with left and right motors at 10% speed for 1 second
robot.drive(10,10)
time.sleep(1)

# Stop the robot
robot.drive(0,0)

Drive Forward, Backward, Left, and Right

import moosepy
import time

robot = moosepy.Robot("superstar_path", "password")

# Forward
robot.drive(10,10)
time.sleep(1)

# Backward
robot.drive(-10,-10)
time.sleep(1)

# Left
robot.drive(-10, 10)
time.sleep(1)

# Right
robot.drive(10, -10)
time.sleep(1)

# Stop
robot.drive(0,0)

Get Sensor Data JSON

import moosepy

robot = moosepy.Robot("superstar_path", "password")
sensor_data = robot.getSensors()

print(json.dumps(sensor_data, indent=4))

Example Output:

{
    "backend": {
        "battery": {
            "is_charging": false,
            "percent": "2.00%",
            "time_till_discharged": "7.63 minutes"
        },
        "name": "RobotMoose",
        "version": "2017.3.6.0"
    },
    "battery": {
        "charge": 43,
        "state": 16
    },
    "heartbeats": 188,
    "power": {
        "L": 0,
        "R": 0
    }
}

Control a Servo

import moosepy

robot = moosepy.Robot("superstar_path", "password")
robot.setOpt("servo", {"degree": 70})
robot.sendRequest()

License

Copyright 2019 University of Alaska Fairbanks

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

moosepy-1.0.tar.gz (62.1 kB view hashes)

Uploaded Source

Built Distribution

moosepy-1.0-py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page