Archive for the ‘iPhone’ Category

Buddy 4000 + BLE App (work in progress)

Posted by Erin, the RobotGrrl on Wednesday, June 5th, 2013

We’ve been long awaiting the days when communicating to our robots from an iOS device would involve less jumping through hoops! BLE on the newer iOS devices is pretty sweet.

Here is a video demo of our app interacting with Buddy 4000 using BLE!

We’ve been working on this off and on for a few months. Actually, half of the core functionality was finished a while ago (sending data from the iOS device to the robot). The BLE module we were using wasn’t configured properly to send data from the robot to the iOS device, and we didn’t have a TI CC debugger needed to re-program the BlueGiga chip so yeah… When we heard that @sectorfej had new modules in his InMojo store, we quickly bought one!

Here is the BLE module (wires are 5V, GND, TX, RX):

ble_buddy_wip 004

There’s a great BGLib library for this module that has all sorts of features packed in to it. There wasn’t much documentation about sending data… Here’s how to do it:

  1. ble112.ble_cmd_attributes_write(20, 0, data_len_var, data_var);

The number 20 is the hard part. We couldn’t figure out where to find the info about this number or anything… so we iterated from 0-49 to find it! You might have to do the same for yours as well. Just keep an eye open on Xcode for when data is received on the app side, and then narrow down the numbers until you find the one that works.

We didn’t show this in the video, but we use sending data from the robot to the app for triggering sounds. Specifically owl and fart sounds. (Yes, this might be the most complex fart app to date). It works better with RoboBrrd, as it has sensors that can be used to trigger the sounds.

Anyway, most of the ‘core functionality’ of the app is involved with this (below) and the communication. We can even make it auto connect to a particular device (as you saw in the video), which makes the experience even more seamless.

ble_buddy_wip 003

Here is how auto-connection is done. We save the UUID and name of the device, then check if we see that specific one:

  1. - (void) connectToDefault {
  2.     // ok, let’s try this
  3.    
  4.     if(connected) return; // already connected don’t do anything
  5.    
  6.     NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
  7.     NSString *givenUUID = [userDefaults objectForKey:defaultDeviceUUIDKey];
  8.     NSString *givenName = [userDefaults objectForKey:defaultDeviceNameKey];
  9.     //CBUUID *zeeUUID = [CBUUID UUIDWithString:givenUUID];
  10.     CFUUIDRef zeeUUID = CFUUIDCreateFromString(kCFAllocatorDefault, (CFStringRef)givenUUID);
  11.    
  12.     int i = 0;
  13.     for(CBPeripheral *periph in allPeripherals) {
  14.        
  15.         if(periph.UUID == zeeUUID) {
  16.             NSLog(@"same UUID");
  17.             if([periph.name isEqualToString:givenName]) {
  18.                 NSLog(@"same name – let’s try to connect");
  19.                 self.peripheral = periph;
  20.                 [bleManager retrievePeripherals:[NSArray arrayWithObject:self.peripheral]];
  21.             }
  22.         }
  23.        
  24.         i++;
  25.     }
  26.    
  27. }

Sometimes specific BLE modules have certain service UUIDs and characteristic UUIDs that you can only send data to. We’ve never experienced a problem with ‘spamming’ everything (yet), but we built in this feature just in case. This is when data is being sent from the app to the robot.

  1. CBUUID *uuidService;
  2.     CBUUID *uuidChar;
  3.    
  4.     int ss = [selectedShield intValue];
  5.    
  6.     switch (ss) {
  7.         case 0: {
  8.             // any
  9.             uuidService = [CBUUID UUIDWithString:roboBrrdServiceUUID];
  10.             uuidChar = [CBUUID UUIDWithString:roboBrrdCharacteristicTXUUID];
  11.         }
  12.             break;
  13.         case 1: {
  14.             // kst
  15.             uuidService = [CBUUID UUIDWithString:kstServiceUUID];
  16.             uuidChar = [CBUUID UUIDWithString:kstCharacteristicTXUUID];
  17.         }
  18.             break;
  19.         case 2: {
  20.             // dr kroll
  21.             uuidService = [CBUUID UUIDWithString:drkrollServiceUUID];
  22.             uuidChar = [CBUUID UUIDWithString:drkrollCharacteristicTXUUID];
  23.         }
  24.             break;
  25.         case 3: {
  26.             // redbear
  27.             uuidService = [CBUUID UUIDWithString:redbearServiceUUID];
  28.             uuidChar = [CBUUID UUIDWithString:redbearCharacteristicTXUUID];
  29.         }
  30.             break;
  31.         default:
  32.             break;
  33.     }
  34.    
  35.    
  36.     for(CBService *aService in self.peripheral.services) {
  37.         if([aService.UUID isEqual:uuidService] || ss == 0) {
  38.             for(CBCharacteristic *aCharacteristic in aService.characteristics) {
  39.                 if([aCharacteristic.UUID isEqual:uuidChar] || ss == 0) {
  40.                     [self.peripheral writeValue:sendData forCharacteristic:aCharacteristic type:CBCharacteristicWriteWithResponse];
  41.                 }
  42.             }
  43.         }
  44.     }

