background image

SunFounder PiDog Kit, Release 1.0

<Yes>, then <Ok> -> <Finish>

After the configuration is complete, it is recommended to reboot the Raspberry Pi.

94

Chapter 3. Hardware

Summary of Contents for PiDog

Page 1: ...SunFounder PiDog Kit Release 1 0 sunfounder Jan 09 2023 ...

Page 2: ......

Page 3: ...ct 44 2 3 Easy Coding 75 3 Hardware 89 3 1 Robot HAT 89 3 2 Camera Module 91 3 3 Sound Direction Sensor 95 3 4 6 DOF IMU 96 3 5 Dual Touch Sensor 97 3 6 11 channel Light Board 97 3 7 Ultrasonic Module 98 3 8 18650 Battery 100 4 Appendix 101 4 1 Filezilla Software 101 4 2 Get the IP address 103 5 Copyright Notice 105 i ...

Page 4: ...ii ...

Page 5: ...nd pose in various poses The ultrasonic module on the head enables it to quickly detect obstacles ahead Special touch sensors allow it to respond to your touch The Light Board on the chest can emit colorful light effects and with the speaker equipped with the robot HAT PiDog can express emotions such as happiness and excitement In addition PiDog is also equipped with a sound direction sensor and a...

Page 6: ...SunFounder PiDog Kit Release 1 0 Content 2 CONTENTS ...

Page 7: ...aged 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 Component List and Assembly Instructions 3 ...

Page 8: ...SunFounder PiDog Kit Release 1 0 4 Chapter 1 Component List and Assembly Instructions ...

Page 9: ...Pi remote access to Raspberry Pi to run the corresponding code If you are familiar with Raspberry Pi and can open the command line successfully then you can skip the first 3 parts and then complete the last part 2 1 1 What Do We Need Required Components Raspberry Pi The Raspberry Pi is a low cost credit card sized computer that plugs into a computer monitor or TV and uses a standard keyboard and m...

Page 10: ...n To view the desktop environment of Raspberry Pi you need to use the screen that can be a TV screen or a computer monitor If the screen has built in speakers the Pi plays sounds via them Mouse Keyboard When you use a screen a USB keyboard and a USB mouse are also needed HDMI The Raspberry Pi has a HDMI output port that is compatible with the HDMI ports of most modern TV and computer monitors If y...

Page 11: ...st users as it will download the image and install it automatically to the SD card Visit the download page https www raspberrypi org software Click on the link for the Raspberry Pi Imager that matches your operating system when the download finishes click it to launch the installer Step 2 When you launch the installer your operating system may try to block you from running it For example on Window...

Page 12: ... the Raspberry Pi Imager click CHOOSE OS Raspberry Pi OS other Scroll down to the end of the newly opened page and you will see Raspberry Pi OS Legacy and Raspberry Pi OS Lite Legacy these are security updates for Debian Buster the difference between them is with or without the desktop It is recommended to install Raspberry Pi OS Legacy the system with the desktop 8 Chapter 2 Play with Python ...

Page 13: ...s 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 Note When the Set hostname box is not checked the default hostname will still be raspberrypi and we will use this hostname to access the Raspberry Pi remotely 2 1 Quick Guide on Python 9 ...

Page 14: ... 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_ assigned_code_elements 10 Chapter 2 Play with Python ...

Page 15: ...SunFounder PiDog Kit Release 1 0 Step 7 Click the WRITE button 2 1 Quick Guide on Python 11 ...

Page 16: ...lease 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 12 Chapter 2 Play with Python ...

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 13 ...

Page 18: ...D card you ve set up with Raspberry Pi OS into the micro SD card slot on the underside of your Raspberry Pi 2 Plug in the Mouse and Keyboard 3 Connect the screen to Raspberry Pi s HDMI port and make sure your screen is plugged into a wall socket and switched on Note If you use a Raspberry Pi 4 you need to connect the screen to the HDMI0 nearest the power in port 4 Use the power adapter to power th...

Page 19: ...sktop directly via VNC is more convenient than from the command line You can access it via Finder by entering the set account password after enabling VNC on the Raspberry Pi side Note that this method does not encrypt communication between the Mac and Raspberry Pi The communication will take place within your home or business network so even if it s unprotected it won t be an issue However if you ...

Page 20: ...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 16 Chapter 2 Play with Python ...

Page 21: ...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 2 1 Quick Guide on Python 17 ...

Page 22: ...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 18 Chapter 2 Play with Python ...

