RVR/Sphero SDK for Android

Are there plans on updating the old Android SDK for RVR support? Will it work without updating? I have interest in directly controlling my RVR using a custom Android app.

Hey btelman96!

Thanks for reaching out and being so excited about RVR :smiley:

Because we have our own Edu and Play Apps that allow you to play with and program your robots (RVR included) from your phone, we won’t be creating new versions of our mobile SDKs; unfortunately, the older versions of the mobile SDKs will not work with RVR, due to all the newfangled tech that RVR uses that has come out since those were last being maintained.

Please keep us posted on all the fun things you’re doing with your RVR and feel free to reach out with any more questions!

Kelsey

1 Like

I was able to get the python SDK working on Android (chaquopy, but is not optimal).

I will be working on making it native though for my purposes. I am trying to control the motors to make a telepresence bot that uses a phone. I have already made a few with Android, and am trying to do the same with my RVR.

This is what I got for the raw motor control. From there, I am sending the byte array via BLE, but can be done as Serial USB as well.

//Java
public class SpheroMotors {
    public static byte[] driveCommand = new byte[]{
            (byte)-115,
            (byte)24,
            (byte)2,
            (byte)22,
            (byte)1,
            (byte)0,
            (byte)2,
            (byte)-119,
            (byte)1,
            (byte)-119,
            (byte)-87,
            (byte)-40
    };

//0x01 forward mode, 0x02 backward mode, 0x00 stop mode
    public static byte[] drive(int leftMode, int leftSpeed, int rightMode, int rightSpeed){
        driveCommand[5]++;
        driveCommand[6] = (byte) leftMode;
        driveCommand[7] = (byte) leftSpeed;
        driveCommand[8] = (byte) rightMode;
        driveCommand[9] = (byte) rightSpeed;
        driveCommand[10] = checksum(driveCommand, 10);
        return driveCommand;
    }

    private static byte checksum(byte[] driveCommand, int checksumIndex) {
        byte sum = 0;
        //skip index 0
        for(int i = 1; i < checksumIndex; i++){
            sum += driveCommand[i] ;
        }
        return (byte) ((sum & 0xFF)^0xFF); //could be cleaned up some probably
    }
}

I will eventually look at expanding it to more functions when the api comes out.

If I could communicate from an external android app to the Sphero EDU app to control motors that would also be doable for my purposes, but I am fine creating my own SDK.

3 Likes

If anybody wants to try this out on an Android device with BLE, I put the code on github. It is a minimal app that just allows raw motor control for each direction.
https://github.com/btelman96/SpheroRVRBLEAndroidDemo.
Just make sure you have a lot of space in the direction it is going so it does not crash into a wall. It will stop after a second or two

2 Likes