Jetson 09 Automatically Send Instructions When Powered On

From Waveshare Wiki
Jump to: navigation, search

Automatically send instructions when booted

This chapter tutorial is used to introduce the host controller will automatically execute instructions and send some instructions to the sub-controller every time it is turned on, the code blocks in this chapter of the tutorial do not need to be executed (and cannot be executed), only used to understand some automatic operations of the product after booting, if you have the need, change or add these instructions.

cmd_on_boot() function

cmd_on_boot() function is located in the main program app.py of the product, this function will be called every time you boot up, you can edit this function to adjust the parameters/add instructions to the instructions that run automatically at boot.

def cmd_on_boot(): 
      # Define the list of commands to be executed at startup 
      cmd_list = [ 
             'base -c {"T":142,"cmd":50}', # set feedback interval 
             'base -c {"T":131,"cmd":1}', # serial feedback flow on 
             'base -c {"T":143,"cmd":0}', # serial echo off 
             'base -c {"T":4,"cmd":2}', # select the module - 0:None 1:RoArm-M2-S 2:Gimbal 
             'base -c {"T":300,"mode":0,"mac":"EF:EF:EF:EF:EF:EF"}', # the base won't be ctrl by esp-now broadcast cmd, but it can still recv broadcast megs. 
             'send -a -b' # add broadcast mac addr to peer 
      ] 
     # traversal command list 
     for i in range(0, len(cmd_list)): 
          camera.cmd_process(cmd_list[i])

The host controller of the product can control some functions through the command line instruction, similar to the base -c instruction above, which is used to directly pass the JSON instruction written later to the sub-controller through Jetson's GPIO serial port, and we will explain in detail what the default instruction here means to run automatically at boot.

  • base -c {"T":142,"cmd":50}

Used to set the extra interval time of continuous feedback information from the sub-controller, the unit of cmd value is ms, this function is used to reduce the frequency of feedback information from the sub-controller, and the purpose is to reduce the computing power pressure of the host controller to process the feedback information of the sub-controller.

  • base -c {"T":131,"cmd":1}

Turn on the continuous information feedback function of the sub-controller, after the function is turned on, there is no need for the host controller to ask and answer to get the information of the sub-controller, the sub-controller will normally turn on the function by default, but we still send another command to turn on the function, which is safer.

  • base -c {"T":143,"cmd":0}

Turn off the serial port command echo, so that when the host computer sends instructions to the sub-controller, the sub-controller will no longer feed back the received instructions to the host computer, so as to avoid the host computer from processing useless information.

  • base -c {"T":4,"cmd":2}

Set the type of the external module, if the value of cmd is 0, it means that there is no external module; 1. a mechanical arm; 2. Gimbal, if your product does not have a gimbal or robotic arm installed, you need to change the value here to 0.

  • base -c {"T":300,"mode":0,"mac":"EF:EF:EF:EF:EF:EF:EF"}

Avoid the chassis being controlled by the ESP-NOW broadcast of other devices, but you can make up a MAC address by yourself in addition to the device with the mac address, or you can use the MAC address of your own ESP32 remote control.

  • send -a -b

Add the broadcast address (FF:FF) to the peer, so that you can then send the broadcast message directly to other devices through the broadcast signal.

You can learn about other host controller command line instructions through the WEB Command Line Application chapter later.