Robot Not a Dev? Pre-order Now
Not a Dev?

Misty BackPack Documentation and API?


#1

Back on May 23rd, 2018, Steven Kibler posted a blog (Creating an LED mohawk for Misty (part 2) | Misty Robotics) where he described an Arduino library he was developing for use with the Misty backpack. Now that early versions of Misty II and her backpack are being made available to early adopters is there more information available? For example, is the Arduino library available? Is there documentation available on how to best mount an Arduino in the backpack? Also, the same questions for Raspberry Pi.


#2

I’ll bet @cp_sridhar, @steven, and others may have an idea of how to proceed even if we don’t have an “official API” yet. :crossed_fingers:


#3

Indeed, there are no official docs or API available yet, @miker. But… I’m certain that CP or Steven would be happy to help with specific questions.


#4

Hey there Miker. My understanding is that there is a simple API in place for exchanging simple string messages between the backpack and the user software. It would be best to have @cp_sridhar talk about that, as he has the most experience with it. I’ll make sure he sees this post. The LED mohawk was self-contained and did not use the API, so I’m only familiar with it in concept, not in practice. I can certainly help you with the electrical and Arduino side of it though. You’re asking about mounting an Arduino or Raspberry PI. So you don’t want to use our official backpack but make one of your own? If thats not the case let me know. What I did for mohawk was grab a standard protoboard, with 0.1" spacing between the pads, and cut off a small square of it, just big enough to touch all the pogos and have some extra room for soldering my leads to it. The pogo pins on the back are 0.1" spaced, so I put the backplate of the backpack on the back, and lined up the piece of protoboard with the pogo pins, and I just hot glued it in place. I chose a protoboard that had built-in electrical connections between pads (like this one: Adafruit Flex Perma-Proto - Half-sized Breadboard Flex-PCB ID: 1518 - $7.50 : Adafruit Industries, Unique & fun DIY electronics and kits). From the protoboard I soldered wires from power and ground to my Arduino. If I was controlling it through the API I’d also solder the RX/TX lines to my Arduino. The power to the backpack is 3.3V at up to 500 mA. I don’t want to ramble on, so I’ll leave it at that, and if you have any specific questions I’ll do my best to help you out. Just let me know!


#5

I should point out that @cp_sridhar (CP) is pretty busy prepping for some demos for CES next week so he may not get to this right away. I am sure if he has something quick he could share on Github or something though!


#6

Sending data to Misty as a String Message

From Arduino:
Serial.println("<your_data_to_Misty>");