Page 23: ... 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 2 Type in vnc username hostname local or vnc username IP address Af ter entering click Connect 2 1 Quick Guide on Python 19 ...

Page 24: ...iDog 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 20 Chapter 2 Play with Python ...

Page 25: ...or Linux The shell is a command line interpreter CLI when the user uses Unix Linux Most of what you need to do can be done through the shell After setting up the Raspberry pi side you can access the desktop of the Raspberry Pi using the Finder from the Mac 1 Type ssh username hostname local to connect to the Raspberry Pi ssh pi raspberrypi local 2 1 Quick Guide on Python 21 ...

Page 26: ...Aug 26 11 16 44 BST 2022 aarch64 The programs included with the Debian GNU Linux system are free software the exact distribution terms for each program are described in the individual files in usr share doc copyright Debian GNU Linux comes with ABSOLUTELY NO WARRANTY to the extent permitted by applicable law Last login Thu Sep 22 12 18 22 2022 pi raspberrypi 4 Set up your Raspberry Pi so that you ...

Page 27: ...e 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 2 1 Quick Guide on Python 23 ...

Page 28: ...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 Y Enter to save and exit 10 In addition set a password for logging in via VNC from a Mac You can use the same password as the Raspberry 24 Chapter 2 Play with Python ...

Page 29: ...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 13 Type in vnc username hostname local or vnc username IP address Af ter entering click Connect 2 1 Quick Guide on Python 25 ...

Page 30: ...Dog 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 26 Chapter 2 Play with Python ...

Page 31: ...terminal prompts Ping request could not find host hostname local it is possible that the Raspberry Pi failed to connect to the network lease check the network If you really can t ping hostname local try to Get the IP address and ping IP address instead e g ping 192 168 6 116 If multiple prompts like Reply from IP address bytes 32 time 1ms TTL 64 appear it means your computer can access the Raspber...

Page 32: ...window accordingly which is normal What you need is to input the correct password 6 We now get the Raspberry Pi connected and are ready to go to the next step Remote Desktop If you re not satisfied with using the command window to access your Raspberry Pi you can also use the remote desktop feature to easily manage files on your Raspberry Pi using a GUI Here we use VNC Viewer Enable VNC service Th...

Page 33: ...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 2 1 Quick Guide on Python 29 ...

Page 34: ...eed 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 3 After entering your Raspberry Pi name and password click OK 30 Chapter 2 Play with Python ...

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 31 ...

Page 36: ...ostname local it is possible that the Raspberry Pi failed to connect to the network Please check the network If you really can t ping hostname local try to Get the IP address and ping IP address instead e g ping 192 168 6 116 If multiple prompts like 64 bytes from IP address icmp_seq 0 ttl 64 time 0 464 ms appear it means your computer can access the Raspberry Pi 3 Type in ssh username hostname lo...

Page 37: ...efore Mine is raspberry 6 We now get the Raspberry Pi connected and are ready to go to the nextstep 2 1 4 Install All the Modules Make sure you are connected to the Internet and update your system sudo apt update sudo apt upgrade Note Python3 related packages must be installed if you are installing the Lite version OS sudo apt install git python3 pip python3 setuptools python3 smbus Install robot ...

Page 38: ...pi git clone https github com sunfounder vilib git cd vilib sudo python3 install py Then download the code and install pidog module cd 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 Finally you need to run the script i2samp sh to install the components required by the i2s amplifier otherwise the ...

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 35 ...

Page 40: ... 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 1 Input the following command sudo raspi config 2 Choose 3 Interfacing Options by press the down arrow key on your keyboard then press the Enter key 36 Chapter 2 Play with Python ...

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 37 ...

Page 42: ...unFounder 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 38 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 39 ...

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 40 Chapter 2 Play with Python ...

Page 45: ...er 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 Wait for 1 2 minutes there will be a sound to indicate that the Raspberry Pi boots successfully 2 1 Quick Guide on Python 41 ...

Page 46: ...eroing 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 42 Chapter 2 Play with Python ...

Page 47: ... Do not unplug this servo cable before fixing it with the servo screw you can unplug it after fixing it Do not rotate the servo while it is powered on to avoid damage if the servo shaft is not inserted at the right angle pull the servo out and reinsert it Before assembling each servo you need to plug the servo cable into PWM pin and turn on the power to set its angle to 0 After the assembly is com...

Page 48: ... 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 The specific steps are as follows 1 Put the PiDog on the base 2 Run the 0_calibration py cd home pi pidog examples sudo python3 0_calibration py After running the above code you will see the following interface displayed in the terminal 44 Chapter 2 Play with P...

