Hide thumbs Also See for PiDog:

Advertisement

Quick Links

SunFounder PiDog Kit
Release 1.0
sunfounder
Jan 09, 2023

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the PiDog and is the answer not in the manual?

Questions and answers

Summary of Contents for SunFounder PiDog

  • Page 1 SunFounder PiDog Kit Release 1.0 sunfounder Jan 09, 2023...
  • Page 3: Table Of Contents

    CONTENTS 1 Component List and Assembly Instructions 2 Play with Python Quick Guide on Python ......... Funny Project .
  • Page 5 SunFounder PiDog Kit, Release 1.0 Thank you for choosing our PiDog. PiDog is a Raspberry Pi pet robot with aluminum alloy structure. It can act as a mechanical pet, show cuteness to you, and interact with you. It is equipped with a camera module, which can perform color recognition, face detection and other projects; 12 metal gear servos support it to walk, stand, sit, shake its head, and pose in various poses;...
  • Page 6 SunFounder PiDog Kit, Release 1.0 Content CONTENTS...
  • Page 7: Component List And Assembly Instructions

    CHAPTER COMPONENT LIST AND ASSEMBLY INSTRUCTIONS You need to check whether there are missing or damaged components according to the list first. If there are any problems, please contact us and we will solve them as soon as possible. Please follow the steps on the PDF to assemble. If the servo has been powered on, please do not turn the Servo shaft to avoid damage.
  • Page 8 SunFounder PiDog Kit, Release 1.0 Chapter 1. Component List and Assembly Instructions...
  • Page 9: Play With Python

    CHAPTER PLAY WITH PYTHON If you want to program in python, then you will need to learn some basic Python programming skills and basic knowledge of Raspberry Pi, please configure the Raspberry Pi first according to Quick Guide on Python. 2.1 Quick Guide on Python This section is to teach you how to install Raspberry Pi OS, configure wifi...
  • Page 10 SunFounder PiDog Kit, Release 1.0 Power Adapter To connect to a power socket, the Raspberry Pi has a micro USB port (the same found on many mobile phones). You will need a power supply which provides at least 2.5 amps.
  • Page 11 SunFounder PiDog Kit, Release 1.0 Sound or Earphone The Raspberry Pi is equipped with an audio port about 3.5 mm that can be used when your screen has no built-in speakers or when there is no .00 screen operation. 2.1.2 Installing the OS...
  • Page 12 SunFounder PiDog Kit, Release 1.0 Warning: Upgrading the Raspberry Pi OS to Debian Bullseye will cause some features to not work, so it is recommended to continue using the Debian Buster version. In the Raspberry Pi Imager, click CHOOSE OS -> Raspberry Pi OS(other).
  • Page 13 SunFounder PiDog Kit, Release 1.0 Step 5 Select the SD card you are using. Step 6 To open the advanced options page, click the setting button (appears after selecting operating system) or press Ctrl+Shift+X. Enable ssh and set the username and name. You can choose to always use this image customization options.
  • Page 14 SunFounder PiDog Kit, Release 1.0 Then scroll down to complete the wifi configuration and click SAVE. Note: wifi country should be set the two-letter ISO/IEC alpha2 code for the country in which you are using your Raspberry Pi, please refer to the following link: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_...
  • Page 15 SunFounder PiDog Kit, Release 1.0 Step 7 Click the WRITE button. 2.1. Quick Guide on Python...
  • Page 16 SunFounder PiDog Kit, Release 1.0 Step 8 If your SD card currently has any files on it, you may wish to back up these files first to prevent you from permanently losing them. If there is no file to be backed up, click Yes.
  • Page 17 SunFounder PiDog Kit, Release 1.0 Step 9 After waiting for a period of time, the following window will appear to represent the completion of writing. 2.1. Quick Guide on Python...
  • Page 18 SunFounder PiDog Kit, Release 1.0 2.1.3 Set up Your Raspberry Pi If You Have a Screen If you have a screen, it will be easy for you to operate on the Raspberry Pi. Required Components Any Raspberry Pi 1 * Power Adapter...
  • Page 19 SunFounder PiDog Kit, Release 1.0 If You Have No Screen If you don’t have a monitor, you can remotely log into your Raspberry Pi. You can apply the SSH command to open the Raspberry Pi’s Bash shell. Bash is the standard default shell for Linux.
  • Page 20 SunFounder PiDog Kit, Release 1.0 Have Temporarily Monitor (or TV)? 1. Connect a monitor (or TV), mouse and keyboard to the Raspberry Pi and power it on. Select the menu according to the numbers in the figure. 2. The following screen will be displayed. Set VNC to Enabled on the Interfaces tab, and click OK.
  • Page 21 SunFounder PiDog Kit, Release 1.0 3. A VNC icon appears on the upper right of the screen and the VNC server starts. 4. Open the VNC server window by clicking on the VNC icon, then click on the Menu button in the top right corner and select Options.
  • Page 22 SunFounder PiDog Kit, Release 1.0 5. You will be presented with the following screen where you can change the options. Set Encryption to Prefer off and Authentication to VNC password. 6. When you click the OK button, the password input screen is displayed. You can use the same password as the Raspberry pi password or a different password, so enter it and click OK.
  • Page 23 SunFounder PiDog Kit, Release 1.0 You are now ready to connect from your Mac. It’s okay to disconnect the monitor. From here, it will be the operation on the Mac side. 1. Now, select Connect to Server from the Finder’s menu, which you can open by right-clicking.
  • Page 24 SunFounder PiDog Kit, Release 1.0 3. You will be asked for a password, so please enter it. 4. The desktop of the Raspberry pi will be displayed, and you will be able to operate it from the Mac as it is.
  • Page 25 SunFounder PiDog Kit, Release 1.0 Don’t Have Temporarily Monitor (or TV)? • You can apply the SSH command to open the Raspberry Pi’s Bash shell. • Bash is the standard default shell for Linux. • The shell is a command line interpreter (CLI) when the user uses Unix/Linux.
  • Page 26 SunFounder PiDog Kit, Release 1.0 2. The following message will be displayed only when you log in for the first time, so enter yes. The authenticity of host 'raspberrypi.local (2400:2410:2101:5800:635b:f0b6:2662:8cba)' can't be established. ED25519 key fingerprint is SHA256:oo7x3ZSgAo032wD1tE8eW0fFM/ kmewIvRwkBys6XRwg. This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])? 3.
  • Page 27 SunFounder PiDog Kit, Release 1.0 sudo raspi-config 6. The following screen will be displayed. Select 3 Interface Options with the arrow keys on the keyboard and press the Enter key. 7. Then select P3 VNC. 8. Use the arrow keys on the keyboard to select <Yes> -> <OK> -> <Finish> to complete the setup.
  • Page 28 SunFounder PiDog Kit, Release 1.0 9. Now that the VNC server has started, let’s change the settings for connecting from a Mac. To specify parameters for all programs for all user accounts on the computer, create /etc/vnc/ config.d/common.custom. sudo nano /etc/vnc/config.d/common.custom After entering Authentication=VncAuthenter, press Ctrl+X ->...
  • Page 29 SunFounder PiDog Kit, Release 1.0 pi password or a different password. sudo vncpasswd -service 11. Once the setup is complete, restart the Raspberry Pi to apply the changes. sudo sudo reboot 12. Now, select Connect to Server from the Finder’s menu, which you can open by right-clicking.
  • Page 30 SunFounder PiDog Kit, Release 1.0 14. You will be asked for a password, so please enter it. 15. The desktop of the Raspberry pi will be displayed, and you will be able to operate it from the Mac as it is.
  • Page 31 SunFounder PiDog Kit, Release 1.0 Windows Users If you’re a Windows user, you can use Windows PowerShell to login Raspberry Pi remotely. 1. Press the windows + R shortcut key in your keyboard to open the Run program. Then type powershell in the input box.
  • Page 32 SunFounder PiDog Kit, Release 1.0 The authenticity of host 'raspberrypi.local (192.168.6.116)' can't be established. ECDSA key fingerprint is SHA256:7ggckKZ2EEgS76a557cddfxFNDOBBuzcJsgaqA/ igz4. Are you sure you want to continue connecting (yes/no/[fingerprint])? Input “yes”. 5. Input the password you set before. (Mine is raspberry.) Note: When you input the password, the characters do not display on window accordingly, which is normal.
  • Page 33 SunFounder PiDog Kit, Release 1.0 2. Choose 3 Interfacing Options by press the down arrow key on your keyboard, then press the Enter key. 3. Then P3 VNC. 4. Use the arrow keys on the keyboard to select <Yes> -> <OK> -> <Finish> to complete the setup.
  • Page 34 SunFounder PiDog Kit, Release 1.0 Login to VNC 1. You need to download and install the VNC Viewer on personal computer. 2. Open it once the installation is complete. Then, enter the host name or IP address and press Enter.
  • Page 35 SunFounder PiDog Kit, Release 1.0 4. Now you can see the desktop of the Raspberry Pi. 2.1. Quick Guide on Python...
  • Page 36 SunFounder PiDog Kit, Release 1.0 Linux /Unix Users 1. Go to Applications->Utilities, find the Terminal, and open it. 2. Check if your Raspberry Pi is on the same network by type in ping <hostname>.local. ping raspberrypi.local • If terminal prompts ping: cannot resolve <hostname>.local, it is possible that...
  • Page 37 SunFounder PiDog Kit, Release 1.0 ssh pi@raspberrypi.local 4. The following message may appear. The authenticity of host 'raspberrypi.local (192.168.6.116)' can't be established. ECDSA key fingerprint is SHA256:7ggckKZ2EEgS76a557cddfxFNDOBBuzcJsgaqA/ igz4. Are you sure you want to continue connecting (yes/no/[fingerprint])? Input “yes”. 5. Input the password you set before. (Mine is raspberry.) 6.
  • Page 38 Then download the code and install vilib module. /home/pi/ git clone https://github.com/sunfounder/vilib.git cd vilib sudo python3 install.py Then download the code and install pidog module. /home/pi/ git clone https://github.com/sunfounder/pidog.git cd pidog sudo python3 setup.py install This step will take a little time, so please be patient.
  • Page 39 SunFounder PiDog Kit, Release 1.0 Type y and press Enter to continue running the script. Type y and press Enter to run /dev/zero in the background. 2.1. Quick Guide on Python...
  • Page 40 SunFounder PiDog Kit, Release 1.0 Type y and press Enter to restart the machine. Note: If there is no sound after restarting, you may need to run the i2samp.sh script multiple times. 2.1.5 Enable I2C, SPI and Camera Interface Here we are using the Raspberry Pi’s I2C and Camera interfaces, but by default they are disabled, so we need to enable them first.
  • Page 41 SunFounder PiDog Kit, Release 1.0 3. Then P5 I2C. 4. Use the arrow keys on the keyboard to select <Yes> -> <OK> to complete the setup of the I2C. 2.1. Quick Guide on Python...
  • Page 42 SunFounder PiDog Kit, Release 1.0 5. Go to 3 Interfacing Options again and select P4 SPI. 6. Use the arrow keys on the keyboard to select <Yes> -> <OK> to complete the setup of the SPI. Chapter 2. Play with Python...
  • Page 43 SunFounder PiDog Kit, Release 1.0 7. Go to 3 Interfacing Options again and select P1 Camera. 8. Again select <Yes> -> <OK> to complete the setup. 2.1. Quick Guide on Python...
  • Page 44 SunFounder PiDog Kit, Release 1.0 9. After you select <Finish>, a pop-up will remind you that you need to reboot for the settings to take effect, select <Yes>. Chapter 2. Play with Python...
  • Page 45 SunFounder PiDog Kit, Release 1.0 2.1.6 Servo Adjust To ensure that the servo has been properly set to 0°, first insert the rocker arm into the servo shaft and then gently rotate the rocker arm to a different angle. Follow the instructions on the assembly foldout, insert the battery holder cable and turn the power switch to the ON.
  • Page 46 SunFounder PiDog Kit, Release 1.0 Now, run servo_zeroing.py in the examples/ folder. cd /home/pi/pidog/examples sudo python3 servo_zeroing.py Note: If you get an error, try re-enabling the Raspberry Pi’s I2C port, see: i2c_config. Next, plug the servo cable into the any PWM port.
  • Page 47 SunFounder PiDog Kit, Release 1.0 At this point you will see the servo arm rotate to a specific position (0°). If the servo arm does not return to 0°, press the RST button to restart the Robot HAT. Now you can continue the installation as instructed on the assembly foldout.
  • Page 48: Funny Project

    2.2 Funny Project 2.2.1 Calibrate the PiDog Due to possible deviations during PiDog installation or limitations of the servos themselves, some servo angles may be slightly tilted, so you can calibrate them. Of course you can skip this chapter if you think the assembly is perfect and doesn’t require calibration.
  • Page 49 SunFounder PiDog Kit, Release 1.0 3. Place the square (Acrylic C) to the position shown in the picture. Press 1 in the terminal, then press w, s to make the two edges marked in the figure coincide. 2.2. Funny Project...
  • Page 50 SunFounder PiDog Kit, Release 1.0 4. Place the square (Acrylic C) to the position shown in the picture. Press 2 in the terminal, then press w, s to make the two edges marked in the figure coincide. Chapter 2. Play with Python...
  • Page 51 Stretch, twist, sit, wag its tail, pant. Code Note: You can Modify/Reset/Copy/Run/Stop the code below. But before that, you need to go to source code path like pidog\examples. After modifying the code, you can run it directly to see the effect. 2.2. Funny Project...
  • Page 52 2.2.3 Function Demonstration This project shows you all of PiDog’s usual actions and sounds. You can make PiDog make actions or make sounds by entering the serial number. The motion/sound effects currently included in this example are listed below. Chapter 2. Play with Python...
  • Page 53 Run the Code cd /home/pi/pidog/examples sudo python3 2_function_demonstration.py After running this example, you input 1 and press ENTER, PiDog will stand; input 2, PiDog will sit down; input 27, PiDog will issue “woohoo~ “. Press Ctrl+C to exit the program.
  • Page 54 SunFounder PiDog Kit, Release 1.0 (continued from previous page) ['shake_head', 0, 90], ['tilting_head', 0, 60], ['wag_tail', 0, 100], sound_effects name os.listdir('../sounds'): sound_effects.append(name.split('.')[0]) sound_effects.sort() index None last_index exit_flag False STANDUP_ACTIONS ['trot', 'forward', 'backward', 'turn_left', 'turn_right'] show_info(): print("\033[H\033[J", end='') # clear terminal windows print( "\033[104m\033[1m...
  • Page 55 "__main__": function_demonstration() 2.2.4 Patrol In this project, PiDog makes a vivid behavior: patrolling. PiDog will walk forward, if there is an obstacle in front of it, it will stop and bark. Run the Code cd /home/pi/pidog/examples sudo python3 3_patrol.py After running this example, PiDog will wag its tail, scan left and right, and walk forward.
  • Page 56 In this project, PiDog will interact with you in an interesting way. If you reach out and grab PiDog’s head from the front, it will bark vigilantly. But if you reach out from behind it and pet its head, it will enjoy it very much.
  • Page 57 At the same time, the touch sensor will also work. If the touch sensor is stroked (not just touched), PiDog will shake its head, wag its tail, and show a comfortable look.
  • Page 58 KeyboardInterrupt: my_dog.close() 2.2.6 Rest PiDog will doze off on the ground, and when it hears sounds around it, it will stand up in confusion to see who woke it up. Run the Code cd /home/pi/pidog/examples sudo python3 5_rest.py After the program runs, PiDog will get down on the ground, shake its head and tail as if dozing off.
  • Page 59 SunFounder PiDog Kit, Release 1.0 (continued from previous page) my_dog Pidog() sleep(0.1) loop_arround(amplitude=60, interval=0.5, speed=100): my_dog.head_move([[amplitude,0,0]], immediately=True, speed=speed) my_dog.wait_all_done() sleep(interval) my_dog.head_move([[-amplitude,0,0]], immediately=True, speed=speed) my_dog.wait_all_done() sleep(interval) my_dog.head_move([[0,0,0]], immediately=True, speed=speed) my_dog.wait_all_done() is_sound(): my_dog.ears.isdetected(): direction my_dog.ears.read() direction return True else: return False rest(): my_dog.do_action('lie', wait=True, speed=50)
  • Page 60 KeyboardInterrupt: my_dog.close() 2.2.7 Be Picked Up Try lifting your PiDog from the ground, PiDog will feel like it can fly, and it will cheer in a superman pose. Run the Code cd /home/pi/pidog/examples sudo python3 6_be_picked_up.py After the program runs, the 6-DOF IMU Module will always calculate the acceleration in the vertical direction. If PiDog is calculated to be in a state of weightlessness, PiDog assumes a superman pose and cheers.
  • Page 61 SunFounder PiDog Kit, Release 1.0 (continued from previous page) my_dog.do_action('wag_tail', step_count=20, speed=100) my_dog.speak('woohoo') delay(1) stand(): my_dog.rgb_strip.set_mode('breath', front_color='green', delay=0.02) my_dog.do_action('stand', wait=True, speed=60) be_picked_up(): isUp False upflag False downflag False my_dog.rgb_strip.set_mode('breath', front_color='green', delay=0.02) stand() while True: my_dog.accData[0] print('ax: %s, is up: %s'...
  • Page 62 SunFounder PiDog Kit, Release 1.0 2.2.8 Face Track PiDog will sit quietly in place. You applaud it, it looks your way, and if it sees you, it says hello. Run the Code cd /home/pi/pidog/examples sudo python3 7_face_track.py After running this code, PiDog will start the camera and enable the face detection function. You can visit http:// + PiDog's IP +/mjpg (like mine is http://192.168.18.138:9000/mjpg) in your browser to view the...
  • Page 63 SunFounder PiDog Kit, Release 1.0 (continued from previous page) bark from preset_actions import my_dog Pidog() sleep(0.1) delay(time): my_dog.wait_legs_done() my_dog.wait_head_done() sleep(time) face_track(): Vilib.camera_start(vflip=False, hflip=False) Vilib.display(local=True, web=True) Vilib.human_detect_switch(True) sleep(0.2) print('start') roll pitch flag False direction my_dog.do_action('sit', speed=50) my_dog.head_move([[yaw, 0, pitch]], pitch_comp=- 40, immediately=True, speed=80) delay(0.5)
  • Page 64 Run the Code cd /home/pi/pidog/examples sudo python3 8_pushup.py After the program runs, PiDog will perform a plank, then cycle through push-ups and barks. Code Note: You can Modify/Reset/Copy/Run/Stop the code below. But before that, you need to go to source code path...
  • Page 65 KeyboardInterrupt: my_dog.close() 2.2.10 Howling PiDog is not only a cute puppy, but also a mighty dog. Come hear it howl! Run the Code cd /home/pi/pidog/examples sudo python3 9_howling.py After the program runs, PiDog will sit on the ground and howl.
  • Page 66 Because PiDog is equipped with a 6-DOF IMU module, it has a great sense of balance. In this example, you can make PiDog walk smoothly on the table, even if you lift one side of the table, PiDog will walk smoothly on the gentle slope.
  • Page 67 SunFounder PiDog Kit, Release 1.0 (continued from previous page) Pidog from pidog import from pidog.walk import Walk import readchar import threading import my_dog Pidog() sleep(0.5) usage Pidog Balance Ctrl + C to Exit stand_coords [[[0, 80], [0, 80], [0, 80], [0, 80]]] forward_coords Walk(fb=Walk.FORWARD, lr=Walk.STRAIGHT).get_coords()
  • Page 68 KeyboardInterrupt: pass finally: t.join() my_dog.close() 2.2.12 Play PiDog with Keyboard In this example, we will use the keyboard to control PiDog. You can press these keys in the terminal to make it act. Keys Function Keys Function forward backward...
  • Page 69 SunFounder PiDog Kit, Release 1.0 #!/usr/bin/env python3 sleep from time import from pidog import Pidog import readchar from preset_actions import import my_dog Pidog() sleep(0.5) usage Keyboard Control Ctrl + C to Exit SIT_HEAD_PITCH STAND_HEAD_PITCH STATUS_STAND STATUS_SIT STATUS_LIE HEAD_SPEED HEAD_ANGLE head_yrp...
  • Page 70 SunFounder PiDog Kit, Release 1.0 (continued from previous page) "status": STATUS_STAND, "head_pitch": STAND_HEAD_PITCH, "turn right": { "commands": ["turn right"], "function": lambda: my_dog.do_action('turn_right', wait=False, speed=98), "status": STATUS_STAND, "head_pitch": STAND_HEAD_PITCH, "trot": { "commands": ["trot"], "function": lambda: my_dog.do_action('trot', wait=False, speed=98), "status": STATUS_STAND, "head_pitch": STAND_HEAD_PITCH, "stop": {...
  • Page 71 SunFounder PiDog Kit, Release 1.0 (continued from previous page) "function": lambda: shake_head(my_dog, head_yrp), "stretch": { "commands": ["stretch"], "function": lambda: my_dog.do_action('stretch', wait=True, speed=80), "after": "stand up", "status": STATUS_STAND, "doze off": { "commands": ["doze off", "does off"], "function": lambda: my_dog.do_action('doze_off', wait=True, speed=95), "after":...
  • Page 72 SunFounder PiDog Kit, Release 1.0 (continued from previous page) set_head_pitch_init(pitch): global head_pitch_init head_pitch_init pitch my_dog.head_move([head_yrp], pitch_comp=pitch, immediately=True, speed=HEAD_SPEED) change_status(status): global current_status current_status status status STATUS_STAND: set_head_pitch_init(STAND_HEAD_PITCH) my_dog.do_action('stand', wait=False, speed=70) elif status STATUS_SIT: set_head_pitch_init(SIT_HEAD_PITCH) my_dog.do_action('sit', wait=False, speed=70) elif status STATUS_LIE: set_head_pitch_init(STAND_HEAD_PITCH) my_dog.do_action('lie', wait=False, speed=70)
  • Page 73 SunFounder PiDog Kit, Release 1.0 (continued from previous page) "Q": "bark harder", "e": "pant", "r": "wag tail", "t": "shake head", "v": "stretch", "1": "doze off", "2": "push-up", "3": "howling", "4": "twist body", "5": "scratch", "t": "handshake", "g": "high five", main():...
  • Page 74 In this example, we will use SunFounder Controller APP to control PiDog. You need to download the APP on your phone/tablet first, then connect to the hotspot sent by PiDog, and finally create your own remote control on SunFounder Controller to control PiDog.
  • Page 75 SunFounder PiDog Kit, Release 1.0 • There are preset controllers for some products in the Preset section. Here we choose PiDog. • Give it a name, then click Confirm. 2.2. Funny Project...
  • Page 76 • Now you have entered the inside of the remote control, which has several components for setting. Click the save button in the upper right corner. • Next you need to connect PiDog with your device by pressing the connect button. • Wait a few seconds, MyDog(IP) will appear, click it to connect.
  • Page 77 4. Run the Controller. • When the “Connected Successfully” prompt appears, tap the button in the upper right corner. • The picture taken by the camera will appear on the APP, and now you can control your PiDog with these widgets.
  • Page 78 – high five Then you may want to master its basic functions, or write some fun examples. If you are familiar with Python programming, you can find examples of PiDog’s basic functions in the /home/pi/ pidog/basic_examples directory. If you prefer, you can master them in a step-by-step fashion using the lessons provided below.
  • Page 79: Easy Coding

    • tail_init_angle : In this array, there is only one value, which is dedicated to controlling the tail servo, which is 9. 3. Pidog allows you to redefine the serial number of the servos when instantiating the robot if your servo order is different.
  • Page 80 [0, 0, -25], tail_init_angle= 2.3.2 Leg Move PiDog’s leg movements are implemented by the following functions. Pidog.legs_move(target_angles, immediately=True, speed=50) • target_angles: It is a two-dimensional array composed of an array of 8 servo angles (referred to as angle group) as elements. These angle groups will be used to control the angles of the 8 foot servos. If multiple angle groups are written, the unexecuted angle groups will be stored in the cache.
  • Page 81 # stop and half stand my_dog.legs_move([[45, 10, -45, -10, 45, 10, -45, -10]], immediately=True, speed=50) PiDog’s leg control also has the following functions that can be used together: Pidog.is_legs_done() This function is used to determine whether the angle group in the cache has been executed. If yes, return True;...
  • Page 82 Pidog() range(99): my_dog.head_move([[30, 0, 0],[-30, 0, 0]], immediately=False, speed=30) # keep 10s time.sleep(10) my_dog.head_move([[0, 0, 0]], immediately=True, speed=80) 3. Whether sitting or half standing, PiDog keeps its head level when shaking its head. from pidog import Pidog import time...
  • Page 83 2.3.4 Tail Move Following are the functions that control PiDog’s tail. This function is similar to Move. Pidog.tail_move(target_angles, immediately=True, speed=50) • target_angles : It is a two-dimensional array composed of an array of 1 servo angles (referred to as angle group) as elements.
  • Page 84 2.3.5 Stop All Actions After the previous chapters, you can find that the servo control of PiDog is divided into three threads. This allows PiDog’s head and body to move at the same time, even with two lines of code.
  • Page 85 # close all the servo threads 2.3.6 Do Preset Action Some commonly used actions have been pre-written in PiDog’s library. You can call the following function to make PiDog do these actions directly. Pidog.do_action(action_name, step_count=1, speed=50) • action_name : Action name, the following strings can be written.
  • Page 86 2.3.7 PiDog Speak PiDog can make sound, it is actually playing a piece of audio. These audios are saved under pidog\sounds path, you can call the following function to play them. Pidog.speak(name) • name : Filename (without suffix), such as "angry". PiDog provides the following audio.
  • Page 87 2.3.8 Read Distance Through the Ultrasonic Module in its head, PiDog can detect obstacles ahead. An ultrasonic module can detect objects between 2 and 400 cm away. With the following function, you can read the distance as a floating point number.
  • Page 88 SunFounder PiDog Kit, Release 1.0 2.3.9 PiDog RGB Strip There is an RGB Strip on PiDog’s chest, which PiDog can use to express emotions. You can call the following function to control it. Pidog.rgb_strip.set_mode(style='breath', color='white', brightness=1, delay=0.01) • style : The lighting display mode of RGB Strip, the following are its available values.
  • Page 89 2.3.10 IMU Read Through the 6-DOF IMU Module, PiDog can determine if it’s standing on a slope, or if it’s being picked up. The 6-DOF IMU Module is equipped with a 3-axis accelerometer and a 3-axis gyroscope, allowing acceleration and angular velocity to be measured in three directions.
  • Page 90 2.3.11 Sound Direction Detect The PiDog has a Sound Direction Sensor Module that detects where sound is coming from, and we can trigger it by clapping near it. Using this module is as simple as calling these functions.
  • Page 91 {direction}") 2.3.12 Pat the PiDog’s Head The Touch Swich on the head of PiDog can detect how you touch it. You can call the following functions to use it. Pidog.dual_touch.read() • Touch the module from left to right (front to back for PiDog’s orientation), it will return "LS".
  • Page 92 SunFounder PiDog Kit, Release 1.0 Chapter 2. Play with Python...
  • Page 93: Hardware

    CHAPTER THREE HARDWARE When you are writing code, you may need to know how each module works or the role of each pin, then please see this chapter. In this chapter you will find a description of each module’s function, technical parameters and working principle. 3.1 Robot HAT Robot HAT is a multifunctional expansion board that allows Raspberry Pi to be quickly turned into a robot.
  • Page 94 SunFounder PiDog Kit, Release 1.0 Left/Right Motor Port • 2-channel XH2.54 motor ports. • The left port is connected to GPIO 4 and the right port is connected to GPIO 5. I2C Pin/Port • I2C pins from Raspberry Pi. SPI Pin •...
  • Page 95: Camera Module

    SunFounder PiDog Kit, Release 1.0 • Two LEDs light up when the voltage is higher than 7.8V. • One LED lights up in the 6.7V to 7.8V range. • Below 6.7V, both LEDs turn off. Power Indicator • If Robot HAT is working, it lights up.
  • Page 96 SunFounder PiDog Kit, Release 1.0 This is a 5MP Raspberry Pi camera module with OV5647 sensor. It’s plug and play, connect the included ribbon cable to the CSI (Camera Serial Interface) port on your Raspberry Pi and you’re ready to go.
  • Page 97 SunFounder PiDog Kit, Release 1.0 Warning: Do not install the camera with the power on, it may damage your camera. Enable the Camera Interface Run the following command to enable the camera interface of your Raspberry Pi. If you have enabled it, skip this; if you do not know whether you have done that or not, please continue.
  • Page 98 SunFounder PiDog Kit, Release 1.0 <Yes>, then <Ok> -> <Finish> After the configuration is complete, it is recommended to reboot the Raspberry Pi. Chapter 3. Hardware...
  • Page 99: Sound Direction Sensor

    SunFounder PiDog Kit, Release 1.0 sudo reboot 3.3 Sound Direction Sensor This is a sound direction recognition module. It is equipped with 3 microphones, which can detect sound sources from all directions, and is equipped with a TR16F064B, which is used to process sound signals and calculate the sound source direction.
  • Page 100: 6-Dof Imu

    SunFounder PiDog Kit, Release 1.0 • SCLK - SPI clock • CS - SPI Chip Select • BUSY - busy detection 3.4 6-DOF IMU The 6-DOF IMU is based on the SH3001. SH3001 is a six-axis IMU (Inertial measurement unit). It integrates a three-axis gyroscope and a three-axis accelerom- eter.
  • Page 101: Dual Touch Sensor

    SunFounder PiDog Kit, Release 1.0 3.5 Dual Touch Sensor Dual channel touch sensor, based on two ttp223 touch sensors. When a touch signal is detected, the corresponding pin level will be pulled low. TTP223 is a touch pad detector IC that provides 1 touch key. The touch detection IC is specially designed to replace the traditional direct keys with different pad sizes.
  • Page 102: Ultrasonic Module

    SunFounder PiDog Kit, Release 1.0 • Power supply: 3.3V • Communication: IIC • Connector: SH1.0 4P • LEDs: 3535 RGB LEDs Pin Out • GND - Ground Input • VCC - Power Supply Input • SDA - IIC SDA • SCL - IIC SCL 3.7 Ultrasonic Module...
  • Page 103 SunFounder PiDog Kit, Release 1.0 • Max Range: 500cm • Min Range: 2cm • Trigger Input Signal: 10uS TTL pulse • Echo Output Signal: Input TTL lever signal and the range in proportion • Connector: XH2.54-4P • Dimension: 46x20.5x15 mm...
  • Page 104: 18650 Battery

    • GND: Negative battery terminal. This is a custom battery pack made by SunFounder consisting of two 18650 batteries with a capacity of 2200mAh. The connector is XH2.54-4P, which can be charged directly after being inserted into the Robot HAT.
  • Page 105: Appendix

    CHAPTER FOUR APPENDIX 4.1 Filezilla Software The File Transfer Protocol (FTP) is a standard communication protocol used for the transfer of computer files from a server to a client on a computer network. Filezilla is an open source software that not only supports FTP, but also FTP over TLS (FTPS) and SFTP. We can use Filezilla to upload local files (such as pictures and audio, etc.) to the Raspberry Pi, or download files from the Raspberry Pi to the local.
  • Page 106 SunFounder PiDog Kit, Release 1.0 Note: Quick Connect is a good way to test your login information. If you want to create a permanent entry, you can select File-> Copy Current Connection to Site Manager after a successful Quick Connect, enter the name and click OK.
  • Page 107: Get The Ip Address

    SunFounder PiDog Kit, Release 1.0 4.2 Get the IP address There are many ways to know the IP address, and two of them are listed as follows. Checking via the router If you have permission to log in the router(such as a home network), you can check the addresses assigned to Raspberry Pi on the admin interface of router.
  • Page 108 SunFounder PiDog Kit, Release 1.0 Chapter 4. Appendix...
  • Page 109: Copyright Notice

    FIVE COPYRIGHT NOTICE All contents including but not limited to texts, images, and code in this manual are owned by the SunFounder Company. You should only use it for personal study,investigation, enjoyment, or other non-commercial or nonprofit purposes, under therelated regulations and copyrights laws, without infringing the legal rights of the author and relevant right holders.

Table of Contents

Save PDF