From Raspberry:
Disable Serial Port access on boot and Enable I2C on GPIO pins using
sudo raspi-config` in the terminal
I then used python to send data to Misty and used library serial.

import serial
uart = serial.Serial('/dev/serial0', baudrate=9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE,bytesize=serial.EIGHTBITS, timeout=1)
uart.write("<your_data_to_Misty>\n".encode())

Best Practice:
Format your string as a JSON so it can be easily parsed out in a Misty Skill
Example: Sending temperature & pressure data from Arduino to Misty can look like this:

Serial.println("{\"temperature\":\""+String(<temp_value>)+"\",\"pressure\":\""+String(<pressure_value>)+"\"}");

On Misty Skill:

misty.AddReturnProperty("StringMessage", "StringMessage");
misty.RegisterEvent("StringMessage", "StringMessage", 0, true);
function _StringMessage(data) {
if(data !== undefined &amp;&amp; data !== null) {
var obj = JSON.parse(data.AdditionalResults[0].Message);
var temp_misty_in       = obj.temperature;
var pressure_misty_in = obj.pressure;
}}

For more details on misty.AddReturnProperty and misty.RegisterEvent please refer to our SDK Doc.
Hope this helps ! :slight_smile:


#7

Thank you all for your replies. They have helped clarify the situation greatly.

The backpack that accompanied the Misty II that I received was empty. I assumed from this that it was up to me to provide the Arduino or Raspberry Pi. Are there any backpacks available at this time that include the pre-mounted Arduino?

I am primarily a software person with a smattering of hardware when needed. I was considering acquiring a Pixy2 and connecting it to Misty as a basis for some “follow me” experiments. One mismatch seems to be that the Pixy2 assumes 5V power via USB but the backpack only provides 3.3V. Is that correct? Also the Pixy2’s typical power consumption is 140mA and the backpack provides 500mA which would be shared between the Pixy2 and an Arduino. Is that also correct?


#8

We are still in the pre-production phase for those backpacks that have the Arduinos in them. I will enquire about pre-release version of those.


#9

Powering Pixy2 and Arduino

Misty has two interfaces on the backpack

  1. USB 5V 0.5A
  2. UART that is 3.3V logic

You could use the USB to power the Pixy and still use Arduino with UART. Internally they do have a common ground, so it should just work fine. ‘Follow me’ with Pixy on Misty would really be cool! I am excited! Do keep us posted !


#10

Also note that the USB and UART backpack channels have separate power controllers, each providing up to 500 mA. Therefore the 140 mA draw by the Pixie won’t need shared with your Arduino load.


#12

I have acquired an Uno and a Pixy2. My plan is to connect them to Misty II as follows:
[Misty II USB] <—> [Arduino USB … Arduino ICSP] <—> [Pixy2]
as the Pixy2 provides the ICSP cable.
Before that, however, I just want to verify that I can send serial data successfully from the Arduino to Misty. I am just trying to send the single json-formatted temperature and pressure line. I have copied the Arduino and Misty code from the docs.
The Arduino code works fine with the Arduino IDE and serial monitor.
The serial monitor shows:
{“temperature”:“69”,“pressure”:“30”}
However, I am not apparently receiving the Arduino serial data when connected to Misty.
I am a little vague on what the correct serial speed value should be in the Arduino setup().
I can post my code fragments if necessary but I am hoping I am just missing something obvious. Suggestions, please. Thanks.


#13

I tried this simplified version this morning without success.

----- MERSerial00.ino -----

void setup()
{
  Serial.begin(115200);
}
  
void loop()
{
  while (1==1) {
    delay(1000);
    Serial.println("AbCdEfGhIj");
  }
}

----- MERSerial00.js ------

    misty.AddReturnProperty("StringMessage", "StringMessage");
    misty.RegisterEvent("StringMessage", "StringMessage", 0, true);

    function _StringMessage(data) {
      misty.Debug("MERSerial00 received " + data);
    }

----- MERSerial00.json ----

    {
      "Name": "MERSerial00",
      "UniqueId": "b36a27f6-cccd-449a-a195-9b18a7c1ea86",
      "Description": "Simply dump Arduino data received via USB",
      "StartupRules": [ "Manual", "Robot" ],
      "Language": "javascript",
      "BroadcastMode": "verbose",
      "TimeoutInSeconds": 300,
      "CleanupOnCancel": false,
      "WriteToLog": true,
      "Parameters": { }
    }

#14

@cp_sridhar Can you take a look at @miker’s code? Thanks very much!


#15

My hunch is that you’ll need to access the message sent through the USB by digging into the AdditionalResults array in the data object. (When you use misty.AddReturnProperty(), the data you specify is added to this AdditionalResults array.)

I don’t have the hardware to test this, so I can’t guarantee that this is your issue, but you might try changing the block that executes in the _StringMessage() callback to this something like this:

MerSerial00.js

misty.AddReturnProperty("StringMessage", "StringMessage");
misty.RegisterEvent("StringMessage", "StringMessage", 0, true);

function _StringMessage(data) {
     var message = data.AdditionalResults[0].Message
     misty.Debug("MERSerial00 received " + message);
}

I’ll leave it to @cp_sridhar to check if that’s right and provide further guidance :wink:


#16

Hi Miker :slight_smile: It is great to see you expanding Misty’s capabilities !!

Here are some mods that might get your test to work.

On The Auduino Side
Use baud rate 9600 instead of 115200
Serial.begin(9600);

On Misty Side
Jonathan has got it right…

function _StringMessage(data) {	
    misty.Debug(JSON.stringify(data.AdditionalResults[0].Message));
}

#17

Is there any way for me to see what data Misty II is receiving on its USB port from the Arduino Uno? I made the suggested changes and reverted to a JSON version of the code that sends data from Arduino to Misty II USB every second. The TX light on the Arduino blinks every second but my javascript never appears to get called.


#18

When you say “reverted to a JSON version of the code” – does this mean you’re attempting to send a JSON object to Misty instead of the test string in your first example?

You might try using the API Explorer to check if Misty is receiving messages, and to see what those messages are. Make sure you’ve selected Misty II from the drop-down at the top of the explorer, then go to the WebSockets section and use the form to subscribe to the StringSensor named object. Once subscribed, if Misty is indeed receiving messages, then I believe you should see the data from the event (including the data Misty received from the Arduino) print to the JavaScript console.


#19

Thank you for your input. I tried the API Explorer per your suggestion but saw nothing in the JavaScript console. At this point I am starting to believe that the USB port on the Misty II is not working.


#20

Hypothetically, suppose for the moment that the Misty II
I have in my possession is the final product version
that will be shipped to me in April. Pretend that I attempt
to use my Arduino Uno with the Misty II USB port and am
unable to get successful data communication to function.
What will be my options at that point? Will there be a
diagnostic that I can run on the Misty II to analyze the
USB port and verify that it is indeed functioning
correctly? If so, are there any similar programs in
existence now that I could run to verify the USB port?


#21

Great question. I am looking into this @miker. I for sure don’t have an answer offhand, but I’ll get back to you as soon as I know something useful.