Home Community Blog Buy Now
Blog

Misty Community Forum

Seeking advice: adding whiskers

As my first project for Misty I wrote a skill to patrol a perimeter by following the right hand wall. The environment is a regular house with a circular floor plan and assorted furniture including bookshelves, coffee tables, etc., so, some narrow-ish spaces. Navigation uses only the TimeOfFlight sensors. The problem comes with furniture which Misty doesn’t see with the TOF’s. I’ve played with the TakeDepthPicture functionality, but it doesn’t look like that will work.

So I’m thinking of adding whiskers for detecting things on the front and sides, and I’m looking for advice on how to start. I’ve never done anything with arduino or raspberry pi, and don’t know which might be cheaper or easier with Misty. I’m looking for the cheapest/easiest way to get started. All suggestions welcome.

Hi @james.s.seattle this is an amazing idea! and I love the idea of putting whiskers on Misty! Unfortunately I have not added whiskers to Misty and haven’t seen someone try it out yet but I would LOVE to see someone give it a shot.

The closest to whiskers that I have done on a robot is this robotics kit ->Robotics with the Board of Education Shield for Arduino | LEARN.PARALLAX.COM
It’s a really good starter kit for robotics and arduino programming and not too expensive. I’m not certain but you may be able to modify this kit to incorporate it into Misty.

The alternative might be too also incorporate the bump sensors into your application that might help with furniture it doesn’t see. The idea here might be that when Misty “bumps” into a furniture piece that the TOF sensor did not see it will adjust it’s path accordingly.

I hope this helps and I welcome any other discussions you might have in this very exciting project.

Hey @Woo, at the risk of disappointing about the whiskers, I think I’m going to try ultrasound depth sensors first, as they should give actual distance data.

I should add that I have incorporated the bump sensors, but that doesn’t stop Misty from trying to crawl under coffee tables, usually falling over backwards in the process. [Yes, I’ve been catching.]

Let me know if you have any other advice.

That’s a great idea! I can’t wait to hear more about how it goes!

Yes - Misty does like to occasionally sneak under coffee tables but I’m glad you are able to catch her.

Another idea might be to use the Occipital Structure Sensor Core to give you a depth array map -> Misty Docs | API Reference

Hey @Woo, or anybody …

So I got the ultrasonic depth sensor with a qwiic cable and it’s super easy to set up. Now I’m wondering if I can daisy chain another. Problem is I can’t find any examples how to have the arduino backpack tell one from the other. Any ideas?

*

Hi @james.s.seattle that’s a great question. You mean tell one ultrasonic depth sensor from the other? I’ve not used that before but I’m interested to test it out. Do you have a link to the one you bought? I’ll see whether I can buy one and test it out.

Hey Justin @Woo, yes, trying to tell one depth sensor from the other.

So I got two of these Zio Ultrasonic Distance Sensor - HC-SR04 (Qwiic)(Zio Ultrasonic Distance Sensor - HC-SR04 (Qwiic) - SEN-15171 - SparkFun Electronics) from Sparkfun (+ 2 qwiic cables).

Below is the program for the arduino backpack which works for just one sensor on the qwiic bus. My best guess [me=rank beginner] is that SLAVE_ADDR is an address for the sensor, and that if I could establish a different address (SLAVE_ADDR2) for the other sensor I would be set, but I don’t know how to go about doing that.

This is the arduino code:

#include <Wire.h>

void setup() {
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial communication at 9600bps
}

int reading = 0;

#define SLAVE_BROADCAST_ADDR 0x00 //default address
#define SLAVE_ADDR 0x00 //SLAVE_ADDR 0xA0-0xAF
uint8_t distance_H=0;
uint8_t distance_L=0;
uint16_t distance=0;

void loop() {

Wire.beginTransmission(SLAVE_ADDR); // transmit to device #8
Wire.write(1); // measure command: 0x01
Wire.endTransmission(); // stop transmitting

Wire.requestFrom(SLAVE_ADDR, 2); // request 6 bytes from slave device #8
while (Wire.available()) { // slave may send less than requested
distance_H = Wire.read(); // receive a byte as character
distance_L = Wire.read();
distance = (uint16_t)distance_H<<8;
distance = distance|distance_L;

Serial.print("{“message”:“Hello, Misty! This is your backpack talking.”,");
Serial.print("“distance”:");
Serial.print(distance);
Serial.println("}");
delay(100);
}
}

Okay @Woo, on further research there is good news and bad news. The good news is that you can check each of the addresses available to see if there is a device there. The bad news is it looks like two ultrasonic sensors daisy-chained by qwiic share the same address, which is 0. Sometimes readings will come from one, sometimes the other.

So it looks like I’d have to use a second arduino?

@james.s.seattle The HC-SR04 sensor you are using has a rated current draw of about 15 mA. The Arduino’s GPIO pin is capable of sourcing that. So an alternative you might try is to connect the Vcc pin of each of the sensors to a GPIO on the arduino, and turn only one of the sensors on at a time. Read it, turn it off, turn the other one on, and then read it. This works so long as the time it takes to turn the sensor on and get the first reading is fast enough that you get the data you need. You can also consider turning the 2nd one on just before you start reading the first one, which will give you more time for the sensor to get its sample. I didnt look yet, but there are likely other ultrasonic sensors that will allow you to connect multiple instances to the same Arduino. In the end I would argue that it is better to have only one microcontroller and get the sensors that will work with it. Much easier in the end.

1 Like