This also allows us to do certain actions for different shields. While going through the example code for the RedBear BLE shield, we noticed it needed a ‘reset’ (or something). We haven’t tested this yet, but hopefully it will make the RedBear one work:

  1. if([selectedShield intValue] == 3) { // redbear shield is weird
  2.        
  3.         CBUUID *uuidService = [CBUUID UUIDWithString:redbearServiceUUID];
  4.         CBUUID *uuidChar = [CBUUID UUIDWithString:redbearResetRXUUID];
  5.         unsigned char bytes[] = {0×01};
  6.         NSData *d = [[NSData alloc] initWithBytes:bytes length:1];
  7.        
  8.         for(CBService *aService in self.peripheral.services) {
  9.             if([aService.UUID isEqual:uuidService]) {
  10.                 for(CBCharacteristic *aCharacteristic in aService.characteristics) {
  11.                     if([aCharacteristic.UUID isEqual:uuidChar]) {
  12.                         [self.peripheral writeValue:d forCharacteristic:aCharacteristic type:CBCharacteristicWriteWithResponse];
  13.                     }
  14.                 }
  15.             }
  16.         }
  17.        
  18.     }

The above is called whenever data is received by the app- eg:

  1. peripheral:didUpdateValueForCharacteristic:error:

When it is all working, it’s really fun to interact with the robot in this way!

ble_buddy_wip 002

There are still some wonky things that happen. For example, if you send too much data- or if you send it at the same time. Sometimes we don’t even know what we did and it will just disconnect (though thanks to our code, it re-connects quickly and without interrupting the user). This happens infrequently, so it might be odd cases.

Special thanks to @macisv, who at SecondConf last year taught me lots about BLE and let me experiment with it! And of course @sectorfej for making this great module that we used :)

Now for the hard part: completing and releasing it. It’s kind of weird, even though we are using this quite often… we have kind of come to dislike this interaction (of pressing and holding buttons) because it’s quite boring. So we’re not sure yet if this one will be finished, or if we’ll be trying something else, perhaps with more gestures and such.

ble_buddy_wip 001

More fun coding ahead! :D

Posted in: BLE, iPhone, Programming, Projects, Robot.

RoboBrrd & Apps for Arduino at SecondConf!

Posted by Erin, the RobotGrrl on Wednesday, September 19th, 2012

SecondConf Splash

We’re going to SecondConf! SecondConf is a developers conference for iOS and Mac. It’s sort of like WWDC, but there will be less people there, more discussions, and lots of learning of course!

We were invited to give a talk last year, but thanks to a cold on the end of Maker Faire we had to post-pone it to this year. And we were actually invited back this year to give a talk! Sweet!

If you’re going to SecondConf, our talk is Sunday at 11:00AM!

You will not want to miss it, because it will be about robots and electronics and how to create a blended reality by combining it with software!

The talk is about 40 minutes long. During the talk we will discuss:

Apps for Arduino
- “If hardware is the heart of a project, then software is its soul”
- Matatino and Wijourno frameworks
- Why lack of feature creep is its best feature
- Community, open source
- And more!

RoboBrrd
- “Do-it-yourself educational robotic pet”
- Educational aspects
- Fun hardware
- And more!

The talk will also include some demos of how everything works and such!

From what I’ve heard, the talks will be recorded and archived, so it will be online in the future.

secondconf-robotgrrl-speakers

Check it out! Dr. Wave is also going to be there! Remember when RoboBrrd visited Pixar while we were at Evil Mad Science? It’s always really interesting to learn more about Pixar, movies, software, and just so many things.

Bob Kressin, who is the presenter right after me then lunch, is also doing a presentation on Bluetooth Low Energy. This will also be really cool, since we are going to work together to get RoboBrrd working with BLE on Friday! I’m totally psyched for this!

