Skip to content

Code Development Method

OriginBot fully follows the development method of ROS2, here is a brief introduction to the common operations of the feature pack, and the detailed development principles of ROS2, please refer to the ROS2 Getting Started Tutorial

Hint

The operating environment and software and hardware configurations are as follows:

  • OriginBot Robot (Visual Version/Navigation Version)
  • PC:Ubuntu (≥20.04) + ROS2 (≥Foxy)

Workspaces

In the development of ROS robots, when we develop code for some functions of the robot, all kinds of code, parameters, scripts and other files need to be placed in a certain folder for management, which is called a workspace in the ROS system.

In the official image of OriginBot, a workspace has been created, located in the /userdata folder, named dev_ws, which is called the root directory of the workspace, which contains four subfolders:

image-20220920221905698

  • src,code space,code and scripts written in the future, all need to be artificially placed here;
  • build,the compilation space,which saves the intermediate files generated during the compilation process;
  • install,installation space,where compiled executables and scripts are placed;
  • log,log space,during compilation and operation, various warnings, errors, information and other logs are stored;
  • config,configuration file,which stores the model configuration file of the human body tracking and gesture recognition application (not a folder required for the ROS2 workspace).

Most of our operations in these four space folders are carried out in src, and after the compilation is successful, the compilation result in install is executed.

Feature packs

The function packages of the OriginBot robot are placed in the src folder in the /userdata/dev_ws workspace, and the structure of the function packages is as follows:

  • originbot_base: Robot chassis drive
  • originbot_driver:Robot equipment driven
    • >> serial_ros2:Serial port driver package
    • >> ydlidar_ros2_driver:EAI X3 lidar Driver Package
    • >> kruisee_lidar:Krypton KRJ10 lidar Driver Package
  • originbot_msgs: OriginBot custom communication interface
  • originbot_bringup:Scripts and files related to the bot launch
  • originbot_linefollower:Robot visual line inspection function package
  • originbot_navigation:Scripts and configuration files related to robot mapping and navigation
  • originbot_example:The robot implements the official classic case function package of ROS
  • originbot_audio:Robot voice-related function packages
  • originbot_deeplearning:Robot deep learning function
    • >> body_tracking:Robot human body following function package
    • >> gesture_control:Robot gesture control function package
    • >> line_follower_perception:Robot AI visual line inspection function package
    • >> play_football:Robot AI visual kick and shoot function package
    • >> parking_search:Robot AI vision parking space search function package

Compile the code

After modifying the code or configuration file in the feature pack, you need to use the following command to compile the workspace, if there are missing dependencies or errors in the code, there will be an error during the compilation process, otherwise there should be no errors during the compilation process:

$ cd /userdata/dev_ws/
$ colcon build

image-20220920222359026

Set environment variables

After compilation, in order for the system to be able to find our feature pack and executable, we also need to set the environment variables:

$ source /userdata/dev_ws/install/local_setup.bash # Takes effect only on the current terminal
$ echo " source /userdata/dev_ws/install/local_setup.bash" >> ~/.bashrc # All terminals are valid and run only once
Hint

In the official image of OriginBot, the above environment variables have been set in the .bashrc configuration file, and there is no need to configure them again.

图片1