Navideck / Romo-iOS-SDK

Romo SDK supporting up to iOS 17!
Other
44 stars 15 forks source link
ios objective-c robotics romo

Romo iOS SDK

become a patron

Platform: iOS 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17

Romo SDK gives you the power to write your own software for Romo robots. After downloading the SDK, this guide will help you get rolling so you can start developing apps for Romo.

This project is a continuation of the Romo SDK, an attempt to breathe life into the lovable but sadly discontinued, iPhone robot, Romo. The goal is to enable a community of makers, tutors and researchers that is actively engaged with the Romo platform and smartphone robotics.

The SDK is broken up into 3 major frameworks, so you can pick and choose what you'd like to use in your app. The list of current frameworks is:

RMCore

Control Romo's hardware using your own apps! Using RMCore, you can drive all three motors, flash LEDs, and access state information about your Romo base.

RMCharacter

RMCharacter allows you to add Romo's adorable personality to your app. Want Romo to get excited when someone tweets your username? Now he can!

RMVision

RMVision allows you to use the iPhone's camera to allow Romo to see but also understand the world using computer vision.

Setting up a project

You have multiple options:

Using CocoaPods

The most easy way to include the Romo SDK in your app is using CocoaPods:

pod 'Romo'

Note that this will get you only RMCore.

If you additionally need RMCharacter add

pod 'Romo/RMCharacter'

Make sure to comment out use_frameworks! as you will face missing assets otherwise. You will also need to add

install! 'cocoapods', :disable_input_output_paths => true on top of your Podfile.

If you additionally need RMVision add

pod 'Romo/RMVision'

A complete PodFile with all frameworks would look like this:

# Uncomment the next line to define a global platform for your project
platform :ios, '6.0'
install! 'cocoapods', :disable_input_output_paths => true

target 'My Cool Romo App' do
  # Comment the next line if you don't want to use dynamic frameworks
  # use_frameworks!

  # Pods for My Cool Romo App
  pod 'Romo'
  pod 'Romo/RMCharacter'
  pod 'Romo/RMVision'

end

Carthage

Although not tested yet, the basic folder structure for Carthage is in place so it should theoretically already be working.

Manually

Enable the Accessory

Note: Only if you're using RMCore to interface with the robot.

  1. Navigate to your app's Info.plist file in XCode, which should be in the Supporting Files folder by default.

  2. Click on the top row ("Information Property List") and add a new entry by clicking the plus button.

  3. XCode will now ask you to input the key for this new entry. Use Supported external accessory protocols. Expand the newly created element, and change the value for "Item 0" to be com.romotive.romo.

  4. That's it! Save the file and you're all set to have your app talk to the hardware accessory.

Getting started

Now that we have a project that uses the Romo SDK, it's time to start writing some code!

If you're using RMCore with ObjC, you'll want to do the following...

  1. Import the RMCore framework

    #import <Romo/RMCore.h>
  2. Implement the RMCoreDelegate interface

    @interface YourVC : UIViewController <RMCoreDelegate>
  3. Add a property for the robot, with the protocols you'd like to use (here we're specifying that our robot can tilt its head, drive, and use an LED)

    @property (nonatomic, strong) RMCoreRobot<HeadTiltProtocol, DriveProtocol, LEDProtocol> *robot;
  4. Initialize your delegacy to the robot (often in viewDidLoad).

    [RMCore setDelegate:self];
  5. Implement a connection delegate (triggered when a robot is connected).

    - (void)robotDidConnect:(nonnull RMCoreRobot *)robot
    {  
    // Currently the only kind of robot is Romo3, so this is just future-proofing
    if (robot.isDrivable && robot.isHeadTiltable && robot.isLEDEquipped) {
        self.robot = (RMCoreRobot<HeadTiltProtocol, DriveProtocol, LEDProtocol> *) robot;
    }
    }
  6. Implement disconnection delegate (triggered when a robot is disconnected).

    - (void)robotDidDisconnect:(nonnull RMCoreRobot *)robot
    {
    if (robot == self.robot) {
        self.robot = nil;
    }
    }

Now you're ready to send the robot commands. Here are some examples:

In your app's Info.plist add a new key with the text Required background modes and select the App communicates with an accessory value for the first item.

If you're using RMCore with Swift, you'll want to do the following...

  1. Import the RMCore framework
    import Romo