Mega thank you for SecondConf for the opportunity and accommodations! It’s going to be great. Looking forward to meeting everyone!

Posted in: apps4arduino, Fun, iPhone, Programming, Projects.

RoboBrrd Food – Using the Redpark Serial Cable

Posted by Erin, the RobotGrrl on Thursday, July 21st, 2011

Remember a while ago, when I was able to send data through the MFi SkyWire cable? It turns out, now there is a cable designed for hobbyists, with an SDK, by Redpark! They were very kind enough to send me a cable, so I figured that the first thing to try would be to feed RoboBrrd!

Here is a video where I explain everything in detail!

View video on YouTube

Here is a link to the code on Github!

What is next? For WWDC 2011 legacy sake, I will probably try to drive DOGCOW robot with the iPhone’s accelerometer. This time though, the cable would be attached to an XBee so that it will be wireless. :D

Posted in: iPhone, Programming, Projects, Robot.

Logomotionator

Posted by Erin, the RobotGrrl on Tuesday, March 22nd, 2011

Logomotionator

Logomotionator is an App for the FIRST Robotics Competition 2011 that I created during the build season while helping out Team 296: The Northern Knights! You can download it on iTunes for free.

Here is the description of Logomotionator:

Logomotionator provides a way for teams to organize and collect their ideas about strategy and scoring during the 2011 FIRST Robotics Competition season.

Features:
- Fabulous user interface design
- Track the scoring for the red and blue alliance
- Up to 5 tubes per peg will be counted (in case some are deflated)
- Record which teams were on the alliances, their minibot scores and penalties
- View your saved scores and email them
- Draw strategic plays on the game field in red and blue
- Easily access the usfirst.org website

The FIRST Robotics Competition is a fantastic way to get youth interested in Science, Technology, Engineering and Math. Check out one of the regional competitions in your area to see what the future holds.

Inspiration for the App came about by the temptation of an Apple eMate 300 (an iPad of 10 years ago, basically)! I took in some feature requests and just started to work away at it. Making the calculator algorithm was fun :)

All of the coding was straight forward. I must be getting really good at making Apps or something. Making the game field drawing stuff was probably the part I most enjoyed:

Logomotionator

I also really enjoyed the email stuff too:

Logomotionator

The only rough spot was on the saved scores view, because the “Remove button” is actually in a different section, I have to replace it with an invisible cell when removing everything because of the protective UITableView cell math.

Logomotionator

Once all of the functionality was there I wanted to make something that would really capture the energy that the competitions have. I figured it would have to look snazzy, so I paid close attention to detail when styling the App. On the iPhone 4′s retina display, the graphics look beautiful.

Logomotionator

This is what the background looks like, I had a lot of fun making it!

Logomotionator

This is my most complete App ever (so far). I really like the finished product. I can’t wait until after the season is over to go through some of the code with the programming students. It would be a fun exercise to break down the calculator algorithm!

I hope you enjoy it. There’s some more screenshots on flickr. Go download Logomotionator now! It’s free!


FIRST®, FIRST® Robotics Competition, FRC®, FIRST® Tech Challenge, and FTC®, are registered trademarks of FIRST® (www.usfirst.org) which is not overseeing, involved with, or responsible for this activity, product, or service.

Posted in: Art, FIRST, iPhone, Programming, Projects.

Apps on the Desk

Posted by Erin, the RobotGrrl on Monday, December 13th, 2010

I have been coding up an App storm the past few weeks!

IMG_9990

First off, I got an actual phone that runs the Android OS! The user experience is sort of meh, I guess it’s a personal opinion sort of thing. What they did on the Android OS was separate some functions out to the hardware. I have to admit, it’s a bit confusing to go from the mindframe of everything will be accessible via the screen to pressing actual buttons. The menu button is great, though.

Making Android Apps is done in Java (yay, my first language!) through Eclipse. It will be fun to do some of the advanced things on this platform, like Augmented Reality. I would love to Augment explosions, so you can blow stuff up with your mind (er, smartphone), without harming anything. Imagine how much more peaceful the world would be with such an App?!

:)

Next, KiloWhatt a la iPad: Split Screen View

Screen shot 2010-12-13 at 2.55.53 PM

The split screen view is really important in iPad Apps. KiloWhatt, right now, is the only energy management App for iPad, so updating its Universality is quite important. Making split views is, of course, more tricky than it seems. There are some really bad gotchas that can get to you. The one that got me was auto-rotation, it was sneaky. ;) (You have to have autorotation enabled for all views).

