太白金星

【Training Camp】A mobile repair dog

 
Overview

Project Description 

When I first saw this dog, I wanted to name it a moving repair dog~, so the name of the project was a moving repair dog;
Production idea: I am more interested in servo control and 3D design;
Implemented functions: The basic functions of the dog, such as installation, stepping, forward, backward, etc., have been realized. I originally wanted to implement ultrasonic ranging and avoid obstacles, but the module was broken. The power indicator module and a servo failed before video recording, so the effect was a bit strange.
Front.jpg Looking down.jpg
Left.jpg Right rear.jpg

Schematic design instructions

Based on the given basic schematic diagram, the principle of the system is drawn modularly, as shown in the following figure:
Schematic diagram.png

Added part:

(1) A locomotive and a power switch are added to the power supply. Both of these devices are high-current devices and lead out the required power supply voltage for use;
(2) Group the interfaces of the four legs and lead to the remaining 8 sets of expansion interfaces;
(3) A power indicator LED and a function LED are added;
(4) Plate and frame studs;
Note: If you want to access the battery power indicator module, it is more reasonable to replace the PWR in H1 with VIN, so that the power indicator can be turned on and off when the switch is activated. Otherwise, it will be turned on all the time to consume the battery.
image.png

PCB design instructions

Basically, the layout is based on the schematic diagram. The main idea is that the upper left is the power supply, the upper right is the Hi3861 module, and the lower part is reserved for the PCA9685. The whole thing is relatively simple.
image.png
image.png
Pin connection.jpg

material selection

Servo: MG90S metal gear
Main control: Chuanzhi Hi3861 module
Battery: Two parallel and two series 18650 lithium batteries 7.4V 4000mAh
Power display: 4-segment display

3D shell

The top and bottom covers have been widened, the side covers have been heightened, the thighs have been lengthened and the calves have been modified. The front and rear baffles have also been modified. The front baffle does not match the actual ultrasonic size, and the power display module does not match the rear one. Bezel matches.
image.pngimage.pngimage.pngimage.pngimage.pngimage.pngimage.png

programming

Using the virtual machine officially provided by Chuanzhi, VMWare16 Pro can be opened directly without any errors. hb build can be used directly.

image.png

code editor

Visual Studio Code, personally familiar with it
image.png

1 About installation mode

Since my dog's legs are long, the dog's legs are not stable in the default installation mode, so I need to enter parameters in the dog leg simulation for adjustment.
image.png
Other static postures are adjusted according to the software to obtain the degrees of alpha and beta.
After obtaining the angle of the above posture, download and verify it through pycarm IDE.

Custom dog-leg installation mode

image.png

2 Modify the web page to add buttons and implement functions (note the html format)

The web page is modified as follows. When adding buttons, add the corresponding click action function for binding.
image.png
View directly in browser
image.png

C code logic modification

main program

#include <stdio.h>

#include <string.h>

#include <strings.h>

#include <stdlib.h>

#include <unistd.h>



#include "ohos_init.h"

#include "cmsis_os2.h"



#include "genki_base.h"

#include "genki_web_ohosdog.h"

#include "genki_web.h"

#include "genki_pin.h"

#include "dog.h"

#include "led.h"

#include "beep.h"

#include "lcd_st7735.h"



static void init_service(void)

{

genki_web_register(newDogService());

}



static void start(void)

{

IoTIoSetFunc(IOT_IO_NAME_10, IOT_IO_FUNC_10_I2C0_SDA);

IoTIoSetFunc(IOT_IO_NAME_9, IOT_IO_FUNC_9_I2C0_SCL);

IoTI2cInit(0, 400000);

init_led();

init_beep();

init_service();

dog_init();

genki_services_start();

dog_install();

// ST7735_LCD_Init();

// LCD_ShowString(8, 8, "Hello Word", BLACK, BLUE, 16, 1);

}



APP_FEATURE_INIT(start);

Installation mode

void dog_install(void)
{
  dog_setLeftFrontAngle(45, 135);
  dog_setLeftBackAngle(45, 135);
  dog_setRightFrontAngle(45, 135);
  dog_setRightBackAngle(45, 135);
}