Page 49: ...ounder 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 45 ...

Page 50: ...r 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 46 Chapter 2 Play with Python ...

Page 51: ...p Run the Code cd home pi pidog examples sudo python3 1_wakeup py After the code is executed PiDog will perform the following actions in sequence 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 47...

Page 52: ... immediately True speed 90 my_dog do_action sit wait False speed 50 my_dog wait_legs_done my_dog do_action wag_tail step_count 10 wait False speed 100 my_dog rgb_strip set_mode breath front_color 245 10 10 brightness 0 8 delay 0 002 pant my_dog pitch_comp 30 my_dog wait_all_done my_dog rgb_strip close if __name__ __main__ try wake_up except KeyboardInterrupt pass finally my_dog close 2 2 3 Functio...

Page 53: ...ou 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 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 usr bin env python3 from time import sleep from pidog import Pid...

Page 54: ...ine for i sound_effect in enumerate sound_effects print f 033 i first_line 32H i len actions 1 sound_effect last_line max i first_line last_line 1 print f 033 100m 033 1m 033 last_line 2 0H Ctrl C Quit 033 0m if index None print Current selection end if index len actions print f index 1 actions index 0 else print f index 1 sound_effects index len actions def do_function index global last_index my_...

Page 55: ...ge continue index int num 1 do_function index show_info except ValueError print ValueError except KeyboardInterrupt my_dog close sleep 0 05 if __name__ __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 p...

Page 56: ...nce value 2 cm if my_dog distance value 15 print f distance round my_dog distance value 2 cm DANGER 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 1 bark my_dog head_yaw 0 0 my_dog rgb_strip set_mode breath white delay 0 1 if __name__ __main__ try while Tru...

Page 57: ...port sleep from math import sin from preset_actions import bark_action my_dog Pidog sleep 0 1 def lean_forward my_dog speak angry bark_action my_dog sleep 0 2 bark_action my_dog sleep 0 4 bark_action my_dog def head_nod step y 0 r 0 p 30 angs for i in range 20 r round 10 sin i 0 314 2 p round 20 sin i 0 314 10 2 angs append y r p my_dog head_move angs step immediately False speed 80 def alert my_d...

Page 58: ...xcept 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 At the same time its sound direction sensor module is working If PiDog ...

Page 59: ...d while True Sleeping my_dog rgb_strip set_mode breath pink delay 0 14 my_dog head_move 0 0 40 immediately True speed 5 my_dog do_action wag_tail step_count 20 speed 20 my_dog do_action doze_off wait False speed 95 If heard anything wake up if is_sound Set light to yellow and stand up my_dog rgb_strip set_mode boom yellow delay 0 01 my_dog body_stop my_dog do_action stand wait False speed 90 my_do...

Page 60: ... 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 Otherwise consider PiDog to be on flat ground and make a standing pose 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 ...

Page 61: ...pflag False downflag False my_dog rgb_strip set_mode breath front_color green delay 0 02 stand while True ax my_dog accData 0 print ax s is up s ax isUp gravity 1G 16384 if ax 16000 my_dog body_stop if upflag False upflag True if downflag True isUp False downflag False stand if ax 13000 my_dog body_stop if upflag True isUp True upflag False fly if downflag False downflag True sleep 0 2 if __name__...

Page 62: ...PiDog will sit down and activate the Sound Direction Sensor Module to detect the direction of your clapping When PiDog hears clapping or other noise it turns its head toward the sound source trying to find you If it sees you face detection finds an object it will wag its tail and let out a bark Code Note You can Modify Reset Copy Run Stop the code below But before that you need to go to source cod...

Page 63: ...speed 80 delay 0 5 if my_dog ears isdetected direction my_dog ears read while True if flag False my_dog rgb_strip set_mode breath pink delay 0 1 If heard somthing turn to face it if my_dog ears isdetected flag False direction my_dog ears read pitch 0 if direction 0 and direction 100 yaw direction if yaw 80 yaw 80 elif direction 260 and direction 360 yaw 360 direction if yaw 80 yaw 80 my_dog head_m...

Page 64: ...direction people ex ey round yaw 2 round roll 2 round pitch 2 end r flush True my_dog head_move yaw 0 pitch pitch_comp 40 immediately True speed 100 sleep 0 05 if __name__ __main__ try face_track except KeyboardInterrupt Vilib camera_close my_dog close 2 2 9 Push Up PiDog is an exercise loving robot that will do push ups with you Run the Code cd home pi pidog examples sudo python3 8_pushup py Afte...