All that is left in this version is to get all the information appearing, and make some popup view controllers. I missed the deadline for the App submission before Christmas, so I think I will work on this more for a few weeks to improve everything, like adding in the easy-peasy plist sorting capabilities.

Sorting data in Cocoa is breathtaking. Imagine you have a NSArray of NSDictionary…

  1. NSSortDescriptor *dateSortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"Day" ascending:YES selector:@selector(compare:)] autorelease];
  2. [arrayOfDictionarys sortUsingDescriptors:[NSArray arrayWithObjects:dateSortDescriptor, nil]];

forrst

HOW BEAUTIFUL IS THAT?! SERIOUSLY! IT TOTALLY DESERVES CAPS LOCK!

I also want to add in some Three20, Twitter, and Game Center.

:D

Finally, the crazy particle kaleidoscope.

Kaleidoscope Particles iOS Cocos2d from RobotGrrl on Vimeo.

Screen shot 2010-12-13 at 2.58.42 PM

This is using Cocos2d for iPhone. It is amazing. This actually runs at 60fps on an iPhone 4, and rarely drops to 58fps. I was trying to use Core Animation for a lot of things, like a Crazy Stars revamped, but Cocos2d is definitely better to use. They have lots of documentation, examples, and friendly people on IRC who help you out.

What I want to do with this App is add in some Box2d, so that I can fling the particle around and it will be bouncing all over the place! It would also be really neat if I can add some satellites around each of the emitters. I really enjoy the way single pixels show up on a retina display, they are tiny and crisp, so it would be interesting to see those flowing around the emitters.

:D

Special shout out to Ken aka Retro for sending me 20 chips that I can use as the biocore in BEAM robots! Oh, and these hilarious Robot Monkey tissues!

207739342

To finish off, here’s a nice photo I took a few weeks ago:

IMG_0229 - Version 2

Posted in: Android, iPhone, Programming, Projects.

Canada Spirit!

Posted by Erin, the RobotGrrl on Tuesday, November 30th, 2010

Canada Spirit

Canada Spirit is now available on the App Store! Woot! It is a Free App, with an optional In-App upgrade. You can check it out here:

US: http://itunes.apple.com/us/app/canada-spirit/id394637853?mt=8
Canada: http://itunes.apple.com/ca/app/canada-spirit/id394637853?mt=8

The App has actually been complete for 3 months now, but there were complications along the way. It’s a long story:

For Apps that use In-App purchases, you have to have your App reviewed (without the In-App purchase capabilities) and rejected. This takes approximately 1.5 weeks. Not to mention, that you have to make the App without the In-App capabilities, which, depending on the complexity and time dedication, could be a few days. We’re already looking at 2 weeks waiting here.

Once your App is rejected, you can finally test the In-App purchase sandbox part of your App. SWEET. Add a few days for debugging. We’re up to a total of about 2.5 weeks used to be waiting here.

This is when the crazy part happened to me. For the In-App purchase, I selected the option “Canadian English” for the language. When my App moved to “In Review” (yesss finally!), they removed that language, which forced my In-App purchase to be in a “Developer Action Required” state- and thus no In-App Purchase approval. The whole point of submitting your App (without the In-App purchase capability) to be rejected was to get the In-App purchase approved.

For this, an additional 1.5 weeks were added. We’re already at 4 weeks here! >_<

Depending on how carefully you read the guidelines for the App Store, then you can be waiting about a month. That’s what happened to Canada Spirit. It got caught in the payment for hardware devices clause. This added another 1.5 weeks…

Once the App was resubmitted, the In-App purchase language options changed AGAIN. Luckily though this time the App Store review team actually contacted me and I was able to fix the In-App without having to go to the back of the line. YAY!

You have to have a lot of dedication to survive the App Store review process. Canada Spirit went through 6 weeks of poking and prodding just to get to you guys, so I hope you enjoy it :D Post your screenshots of whatever photos you decorate on Flickr so that we can see them!

Also, sharing this story isn’t meant to be against the App Store at all. I still enjoy the App Store as a consumer and developer! It is to cast some awareness on the time investment you will have to make if you want to do some In-App purchases! :D

Posted in: iPhone, Projects.

S7GraphView Zoom & Pan Code

Posted by Erin, the RobotGrrl on Wednesday, October 20th, 2010

Here is the code for the S7GraphView Zoom & Pan modification that I mentioned a while ago for the s7graphview iOS framework.

DemoS7GraphView-ZoomPan.zip

If anyone out there improves it more, please leave a comment! :D

Posted in: iPhone, Projects.