.st0{fill:#FFFFFF;}

Education

Pidog: my new lab dog that understands Python 

 April 10, 2023

By  Peter

Join Our Mailing List

We publish fresh content each week. Read how-to's on Arduino, ESP32, KiCad, Node-RED, drones and more. Listen to interviews. Learn about new tech with our comprehensive reviews. Get discount offers for our courses and books. Interact with our community.

One email per week, no spam, unsubscribe at any time.

Sunfounder shared their new (ahem…) pet project with me: Pidog.

Pidog is an educational robotic dog and is currently experimental and under development. I was lucky to have the opportunity to play with an early prototype and to be able to write about it.

Pidog sitting on his mat. You can see his camera, range finder, touch sensor (behind the range finder), IMU (on his right side) and mood RGB LED indicator (front of the body).

Instead of muscles, he (it looks like a “he” to me) has servo motors. Instead of eyes, he has a camera and ultrasonic distance sensor. Instead of ears, he has a custom sound direction sensor and a 6-degree-of-freedom IMU (inertial measurement unit). Instead of a mouth, he has a speaker.

Pidog also has a touch sensor on the top of his head (so he knows when you pat him), and can express his mood with his tail and the RGB LED at the front of his body.

Thanks to all of these components, Pidog can see me and track my face, walk, bark and growl, scratch his “ear”,

The brain of Pidog is a Raspberry Pi. Given the shortage of Raspberry Pi’s at the moment, my Pidog is using a Raspberry Pi 3 and performs very well. On top of the Pi, Pidog has a HAT with outputs for the servo motors and input/outputs.

Pidog’s favourite snack is electricity, which I provide a lot of via USB-C. He can store much of it in a battery, which keeps him happy for several hours.

Pidog trick examples

Most of our communication is through wifi. I also find that better than using voice commands. Although Pidog can hear me, my voice commands sometimes confuse him.

So, I use Wifi with my phone. Here is an example:

Phone control

Pidog comes in lots of parts. It took me around four hours to assemble him. But, it was worth it. Just look at him trying to balance for the first time:

Balancing

Yes, he is a bit clumsy, but he’s got so much potential! Just a few minutes later, he’s on doing perfect pushups!

Doing pushups

Pidog comes with a lot of (Python) tricks out-of-the-box. Here’s one, where he’s on patrol. During the patrol, Pidog looks for intruders. When he finds one, he will stop, bark at them, and show displeasure via his RGB strip:

On patrol

Here’s the Python script that teaches Pidog how to do “patrol” (this script comes with the Pidog examples collection):

#!/usr/bin/env python3
import time
from pidog import Pidog
from time import sleep
from preset_actions import bark

t = time.time()
my_dog = Pidog()
my_dog.do_action('stand', speed=80)
my_dog.wait_all_done()
sleep(.5)

DANGER_DISTANCE = 15

stand = my_dog.legs_angle_calculation([[0, 80], [0, 80], [30, 75], [30, 75]])

def patrol():
    distance = round(my_dog.ultrasonic.read_distance(), 2)
    print(f"distance: {distance} cm", end="", flush=True)

    # danger
    if distance < DANGER_DISTANCE:
        print("\033[0;31m DANGER !\033[m")
        my_dog.body_stop()
        head_yaw = my_dog.head_current_angles[0]
        my_dog.rgb_strip.set_mode('boom', 'red', delay=0.01)
        my_dog.tail_move([[0]], speed=80)
        my_dog.legs_move([stand], speed=70)
        my_dog.wait_all_done()
        sleep(0.5)
        bark(my_dog, [head_yaw, 0, 0])

        while distance < DANGER_DISTANCE:
            distance = round(my_dog.ultrasonic.read_distance(), 2)
            if distance < DANGER_DISTANCE:
                print(f"distance: {distance} cm \033[0;31m DANGER !\033[m")
            else:
                print(f"distance: {distance} cm", end="", flush=True)
            time.sleep(0.01)
    # safe
    else:
        print("")
        my_dog.rgb_strip.set_mode('breath', 'white', delay=0.1)
        my_dog.do_action('forward', step_count=2, speed=98)
        my_dog.do_action('shake_head', step_count=1, speed=80)
        my_dog.do_action('wag_tail', step_count=5, speed=99)


if __name__ == "__main__":
    try:
        while True:
            patrol()
            time.sleep(0.01)
    except KeyboardInterrupt:
        pass
    except Exception as e:
        print(f"\033[31mERROR: {e}\033[m")
    finally:
        my_dog.close()

Much of the functionality that you can use to teach Pidog custom behaviours is nicely packaged in the Pidog module that Sunfounder provides.

I am now trying to teach my bio-dog (Einstein) to play nice with Pidog. This is proving to be a difficult challenge. Einstein is worried that Pidog is getting all my attention.

Not getting along with Einstein

More imagery

Here are some more photos with details of the Pidog components:

In conclusion

Pidog is a Sunfounder project, and as I am writing this post, it is under development.

Already, it is an excellent robotics kit that is particularly appealing to STEM educators.

While the really difficult technical robotics problems (such as maintaining balance, walking straight, and using the video camera to track a face) have been solved by Sunfounder’s engineers, what is left for the learners are the (also very difficult) creative problems. For example, how can you make Pidog behave like a cute puppy, or understand the difference between a bio-dog and a human? How can you teach him to fetch a stick? (Ok, he will need some new hardware for this, but that’s an interesting problem).

Or, even more important, how can you make Pidog look at you like this (see below) when he wants to go for a walk?

Take me for a walk, please!

This is the kind of robotics kit that can help learners to unleash their creativity because it provides a workbench with a wide range of possibilities.

I do hope that Pidog hits the market soon.

If you had a Pidog, what would you do with it?


Tags

pidog


You may also like

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Learn Arduino Online: New Simulator Tutorials in Arduino Step by Step Getting Started I’m thrilled to share a major update to my course, Arduino Step by Step Getting Started. The course now includes a comprehensive

Read More
New Simulator Tutorials in Arduino Step by Step Getting Started

When compared TFT, LCD, and OLED, E-paper displays stand out for their energy efficiency, excellent readability in bright light, and a look that mimics traditional ink on paper. The Crowpanel ESP32 4.2” e-paper display, offered

Read More
Crowpanel ESP32 4.2” E-Paper Display: A Versatile and Energy-Efficient HMI Solution