In case you don't use CocoaPods you need to import the RMCore framework manually using a bridging header file MyCoolRomoApp-Bridging-Header.h with:

#import <Romo/RMCore.h>
  1. Implement the RMCoreDelegate protocol

    class ViewController: UIViewController, RMCoreDelegate {
  2. Add a property for the robot, with the protocols you'd like to use (here we're specifying that our robot can tilt its head, drive, and use an LED)

    var robot: RMCoreRobotRomo3?
  3. Initialize your delegacy to the robot (often in viewDidLoad).

    RMCore.setDelegate(self)
  4. Implement a connection delegate (triggered when a robot is connected).

    func robotDidConnect(_ robot: RMCoreRobot) 
    {
    // Currently the only kind of robot is Romo3, so this is just future-proofing
    if robot.isDrivable && robot.isHeadTiltable && robot.isLEDEquipped {
        self.robot = robot as? RMCoreRobotRomo3
    }
    }
  5. Implement disconnection delegate (triggered when a robot is disconnected).

    func robotDidDisconnect(_ robot: RMCoreRobot) {
    print("Disconnected")
    if robot == self.robot {
        self.robot = nil
    }
    }

Now you're ready to send the robot commands. Here are some examples:

In your app's Info.plist add a new key with the text Required background modes and select the App communicates with an accessory value for the first item.

For using RMCharacter with ObjC, a good start would be...

  1. Add a property for the character
    @property (nonatomic, strong) RMCharacter *romo;
  2. Initialize your character (often in viewDidLoad).

    - (void)viewDidLoad
    {
    [super viewDidLoad];
    
    // Grab a shared instance of the Romo character
    self.romo = [RMCharacter Romo];
    }
  3. Add the character to a superview (often in viewWillAppear).

    - (void)viewWillAppear:(BOOL)animated
    {
    [super viewWillAppear:animated];
    
    // Add Romo's face to self.view whenever the view will appear
    [self.romo addToSuperview:self.view];
    }
  4. Ensure you remove the character's view when you're done with it (often in viewDidDisappear).

    - (void)viewDidDisappear:(BOOL)animated
    {
    [super viewDidDisappear:animated];
    
    // Removing Romo from the superview stops animations and sounds
    [self.romo removeFromSuperview];
    }

    Now you're ready to send the character commands. You can do things like:

HelloRMCore

Control your Romo's hardware through driving its motors and LEDs.

This simple application presents three buttons on the screen when the iDevice is docked on a robot. Two of these buttons tilt the robot's head up and down when tapped. The third button tells the robot to drive in a circle and blink its LED.

HelloRMCoreSwift

Same as HelloRMCore but in Swift

HelloRMCharacter

Cycle through Romo's expressions and emotions, and see how he can look around.

To get started interfacing with an RMCharacter object, we show you how to get Romo's face to appear on your iDevice. Drag your finger on Romo's face to have him look around. When your finger leaves the screen, Romo will perform a random expression (a brief action) and transition into a random emotion (a persistent state).

HelloRomo

Use both RMCore and RMCharacter to drive Romo around and make faces.

Swipe left or right on Romo's face, and he will start driving in a circle in the direction you swiped. When you poke Romo's face, he'll stop what he's doing. Finally, swipe up to change Romo's emotional state.

Documentation

The documentation can be found in the "docs" folder that comes bundeled with the SDK.

FAQ

Is the Romo App on the App Store?

Find the Romo app on the App Store

Is the Romo App open source?

Find the Romo app source code here

Is firmware source code available?

Find Romo's firmware source code here

Where can I buy a Romo robot?

There seems to be plenty of stock in online stores.

Which Romo works with the SDK?

Any Romo with either 30pin or lightning port. This includes Romo models 3A, 3B, 3L.

Which iPhone works with Romo?

iPhone 3GS and above. iPhone SE (1st gen) & iPhone 12 mini fit like a glove. iPhone 6, 7 and 8 need some squeezing but fit just fine. iPhone X and iPhone 12 (non mini) are too big.

Which iOS versions are compatible with the SDK?

The latest SDK works from iOS 6.0 up to iOS 17!

How did this come to be?

Romotive, the company behind Romo, after shutting down were kind enough to open source their code stating: "We've decided to completely open-source every last bit of Romo's smarts. All of our projects live in this repo and you're free to use them however you like."

Issues and pull requests are always welcome!

Patrons

Support us by becoming a patron!

become a patron