static pose

When type is set to 2 in dog.c, it is used as a static posture communication command. When htm sends the json string to Hi3861 through http, only the Hi3861 pair is retained, which represents the analysis of the "index" key-value pairs of the four static posture commands. , while discarding other key-value pair parsing.
void dog_execJson(char *buf, int len)
{
  cJSON *recv_json;
  recv_json = cJSON_ParseWithLength(buf, len);

  int type = cJSON_GetObjectItem(recv_json, "type")->valueint;
  if (type == 1)
  {
    dog_install();
  }
  else if (type == 2)
  {
    int index = cJSON_GetObjectItem(recv_json, "index")->valueint;

    // cJSON *data_json;
    // data_json = cJSON_GetObjectItem(recv_json, "data");
    // int alpha = cJSON_GetArrayItem(data_json, 0)->valueint;
    // int beta = cJSON_GetArrayItem(data_json, 1)->valueint;

    // if (index == 0) {
    // dog_setLeftFrontAngle(alpha, beta);
    // } else if (index == 1) {
    // dog_setLeftBackAngle(alpha, beta);
    // } else if (index == 2) {
    // dog_setRightFrontAngle(alpha, beta);
    // } else if (index == 3) {
    // dog_setRightBackAngle(alpha, beta);
    // }

    if (index == 0) // squat
    {
      dog_setLeftFrontAngle(15, 165);
      dog_setLeftBackAngle(15, 165);
      dog_setRightFrontAngle(15, 165);
      dog_setRightBackAngle(15, 165);
    }
    else if (index == 1) // stand up
    {
      dog_setLeftFrontAngle(85, 70);
      dog_setLeftBackAngle(85, 70);
      dog_setRightFrontAngle(85, 70);
      dog_setRightBackAngle(85, 70);
    }
    else if (index == 2) // Lie forward
    {
      dog_setLeftFrontAngle(-40, 45);
      dog_setRightFrontAngle(-40, 45);
      dog_setLeftBackAngle(45, 90);
      dog_setRightBackAngle(45, 90);
    }
    else if (index == 3) // Lie down
    {
      dog_setLeftFrontAngle(90, 135);
      dog_setRightFrontAngle(90, 135);
      dog_setLeftBackAngle(160, 180);
      dog_setRightBackAngle(160, 180);
    }
  }
  else if (type == 3)
  {
    int execute_count = 1;
    if (cJSON_HasObjectItem(recv_json, "count"))
    {
      execute_count = cJSON_GetObjectItem(recv_json, "count")->valueint;
    }

    dog_action_t *action = malloc(sizeof(dog_action_t));
    action->exec_count = execute_count;

    //Send multiple messages
    cJSON *list_json;
    list_json = cJSON_GetObjectItem(recv_json, "list");
    int count = cJSON_GetArraySize(list_json);

    action->len = count;
    action->cmds = malloc(sizeof(dog_cmd_t) * count);

    for (int i = 0; i < count; i++)
    {
      cJSON *item_json;
      item_json = cJSON_GetArrayItem(list_json, i);

      dog_cmd_t cmd;
      cmd.angle[0] = cJSON_GetArrayItem(item_json, 0)->valueint;
      cmd.angle[1] = cJSON_GetArrayItem(item_json, 1)->valueint;
      cmd.angle[2] = cJSON_GetArrayItem(item_json, 2)->valueint;
      cmd.angle[3] = cJSON_GetArrayItem(item_json, 3)->valueint;
      cmd.angle[4] = cJSON_GetArrayItem(item_json, 4)->valueint;
      cmd.angle[5] = cJSON_GetArrayItem(item_json, 5)->valueint;
      cmd.angle[6] = cJSON_GetArrayItem(item_json, 6)->valueint;
      cmd.angle[7] = cJSON_GetArrayItem(item_json, 7)->valueint;
      cmd.duration = cJSON_GetArrayItem(item_json, 8)->valueint;

      action->cmds[i] = cmd;
    }
    dog_execAction(action);
  }
  cJSON_Delete(recv_json);
}

Other actions are generated by modifying the software and then written into HTML.

image.png
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-05-20 15:11:15

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号