Page 65: ...0 sleep 0 1 bark my_dog 0 0 20 sleep 1 while True pushup my_dog bark my_dog 0 0 40 sleep 0 4 if __name__ __main__ try main except 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 Code Note You can Modify Re...

Page 66: ...ed 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 Run the Code cd home pi pidog examples sudo python3 10_balance py After the program is running you will see a printed keyboard on the terminal You can control PiDog to walk smoothly on the ramp b...

Page 67: ..._pose x 0 y 0 z 80 current_rpy roll 0 pitch 0 yaw 0 thread_start True def move_thread while thread_start for coord in current_coords print coord my_dog set_rpy current_rpy pid True my_dog set_pose current_pose my_dog set_legs coord angles my_dog pose2legs_angle my_dog legs servo_move angles speed 98 t threading Thread target move_thread def main global current_coords current_pose current_rpy threa...

Page 68: ...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 w forward s backward a turn left d turn right z lie down x stand up c sit q bark 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 Ru...

Page 69: ...itch None yaw None global head_yrp if roll is not None head_yrp 1 roll if pitch is not None head_yrp 2 pitch if yaw is not None head_yrp 0 yaw my_dog head_move head_yrp immediately True speed HEAD_SPEED COMMANDS forward commands forward function lambda my_dog do_action forward wait False speed 98 status STATUS_STAND head_pitch STAND_HEAD_PITCH backward commands backward function lambda my_dog do_a...

Page 70: ...it False speed 70 head_pitch STAND_HEAD_PITCH status STATUS_STAND sit commands sit sit down set set down function lambda my_dog do_action sit wait False speed 70 head_pitch SIT_HEAD_PITCH status STATUS_SIT bark commands bark park fuck function lambda bark my_dog head_yrp pitch_comp head_pitch_init bark harder commands bark harder park harder fuck harder bark harbor park harbor fuck harbor function...

Page 71: ...ush up status STATUS_STAND howling commands howling function lambda howling my_dog after sit status STATUS_SIT twist body commands twist body function lambda body_twisting my_dog before stretch after sit status STATUS_STAND scratch commands scratch function lambda scratch my_dog after sit head_pitch SIT_HEAD_PITCH status STATUS_SIT handshake commands handshake function lambda hand_shake my_dog aft...

Page 72: ... speed 70 my_dog wait_all_done def run_command global command head_pitch_init if not my_dog is_legs_done or not my_dog is_head_done return if command is None return for name in COMMANDS if command in COMMANDS name commands if status in COMMANDS name if current_status COMMANDS name status change_status COMMANDS name status if head_pitch in COMMANDS name head_pitch_init COMMANDS name head_pitch if b...

Page 73: ...SEQUENCES import sys print sys exit 0 break elif key in COMMAND_KEY_MAP command COMMAND_KEY_MAP key Head Pitch elif key in uiojklUIOJKLm if key i head_yrp 2 HEAD_ANGLE elif key I head_yrp 2 HEAD_ANGLE 2 elif key k head_yrp 2 HEAD_ANGLE elif key K head_yrp 2 HEAD_ANGLE 2 Head Yaw elif key j head_yrp 0 HEAD_ANGLE elif key J head_yrp 0 HEAD_ANGLE 2 elif key l head_yrp 0 HEAD_ANGLE elif key L head_yrp...

Page 74: ...y PiDog and finally create your own remote control on SunFounder Controller to control PiDog How to do 1 Install SunFounder Controller from APP Store iOS or Google Play Android 2 Run the Code cd home pi pidog examples sudo python3 12_app_control py After the code runs you will see the following prompt which means your PiDog has successfully started network communication Running on http 192 168 18 ...

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 71 ...

Page 76: ... 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 72 Chapter 2 Play with Python ...

Page 77: ...e 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 Here are the functions of the widgets A Detect the obstacle distance that is the reading of the ultrasonic module C Turn on off face detection D Control PiDog s head tilt angle tilt head 2 2 Funny Project 73 ...

Page 78: ...left turn right trot stop lie down stand up sit bark bark harder pant wag tail shake head stretch doze off push up howling twist body scratch handshake 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 ma...

Page 79: ... head_init_angles 0 0 25 tail_init_angle 0 In the Pidog class the servos are divided into three groups leg_init_angles In this array 8 values determine the angles of eight servos with the servos pin num bers they control being 2 3 7 8 0 1 10 11 From the foldout you can see where these servos are located head_init_angles There is an array with 3 values controllers for PiDog head yaw roll pitch serv...

Page 80: ...ately to execute the newly written angle group if the parameter is set to False the newly written The incoming angular group is added to the execution queue speed The speed at which the angular group is executed Some common usages are listed below 1 Take action immediately from pidog import Pidog import time my_dog Pidog half stand my_dog legs_move 45 10 45 10 45 10 45 10 speed 50 2 Add some angul...

Page 81: ...he control of PiDog s head servo is implemented by the following functions Pidog head_move target_yrps roll_comp 0 pitch_comp 0 immediately True speed 50 target_angles It is a two dimensional array composed of an array of 3 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 unexecut...

Page 82: ...time my_dog Pidog for _ in 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 my_dog Pidog action list shake_head 30 0 0 30 0 0 half_stand_leg 45 10 45 10 45 10 45 10 sit_leg 30 60 30 60 80 45...

Page 83: ...ache immediately When calling the function set this parameter to True the cache will be cleared immediately to execute the newly written angle group if the parameter is set to False the newly written The incoming angular group is added to the execution queue speed The speed at which the angular group is executed PiDog s tail servo control also has some supporting functions Pidog is_tail_done wheth...

Page 84: ...reset to lie pose and close all the threads usually used when exiting a program Here are some common usages from pidog import Pidog import time my_dog Pidog try pushup prepare my_dog legs_move 45 35 45 35 80 70 80 70 speed 30 my_dog head_move 0 0 0 pitch_comp 10 speed 80 my_dog wait_all_done wait all the actions to be done time sleep 0 5 pushup leg_pushup_action 90 30 90 30 80 70 80 70 45 35 45 35...

Page 85: ..._dog close 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 sit half_sit stand lie lie_with_hands_out forward backward turn_left turn_right tro...

Page 86: ...do_action wag_tail step_count 100 speed 90 my_dog do_action tilting_head step_count 5 speed 20 my_dog wait_head_done my_dog stop_and_lie except KeyboardInterrupt pass except Exception as e print f 033 31mERROR e 033 m finally print closing my_dog close 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 foll...

Page 87: ...KeyboardInterrupt pass except Exception as e print f 033 31mERROR e 033 m finally print closing my_dog close 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 Pidog ultrasonic read_distance Here is an example...

Page 88: ...he following color names white black white red yellow green blue cyan magenta pink brightness RGB Strip lights display brightness you can enter a floating point value from 0 to 1 such as 0 5 delay Float display animation speed the smaller the value the faster the change Use the following statement to disable RGB Striping Pidog rgb_strip close Here are examples of their use from pidog import Pidog ...

Page 89: ...sed You can read their acceleration with ax ay az Pidog accData With the PiDog placed horizontally the acceleration on the x axis ie ax should be close to the acceleration of gravity 1g with a value of 16384 The values of the y axis and x axis are close to 0 Use the following way to read their angular velocity gx gy gz my_dog gyroData In the case where PiDog is placed horizontally all three values...

Page 90: ...mp body_pitch speed 80 time sleep 0 2 my_dog close 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 Pidog ears isdetected Returns True if sound is detected False otherwise Pidog ears read This function returns the direction of the so...

Page 91: ...ouched it will return R If the module is not touched it will return N Here is an example of its use from pidog import Pidog import time my_dog Pidog while True touch_status my_dog dual_touch read print f touch_status touch_status time sleep 0 5 2 3 13 More The following address will explain the use of PiDog s more basic functions Vilib Library Vilib is a library developed by SunFounder for Raspber...

Page 92: ...SunFounder PiDog Kit Release 1 0 88 Chapter 2 Play with Python ...

Page 93: ...into a robot An MCU is on board to extend the PWM output and ADC input for the Raspberry Pi as well as a motor driver chip I2S audio module and mono speaker As well as the GPIOs that lead out of the Raspberry Pi itself It also comes with a Speaker which can be used to play background music sound effects and implement TTS functions to make your project more interesting Accepts 7 12V PH2 0 5pin powe...

Page 94: ...o GPIO 5 I2C Pin Port I2C pins from Raspberry Pi SPI Pin SPI pins from Raspberry Pi UART Pin UART pins from Raspberry Pi PWM Pin 12 channel PWM pins P0 P12 ADC Pin 4 channel ADC pins A0 A3 Digital Pin 4 channel digital pins D0 D3 Type C USB Port Energize this port to activate the battery Used to charge the battery Battery Indicator 90 Chapter 3 Hardware ...

Page 95: ...t off RST Button Short pressing RST Button causes program resetting Long press RST Button till the LED lights up then release and you will disconnect the Bluetooth USR Button The functions of USR Button can be set by your programming Pressing down leads to a input 0 releasing produces a input 1 Power Switch Turn on off the power of the robot HAT When you connect power to the power port the Raspber...

Page 96: ... capturing pictures and videos not sound Specification Static Images Resolution 2592 1944 Supported Video Resolution 1080p 30 fps 720p 60fps and 640 x480p 60 90 video recording Aperture F 1 8 Visual Angle 65 degree Dimension 24mmx23 5mmx8mm Weight 3g Interface CSI connector Supported OS Raspberry Pi OS latest version recommended Assemble the Camera Module On the camera module or Raspberry Pi you w...

Page 97: ...mage 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 sudo raspi config 3 Interfacing options P1 Camera 3 2 Camera Module 93 ...

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 94 Chapter 3 Hardware ...

Page 99: ...the BUSY pin and TR16F064B starts to monitor the direction When 064B recognizes the direction it will pull down the BUSY pin When the main control detects that BUSY is low it will send 16bit arbitrary data to 064B follow the MSB transmission and accept 16bit data which is the sound direction data processed by 064B After completion the main control will pull the BUSY pin high to detect the directio...

Page 100: ...cations and can provide high precision real time angular velocity and linear acceleration data The SH3001 has excellent temper ature stability and can maintain high resolution within the operating range of 40 C to 85 C It is typically used in smartphones tablet computers multi rotor drones smart sweepers page turning laser pointers AR VR smart remote controls smart bracelets and other products Spe...

Page 101: ...al signal Connector SH1 0 4P Pin Out GND Ground Input VCC Power Supply Input SIG1 Touch signal 1 low level means touch SIG2 Touch signal 2 low level means touch 3 6 11 channel Light Board This is an 11 channel RGB LED module which is equipped with 11 RGB LEDs controlled by the SLED1735 chip SLED1734 can drive up to 256 LEDs and 75 RGB LEDs In the LED matrix controlled by SLED1734 each LED has on o...

Page 102: ... 5V Supply This is the HC SR04 ultrasonic distance sensor providing non contact measurement from 2 cm to 400 cm with a range accuracy of up to 3 mm Included on the module is an ultrasonic transmitter a receiver and a control circuit You only need to connect 4 pins VCC power Trig trigger Echo receive and GND ground to make it easy to use for your measurement projects Features Working Voltage DC5V W...

Page 103: ...eceived Echo will output a high level if a signal is returned the duration of the high level is the time from emission to return Distance high level time x velocity of sound 340M S 2 Formula us 58 centimeters distance us 148 inch distance distance high level time x velocity 340M S 2 Application Notes This module should not be connected under power up if necessary let the module s GND be connected ...

Page 104: ...us protect the 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 Features Battery charge 5V 2A Battery output 5V 5A Battery capacity 3 7V 2000mAh x 2 Battery life 90min Battery charge time 130min Connector...

Page 105: ...les such as pictures and audio etc to the Raspberry Pi or download files from the Raspberry Pi to the local Step 1 Download Filezilla Download the client from Filezilla s official website Filezilla has a very good tutorial please refer to Documentation Filezilla Step 2 Connect to Raspberry Pi After a quick install open it up and now connect it to an FTP server It has 3 ways to connect here we use ...

Page 106: ... Connection to Site Manager after a successful Quick Connect enter the name and click OK Next time you will be able to connect by selecting the previously saved site inside File Site Manager Step 3 Upload download files You can upload local files to Raspberry Pi by dragging and dropping them or download the files inside Raspberry Pi files locally 102 Chapter 4 Appendix ...

Page 107: ...f router The default hostname of the Raspberry Pi OS is raspberrypi and you need to find it If you are using ArchLinuxARM system please find alarmpi Network Segment Scanning You can also use network scanning to look up the IP address of Raspberry Pi You can apply the software Advanced IP scanner and so on Scan the IP range set and the name of all connected devices will be displayed Similarly the d...

Page 108: ...SunFounder PiDog Kit Release 1 0 104 Chapter 4 Appendix ...

Page 109: ... 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 For any individual or organization that uses these for commercial profit without permission the Company reserves the right to take legal action 105 ...

Reviews: