dji ROBOMASTER EP CORE Programming Manual
Hide thumbs Also See for ROBOMASTER EP CORE:

Advertisement

Quick Links

SCRATCH
PROGRAMMING GUIDE

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ROBOMASTER EP CORE and is the answer not in the manual?

Questions and answers

Summary of Contents for dji ROBOMASTER EP CORE

  • Page 1 SCRATCH PROGRAMMING GUIDE...
  • Page 2 Catalog (Click on the chapter title and jump to the corresponding page) Brief Introduction .................................... 2 System ........................................ 3 LED Effects ....................................13 Chassis ......................................16 Extension Module ..................................39 Smart ........................................50 Armor .......................................77 Sensor .......................................82 Sensor Adaptor ....................................87 Mobile Device ....................................93 Media ........................................94 Commands ....................................
  • Page 3: Brief Introduction

    Brief Introduction The RoboMaster EP CORE programming guide is designed to help new users quickly learn programming techniques for controlling the EP CORE. The RoboMaster lab offers hundreds of graphical programming blocks that allow you to access specific features like EP CORE ’...
  • Page 4 System 1. Start (1) Description: Set the first program executed when the robot powers on (2) Type: Embedded block (3) Example: Move forward 1 meter This will control the RoboMaster EP CORE to move forward by 1 meter. Note:...
  • Page 5 If blocks (other than event triggering blocks and function blocks) are not placed within the “ Start ” area, they will not be executed. For example, in the program shown below, the RoboMaster EP CORE will not be able to take a photo.
  • Page 6 Notes: Selecting “ Pause ” will hold the time currently displayed on the timer. The timer will resume measurement from this time when it starts again. Refer to the example below in which t1=2 and t2=5. Select “ Stop ” to stop the timing process. The previously recorded time will be deleted, and the timer will begin measurement from zero when it starts again.
  • Page 7 Python API: Function: tools.timer_ctrl(behavior_enum) Parameters: ● behavior_enum(enum): ■ rm_define.timer_start ■ rm_define.timer_stop ■ rm_define.timer_reset 3. Set camera magnification to (1) (1) Description: Apply higher magnifications to support visual recognition over longer distances, enabling the robot to focus on unclear objects more accurately (2) Type: Execution block (3) Example: Enlarge camera frame Place a Vision Marker 10 meters in front of the robot ’...
  • Page 8 After enlarging the camera frame: Python API: Function: media_ctrl.zoom_value_update(value) Parameters: ● value (int): [1, 4]...
  • Page 9 4. Timer time (1) Description: Obtain the total time elapsed from when the timer first started to the current time (in seconds) (2) Type: Information block (variable-type data) (3) Example: Time a rotation This uses variables to measure the time it takes the chassis to complete one full rotation. You can check details using the FPV window: Python API: Function: tools.timer_current( )
  • Page 10: Program Runtime

    5. Program runtime (1) Description: Obtain the program running time (in seconds) (2) Type: Information block (variable-type data) (3) Example: Calculate program runtime This obtains the program running time using variables. You can check specific details using the FPV window: Python API: Function: tools.run_time_of_program( ) Return value:...
  • Page 11 (3) Example: Compare time values If the number of the current month is larger than the number of the current day, the Robomaster EP CORE will move its robotic arm up and down; if the number of the current month is less than or equal to the number of the current day, the EP CORE will rotate its chassis from left to right.
  • Page 12: Running Time

    7. Running time (1) Description: Indicate the total time elapsed from when the robot started running up to the current time (in seconds) (2) Type: Information block (variable-type data) (3) Example: Calculate running time time (in This measures the total time elapsed from when the robot most recently started running up to the current hour, minute, and second).
  • Page 13 If the robot restarts after a power failure, it will recount the running time. Python API: Function: tools.get_unixtime( ) Return value: ● time (float) 8. Remaining power (1) Description: Obtain the remaining power of the robot, and return an integer between 0 and 100 to indicate the remaining power percent (2)...
  • Page 14: Led Effects

    (1) Description: Set the flash rate for LEDs (2) Type: Settings block (3) Example: Configure reverse light This will set the rear LED of the chassis to flash red four times per second when RoboMaster EP CORE reversing. Python API: Function: led_ctrl.set_flash(armor_enum, frequency) Parameters: ●...
  • Page 15 ■ rm_define.armor_top_right ● frequency(int): [1, 10] 2. Set chassis (all) LED color to (green) and effect to (solid) (1) Description: Set chassis LED colors and effects: ● Solid: LED will remain steady ● Off: LED will switch off ● Pulse: LED will flicker (from dark to bright and then back to dark) ●...
  • Page 16 (2) Type: Execution block (3) Example: Configure signal light This will set the LEDs of RoboMaster EP CORE to flash on the right side of the chassis before turning right; after the turn is complete, it will switch the LED off.
  • Page 17 Python API: Function: led_ctrl.turn_off(armor_enum) Parameters: ● armor_enum(enum) ■ rm_define.armor_all ■ rm_define.armor_bottom_front ■ rm_define.armor_bottom_back ■ rm_define.armor_bottom_left ■ rm_define.armor_bottom_right ■ rm_define.armor_top_left ■ rm_define.armor_top_right Chassis 1. Set (PWM_all) output to (7.5) (1) Description: Set the output percentage for the PWM port; the larger the value used, the longer the port will maintain a high level of output over the specified time period.
  • Page 18 ② Rotate navigation gear This enables you to connect an external navigation gear to any PWM port and then control its rotation. Notes: PWM port is located on the chassis motion control module and can be seen by removing the transparent cover on the rear side of the chassis.
  • Page 19 For LEDs, the PWM output rate ranges from 0% to 100%, with 0% corresponding to an LED ’ s lowest brightness and 100% to its highest brightness. For navigation gears, the PWM output rate ranges from 2.5% to 12.5%. Because most navigation gears have a control impulse frequency of 50Hz and a control period of 20ms, and because the high-level pulse width of outputs with an adjustable angle range of -90°...
  • Page 20 When the chassis is moving automatically, this will enable you to use the joystick to manually rotate or translate the chassis and increase its translation speed. Notes: If the “ Enable chassis accelerator ” block has not been added, you will not be able to manually control the chassis while running the program.
  • Page 21 As the image below shows, the chassis translates at a programmed speed of 0.5 m/s. When the joystick is pushed to its limit and the chassis accelerator is enabled, the robot will add the two speeds together and translate in a forward direction at a total speed of 1.5 m/s (0.5 m/s + 1 * the joystick ’...
  • Page 22 Note: ’ Please ensure there are no obstacles in the robot s intended path before setting the chassis to a high translation speed. Python API: Function: chassis_ctrl.set_trans_speed(speed) Parameters: ● speed(float): [0, 3.5] m/s 4. Set chassis rotation speed to (30)° /s (1) Description: Set the default rotation speed of the chassis to 30°...
  • Page 23 Python API: Function: chassis_ctrl.set_rotate_speed(speed) Parameters: ● speed(int): [0, 600] ° /s 5. Set wheel rotation speed (rpm) to front-left (100) front-right (100) rear-left (100) rear-right (100) (1) Description: Allow each wheel ’ s rotation speed to be set independently; only valid combinations of rotation direction and speed will take effect.
  • Page 24 ② Translating in a circle This will control the robot to translate along a circular path. Notes: The robot will translate forward at the default rotation speed of 100 rpm for the front-left wheel, 100 rpm for the front-right wheel, 100 rpm for the rear-left wheel, and 100 rpm for the rear-right wheel. To determine a valid combination of wheel rotation directions and speeds, ’...
  • Page 25 When the robot translates backward and to the left, the front-left wheel and the rear-right wheel will rotate backward, so their rotation speed values should be negative, while the front-right wheel and the rear-left wheel will stay still, so their rotation speed values should be zero.
  • Page 26 (1) Description: Set the chassis to translate in a specified direction (2) Type: Execution block (3) Example: Make a round trip This will control the RoboMaster EP CORE to translate forward for one second, then turn around and return to the starting point. Note: This block will control the chassis to continuously translate in a specified direction until the robot receives a “...
  • Page 27 7. Set chassis to translate at (0)° for (1)s (1) Description: Set the duration of time the chassis will translate in a specified direction (2) Type: Execution block (3) Example: Translate in an X-pattern This will control the robot to translate to the “right, forward-left, right, and backward-left” in an X-shaped sequence. Python API: Function: chassis_ctrl.move_with_time(degree, time) Parameters:...
  • Page 28 (1) Description: Set the distance the chassis will translate in a specified direction (2) Type: Execution block (3) Example: Translate in a cross-pattern This will control the robot to translate “forward, backward, left and right” in a cross-shaped sequence. Python API: Function: chassis_ctrl.move_with_distance(degree, distance) Parameters: ●...
  • Page 29 ● distance(float): [0, 5] m 9. Set chassis to translate (0)° at (0.5)m/s (1) Description: Set the chassis to translate in a specified direction and at a specified speed (2) Type: Execution block (3) Example: Return to starting position This sets the chassis to translate forward and to the right at 1 m/s, then translate backward and to the left at 0.5m/s to return to the original position.
  • Page 30 This will control the chassis to rotate increasingly quickly to the right. Notes: Be sure there are no obstacles around the robot before setting a high chassis rotation speed. This block will set the chassis to rotate constantly in a specified direction until it receives a “ set chassis to stop moving ”...
  • Page 31 11. Set chassis to rotate (right) for (1) s (1) Description: Set the duration the chassis will rotate in a specified direction (2) Type: Execution block (3) Example: Rotate left and right The chassis will rotate right for 3 seconds and then rotate left for 3 seconds to return to the original position. Python API: Function: chassis_ctrl.rotate_with_time(direction_enum, time) Parameters:...
  • Page 32 Python API: Function: chassis_ctrl.rotate_with_degree(direction_enum, degree) Parameters: ● direction_enum(enum): ■ rm_define.clockwise ■ rm_define.anticlockwise ● degree(int): [0, 1800] ° 13. Set chassis to rotate (right) at (30)° /s (1) Description: Set the chassis to rotate in a specified direction and at a specified rotation rate (2) Type: Execution block (3) Example: Rotate at variable speed The chassis will rotate right slowly and then rotate left fast.
  • Page 33 14. Set chassis to translate forward at (0)° and rotate (right) (1) Description: Set the chassis to move in a specified direction while rotating simultaneously (2) Type: Execution block (3) Example: Translate in a figure-8 pattern This sets the robot to translate in a figure-8 pattern. Python API: Function: chassis_ctrl.move_and_rotate(degree, direction) Parameters:...
  • Page 34 15. Set chassis to translate at (0.5) m/s along X axis and (0.5)m/s along Y axis and rotate along Z axis at (30)° /s (1) Description: Set the chassis to translate in a specified direction and at a specified speed (2) Type: Execution block (3) Example: Dishwashing moves Python API:...
  • Page 35 This sets the chassis to translate forward for 2 seconds at default speed, then turn right and stop moving Python API: Function: chassis_ctrl.stop( ) 17. Chassis (yaw) axis attitude angle (1) Description: Obtain the current pitch angle for the chassis along its current yaw/pitch/roll axes based on the chassis location when the robot begins running (2) Type: Information block (variable-type data) (3) Example: Signal turn...
  • Page 36 Notes: Rotating the chassis along the yaw axis results in left and right rotation. Rotating the chassis along the pitch axis results in up and down rotation. Rotating the chassis along the roll axis will cause the robot to turn over. Python API: Function: chassis_ctrl.get_attitude(attitude_enum) Parameters:...
  • Page 37 18. Current chassis position (x coordinate) (1) Description: Obtain the current location coordinates and orientation of the chassis (2) Type: Information block (variable-type data) (3) Example: Obtain current position information This enables you to check numerical data for the current chassis position by manually pushing the robot back and forth or turning it left and right.
  • Page 38 ■ rm_define.chassis_forward ■ rm_define.chassis_translation ■ rm_define.chassis_rotate Return value: ● position(float) 19. When chassis hits an obstacle (1) Description: Run the program for the corresponding block when the chassis hits an obstacle (people, table legs etc.) while driving (2) Type: Event block (3) Example: Self-defend This enables the self-defense mechanism to activate when the chassis impacts an obstacle, causing the robot to retreat and stop running the block.
  • Page 39 (2) Return value: Boolean (3) Example: Emit danger warning If the chassis impacts an obstacle while the robot is being controlled through the FPV interface, the “ hit ” sound will play and all red LED indicators for the chassis will blink; otherwise, all LED chassis indicators will remain in the default color. Python API: Function:chassis_ctrl.is_impact( ) Return value:...
  • Page 40: Extension Module

    Extension Module 1. Set gripper to (open) (1) Description: Set gripper to open, close, or stop. (2) Type: Execution block (3) Example: Flexible gripper movement Set gripper to first open then close. Notes: “Set gripper (Open, Close)” is a continuous movement; therefore it must be used with time control modules such as “Wait for (1)s”.
  • Page 41 It can be observed from the FPV window that it takes about 2.1 seconds.
  • Page 42 3. Gripper’s closing status (1) Description: Learn whether the gripper is fully closed. If the return value is “1”, the gripper is fully closed; if the value is “0”, the gripper is not fully closed. (2) Type: Information block (3) Example: Gripper closes Control the gripper’s movement according to its current state until it is fully closed.
  • Page 43 5. Set robotic arm to move forward for (50) millimeters (1) Description: Using the robot body coordinate system as the reference frame, and control the robotic arm to move in a specified direction for a set distance. (2) Type: Execution block (3) Example: Robotic arm dance Control the robotic arm to move forward, backward, upward, and downward.
  • Page 44 may differ, and the robot has built-in limit protection in software, please use the slider to manually control the robotic arm to the target position on the operation interface, use the “robotic arm current position” block to obtain the current robotic arm coordinate information, and then debug the program.
  • Page 45 Notes: Mark the origin when connecting the robotic arm and proceed according to the instructions in the manual. Flexibly control the robotic arm, the gripper, and the mobile chassis so that the robot can grasp, lift, transfer, and deliver objects. Due to the difference in assembly and calibration environment of each robot, the robot coordinate systems of different robots may differ, and the robot has built-in limit protection in software, please use the slider to manually control the robotic arm to the target position on the operation interface, use the “robotic arm current position”...
  • Page 46 position on the operation interface, use the “robotic arm current position” block to obtain the current robotic arm coordinate information, and then debug the program. 8. Robotic arm current position (1) Description: Obtain the robotic arm current position. The position parameter is (X (abscissa), Y (ordinate)). The unit is millimeter.
  • Page 47 It can be observed through the FPV window: 9. Set servo No. (1) to rotate to (90)° (1) Description: Set a specified servo (No.) to rotate to a set angle. If the set angle is a positive value, the servo rotates clockwise; if the set angle is a negative value, the servo rotates counterclockwise.
  • Page 48 Notes: The servo supports two kinds of control: angle control and speed control. This module is applicable to situations with a high requirement for the rotation angle control of the servo. When the servo is installed on the robotic arm, using servo-related modules in the “extension modules ” to control the servo is not supported.
  • Page 49 11. Set servo No. (1) to rotate at (10)° /s (1) Description: Set a specified servo (No.) to rotate at a set speed. If the speed is a positive value, the servo rotates clockwise; if the speed is a negative value, the servo rotates counterclockwise. (2) Type: Execution block (3) Example: The servo speed changes along with the direction.
  • Page 50 Note: The servo supports two kinds of control: angle control and speed control. This module is applicable to cases with a high requirement for speed control of the servo, which will continuously rotate without any positioning limitations. 12. Servo No. (1) angle (1) Description: Obtain the angle of a specified servo (No.).
  • Page 51 Set the chassis to translate in a V shape when the RoboMaster EP CORE identifies the V-sign hand gesture. Note: The RoboMaster EP CORE ’ s smart identification function is disabled by default. If the identification function is not enabled for the robot, it will respond to identifiable objects.
  • Page 52 In the above two example programs, the RoboMaster EP CORE will be unable to identify V and the chassis will not move. Python API: Function: vision_ctrl.enable_detection(function_enum) vision_ctrl.disable_detection(function_enum) Parameters: ● function_enum(enum): ■ rm_define.vision_detection_marker ■ rm_define.vision_detection_pose ■ rm_define.vision_detection_car ■ rm_define.vision_detection_people...
  • Page 53 2. (Enable) Line identification (1) Description: Enable/disable line identification (2) Type: Settings block (3) Example: Identify blue lines When the robot identifies blue lines, all chassis LEDs will be solid blue. Notes: The line identification function is disabled by default. You must enable line identification for the robot to be able to respond to line inspection commands.
  • Page 54 When the robot identifies a double clap, all red LED chassis indicators will blink. Note: Clapping identification is disabled by default. If clapping identification is not enabled first, RoboMaster EP CORE will not respond to any clapping. Python API: Function: media_ctrl.enable_sound_recognition(function_enum) media_ctrl.disable_sound_recognition(function_enum) Parameters: ●...
  • Page 55 Notes: If the Vision Marker is placed more than 1 meter away from the robot (for example 1.5 or 2 meters away from the robot), the robot will not be able to identify it. The identification distance only applies when using Vision Markers of the official standard size. The effective identification distance may vary if you print your own Vision Markers in non-standard sizes.
  • Page 56 Note: The default identifiable vision marker color is red. 6. Set line identification color to (blue) (1) Description: Set the specific line color the robot will be able to identify (2) Type: Settings block (3) Example: Identify blue lines When blue tape is laid on the ground before the camera, the robot’s chassis LED will blink blue for 3 seconds.
  • Page 57 Note: The default line color that the robot can identify is blue. Python API: Function: vision_ctrl.line_follow_color_set(color_enum) Parameters: ● color_enum(enum): ■ rm_define.line_follow_color_blue ■ rm_define.line_follow_color_red ■ rm_define.line_follow_color_green...
  • Page 58 7. Set exposure to (high) (1) Description: Reduce the exposure in Line Follow Mode to prevent blurriness caused by fast turns, ensuring effective and accurate visual identification (2) Type: Settings block (3) Example: EP CORE’s line follow Python API: Function: media_ctrl.exposure_value_update(exposure_value_enum) Parameters:...
  • Page 59 ● exposure_value_enum(enum): ■ rm_define.exposure_value_large ■ rm_define.exposure_value_medium ■ rm_define.exposure_value_small 8. Identify (red heart) and aim (1) Description: Set the robot to identify and aim at the central position of the corresponding Vision Markers (2) Type: Execution block (3) Example: Set robot to aim at the red heart Notes: You must enable Vision Marker identification for the robot to be able to identify Vision Markers.
  • Page 60 9. When (person) identified (1) Description: Set the corresponding block to run its internal program when specified information is identified (2) Type: Event block (3) Examples: Indicate turn, Control attitude ① Indicate turn When the robot identifies a left arrow, the left turn red LED chassis indicators will blink and the robot will translate left for 1 second;...
  • Page 61 Notes: The Event is of high priority, which means that no matter where the main function runs, the main function will be suspended and the program in the Event will start running once the triggering conditions are fulfilled. To have the robot identify a person, rotate the robotic arm slightly upward, have the person stand at a distance of 1 meter, and ensure that the person stands upright within the robot ’...
  • Page 62 def vision_recognized_marker_letter_all(msg) … def vision_recognized_marker_letter_[A, , Z](msg) Type: Event callback 10. When (2) claps identified (1) Description: Set the block to run its internal program when a specific clapping pattern is identified (2) Type: Event block (3) Example: Translate in a spiral pattern Initially, all chassis LED indicators are turned off.
  • Page 63 Python API: Function: def sound_recognized_applause_twice(msg) def sound_recognized_applause_thrice(msg) Type: Event callback 11. (Person) identified (1) Description: Set the robot to return the condition “ True ” when specified information (such as an object, vision marker, gesture, and so on) is identified; otherwise, the condition “ False ” is returned. (2) Return value: Boolean (3) Example: Identify people When the robot identifies a person, all red LED chassis indicators will blink;...
  • Page 64 Note: Try to use this block with conditional statements whenever possible. Python API: Function: vision_ctrl.check_condition(condition_enum) Parameters: ● condition_enum(enum): ■ rm_define.cond_recognized_people ■ rm_define.cond_recognized_car ■ rm_define.cond_recognized_marker_trans_all ■ rm_define.cond_recognized_marker_trans_left ■ rm_define.cond_recognized_marker_trans_right ■ rm_define.cond_recognized_marker_trans_forward ■ rm_define.cond_recognized_marker_trans_stop ■ rm_define.cond_recognized_marker_trans_red_heart ■ rm_define.cond_recognized_marker_trans_target ■ rm_define.cond_recognized_marker_trans_dice ■ rm_define.cond_recognized_marker_number_all ■...
  • Page 65 12. (2) claps identified (1) Description: Set the robot to return the condition “ True ” when a specific clapping pattern is identified; otherwise, the condition “ False ” is returned. (2) Return value: Boolean (3) Example: Stop motion with clapping This sets the robot to turn right and stop all motion when it identifies 3 claps.
  • Page 66 13. Wait until (person) identified (1) Description: When specific information (such as an object, vision marker, gesture, and so on) is identified, the system will continue executing commands; otherwise, it will continue to wait. (2) Type: Execution block, Blocking block Example: Practice shooting Play sound effect when target is identified successfully Note:...
  • Page 67 ■ rm_define.cond_recognized_people ■ rm_define.cond_recognized_car ■ rm_define.cond_recognized_marker_trans_all ■ rm_define.cond_recognized_marker_trans_left ■ rm_define.cond_recognized_marker_trans_right ■ rm_define.cond_recognized_marker_trans_forward ■ rm_define.cond_recognized_marker_trans_stop ■ rm_define.cond_recognized_marker_trans_red_heart ■ rm_define.cond_recognized_marker_trans_target ■ rm_define.cond_recognized_marker_trans_dice ■ rm_define.cond_recognized_marker_number_all ■ rm_define.cond_recognized_marker_number_[zero,..., nine] ■ rm_define.cond_recognized_marker_letter_all ■ rm_define.cond_recognized_marker_letter_[A,..., Z] ■ rm_define.cond_recognized_pose_all ■ rm_define.cond_recognized_pose_victory ■ rm_define.cond_recognized_give_in ■ rm_define.cond_recognized_capture 14. Wait until (2) claps identified (1) Description: Set the system to continue to execute commands when a specific clapping pattern is identified;...
  • Page 68 Python API: Function: vision_ctrl.cond_wait(condition_enum) Parameters: ● condition_enum(enum): ■ rm_define.cond_sound_recognized_applause_twice ■ rm_define.cond_sound_recognized_applause_thrice 15. Identified vision marker info (1) Description: Obtain information for an identified Vision Marker, returned as N, ID, X, Y, W, and H parameters. (2) Type: Information block (list-type data) (3) Example: Recognize Vision Markers When a Vision Marker appears in the robot ’...
  • Page 69 Notes: The vision marker format is as follows: The first item is N, the number of gestures the robot has identified. The second item is a group of 5 numbers: gesture ID, X-axis of the center point, Y-axis of the center point, W-width and H-height, followed by gesture ID, X-axis of the center point, Y-axis of the center point, W-width and H-height of the second gesture, the third, ...
  • Page 70 16. Identified (person) info (1) Description: Obtain the information of an identified person or such robot in terms of the parameters such as N, X, Y, W, and H Type: Information block (list-type data) Example: Identify another EP CORE robot When another EP CORE robot appears in the robot ’...
  • Page 71 Python API: Function: vision_ctrl.get_people_detection_info( ) vision_ctrl.get_car_detection_info( ) Return value: ● detection_info(list) 17. Identified gesture info (1) Description: Acquire identified gesture information in terms of the parameters N, ID, X, Y, W, and H (2) Type: Information block (list-type data) (3) Example: Gesture information You can observe changes in gesture-related data using the FPV window.
  • Page 72 The first item is N, the number of gestures the robot has identified. The second item is a group of 5 numbers: gesture ID, X-axis of the center point, Y-axis of the center point, W-width and H-height, followed by gesture ID, X-axis of the center point, Y-axis of the center point, W-width and H-height of the second gesture, the third, ...
  • Page 73 Notes: The single line information format that is identifiable by the robot is as follows: The first item “N” is the number of points identified on the line, the second item ‘Info’ is the line type, and the subsequent items are grouped into 4 data groups: they are the (Coordinate X, ordinate Y, actual tangent angle θ, curvature C) of ten points that are equidistant from each other on the line (from the nearest to the farthest).
  • Page 74 The third and fourth data sets (X1, Y1) indicate the coordinate information of the first point on the line. The first point is at the bottom of the FOV, which is the point closest to the robot. The fifth data set θ1: Tangent angle of the first point. When the tangent angle is 0, it means that the angle between the tangent and the vertical direction of this point is 90 degrees;...
  • Page 75 If no line is identified by the robot, the length of the returned line data is 2 while the value of the first and second items are all 0. 19. Identified multi-line info (1) Description: Obtain identified multi-line information. The parameters are n, X, Y, θ, and C. (2) Type: Information block (list-type data) (3) Example: Multi-line blink indication When the robot identifies N lines, all the chassis LED indicators blink blue N times.
  • Page 76 Notes: The multi-line information format identified by the robot is as follows: The first item n (number of lines), from clockwise, the (Coordinate X, ordinate Y, actual tangent angle θ, curvature C) of ten points that are equidistant from each other on the first line (from the nearest to the farthest), the (X, Y, θ, C) of ten points on the second line ..., the (X, Y, θ, C) of ten points on the numbered n line.
  • Page 77 Python API: Function: vision_ctrl.get_env_brightness( ) Return value: ● brightness_value(int) 21. Sight position (1) Description: Obtain information for sight position in terms of the parameters X and Y (2) Type: Information block (list-type data) Example: Follow vision markers This will convert the difference between the sight position and a Vision Marker in the robot ’ s field of view into a chassis rotation angle value in order to direct the chassis to move toward the Vision Marker.
  • Page 78 Python API: Function: media_ctrl.get_sight_bead_position( ) Return value: ● sight_bead_position(list) Armor 1. Set armor sensitivity to (5) (1) Description: Set armor sensitivity; the larger the value, the higher the armor sensitivity. For testing armor sensitivity with hard objects or by tapping, the recommended values are 6 and 8, respectively. (2) Type: Settings block (3) Sample: Response to tapping ’...
  • Page 79 Note: Configuring armor sensitivity is only available in laboratory testing. Any armor sensitivity settings will be restored to default during competition. Python API: Function: armor_ctrl.set_hit_sensitivity(value) Parameters: ● value(int): [0, 10] 2. When (any) armor hit ’ (1) Description: Run the block s program when the armor is hit at a specified section (2) Type: Event block (3) Sample: Response to tapping...
  • Page 80 Python API: Function: def armor_hit_detection_all(msg) def armor_hit_detection_bottom_right(msg) def armor_hit_detection_bottom_left(msg) def armor_hit_detection_bottom_front(msg) def armor_hit_detection_bottom_back(msg) def armor_hit_detection_top_right(msg) def armor_hit_detection_top_left(msg) Type: Event callback 3. Most recently hit armor (ID) (1) Description: Display information for the last armor section hit; the ID value indicates the specific section that was hit, and the running time shows the time it was hit (2) Type: Information block (variable-type data) (3) Example: Hit indicator...
  • Page 81 Notes: The returned ID value indicates the section of the armor that has been hit: ID=1: Chassis rear ID=2: Chassis front ID=3: Chassis left side ID=4: Chassis right side Python API: Function: armor_ctrl.get_last_hit_index( ) Return value: ● index(int) Function: armor_ctrl.get_last_hit_time( ) Return value: ●...
  • Page 82 Python API: Function: armor_ctrl.check_condition(condition_enum) Parameters: ● condition_enum(enum): ■ rm_define.cond_armor_hit ■ rm_define.cond_armor_bottom_front_hit ■ rm_define.cond_armor_bottom_back_hit ■ rm_define.cond_armor_bottom_left_hit ■ rm_define.cond_armor_bottom_right_hit ■ rm_define.cond_armor_top_left_hit ■ rm_define.cond_armor_top_right_hit 5. Wait for hit on (any) armor Description: Execute the next command when the specified armor is hit; otherwise, it continues to wait Type: Execution, blocking block Example: Self-defense After the robot is attacked, the chassis quickly rotates to form a self-defense circle.
  • Page 83 Python API: Function: armor_ctrl.cond_wait(condition_enum) Parameters: ● condition_enum(enum): ■ rm_define.cond_armor_hit ■ rm_define.cond_armor_bottom_front_hit ■ rm_define.cond_armor_bottom_back_hit ■ rm_define.cond_armor_bottom_left_hit ■ rm_define.cond_armor_bottom_right_hit ■ rm_define.cond_armor_top_left_hit ■ rm_define.cond_armor_top_right_hit Sensor 1. (Enable) infrared distance sensor No. (1) measurement functions (1) Description: Turn on or turn off the distance measuring function of a specified infrared distance sensor (No.). (2) Type: Settings block (3) Example: Distance measuring using infrared beams Measure the distance between the infrared distance sensor and your palm.
  • Page 84 Move your palm forward and backward and observe the real time distance change through the FPV window. Notes: The distance measuring function of the infrared distance sensor is achieved mainly by the Time of Flight (ToF) camera. The sensor sends out a modulated light pulse (such as infrared beams sent by the infrared distance sensor) which then reflects off the object.
  • Page 85 2. When infrared distance sensor No. (1) distance value (≥) (10) centimeters (1) Description: Run the program in this module when the distance measured by the specified infrared distance sensor (No.) meets the condition. (2) Type: Event block (3) Example: Continuously approaching Control the robot mobile chassis so that it continuously translates towards the wall until the distance measured by the infrared ≤...
  • Page 86 Type: Execution, Blocking block (3) Example: Anti-collision warning ≤ The robot keeps approaching the wall. When the infrared depth sensor detects that the robot is 50 cm away from the wall, the chassis LEDs blink red to warn, and the default LED effect is restored when the distance exceeds 50 cm. 4.
  • Page 87 5. Infrared distance sensor No. (1) distance value (1) Description: Obtain the distance measured by the specified infrared distance sensor (serial No.). The unit is centimeter. (2) Type: Information block (3) Example: Distance measuring using infrared beams Measure the distance between the infrared distance sensor and your palm. Move your palm forward and backward and observe the real time distance change through the FPV window.
  • Page 88 Note: The distance that the infrared distance sensor can read ranges from 10 centimeters to 10 meters. Sensor Adaptor 1. When sensor adaptor No. (1) signal voltage range changes to (high) (1) Description: Execute the program in this module when the I/O pin level of the specified port of the specified sensor adaptor meets the conditions.
  • Page 89 Notes: The output level of the button can be high or low. When the button is “pressed” and “released”, the output level changes, and the I/O pin of the sensor adaptor receives the level signal change so as to control the opening or closing of the gripper. The three pins on the button need to be connected to the designated spots of the sensor adaptor through DuPont wires: Button Pin Sensor Adaptor Port...
  • Page 90 Notes: The sound signal received by the sound sensor used in this function design will output a high electrical level if the signal does not reach the set threshold of the sensor, and a low level if the threshold is exceeded, but the situation for different types of sound sensors varies.
  • Page 91 3. When sensor adaptor No. (1) port (1) signal voltage range is (high) (1) Description: Return “True” when the I/O pin level of the specified port of the specified sensor adaptor meets the conditions; otherwise, returns “False”. (2) Return value: Boolean (3) Example: Lighting effect upon touch Connect a touch sensor to sensor adaptor No.
  • Page 92 4. Sensor adaptor (1) port (1) ADC value (1) Description: Read the ADC pin value of a specified port of a specified sensor adaptor. (2) Return value: Information block (3) Example: Temperature alarm Connect a temperature sensor to sensor adaptor No. (1). A sound alert is played when the temperature sensor approaches a cup filled with hot water.
  • Page 93 VCC(5V) Water level sensor OUT(AD) VCC(5V) High or low Hall sensor electrical OUT(AD) level+ADC OUT(TTL) VCC(5V) High or low Flame sensor electrical module OUT(AD) level+ADC OUT(TTL) VCC(5V) High or low Tracking sensor electrical OUT(AD) level+ADC OUT(TTL) VCC(5V) High or low Smoke sensor electrical OUT(AD)
  • Page 94: Mobile Device

    (2) Type: Information block (variable-type data) (3) Example: Dynamic rotation control Rotate the mobile device to the left or right and observe whether the RoboMaster EP CORE ’ s chassis rotates accordingly. Notes: 1) Mobile device refers to devices such as smartphones and tablets.
  • Page 95 Notes: The faster the robot ’ s velocity changes, the higher the rate of acceleration that will be obtained. Mobile device refers to devices such as smartphones and tablets. The built-in sensor settings of mobile devices may be differ in models, obtain the value sent by the sensor in advance. Python API: Function: mobile_ctrl.get_accel(axis_enum) Parameters:...
  • Page 97 2. Play sound effect (hit) (1) Description: Set the EP CORE to emit a sound and executes the next command block (2) Type: Execution, Non-blocking (3) Example: Hit indicator If the armor on either side of the chassis is attacked, it will play the hit sound effect. Python API: Function: media_ctrl.play_sound(sound_enum, wait_complete_flag=False) Parameters:...
  • Page 98 (3) Example: Remote control photograph When the RoboMaster EP CORE identifies a “ take photo ” gesture, it will take a photo after playing the “ start countdown ” chime. If it does not identify a “ take photo ” gesture, it will continue to rotate and search for the gesture while playing a “...
  • Page 99 “ ” play sound refers to simultaneous execution of the music and the next command, similar to a musical accompaniment; “ ” play sound until finished refers to the execution of playing sound and following commands one by one, similar to a musical solo (for example, it does not dance until the sound finishes playing).
  • Page 100: Take Photo

    5. Play customized audio (select audio) until finished (1) Description: Play inserted customized audio, and the next command will not be executed until the audio is finished block (2) Type: Execution, Blocking Example: play full music clip 6. Take photo (1) Description: Set the robot to emit a specified shutter sound when it takes photos.
  • Page 101 Users will need to insert an SD card with an available memory of more than 2G to operate the “take photo” command. Python API: Function: media_ctrl.capture( ) 7. (Start) video recording (1) Description: Start/stop recording; recorded videos will be saved in the APP album and SD card. (2) Type: Execution block (3) Example: Video recording When the robot recognizes three claps, it rotates in a circle to record the surrounding environment video.
  • Page 102 (2) Type: Execution block (3) Example: Complete a square This will command the RoboMaster EP CORE to translate in the following order to complete a square every two seconds by moving as translating: “ right → forward → left → backward. ”...
  • Page 103 2. Repeat (10) (1) Description: Configure a program to repeat the same command several times (finite loop block) (2) Type: Execution block (3) Example: Translate along a zigzag line This will control the robot to translate along a zigzag line. 3.
  • Page 104 (2) Type: Execution block (3) Example: Rotate chassis left and right The chassis continues to rotate left and right. 4. If...then... (1) Description: Run an internal program when the condition is “ True ” (2) Type: Conditional statement block (3) Example: Rotate and revolve This will control the robot to revolve while rotating...
  • Page 105 Note: The difference between conditional statement blocks and event blocks is that event blocks have higher priority when certain conditional statements are met. Regardless of which step the main function is at, the program within the event block will be finished first.
  • Page 106 5. If...then...else... “ ” (1) Description: Run the “then” program when the condition is and runs the “else” program otherwise True, (2) Type: Conditional statement block (3) Example: Hit indicator If any armor of the robot is attacked, all the chassis LEDs will blink red; otherwise, the default LED effect is solid on. 6.
  • Page 107 (2) Type: Conditional statement block (3) Example: Polygon positioning Set RoboMaster EP CORE to follow the tracks of regular triangle, square, regular pentagon and regular hexagon in sequence. Note: In order to make sure of the proper number of loop, consider it thoroughly when you are completing the judgment conditions.
  • Page 108 Operators 1. (0)+(0) (1) Description: Add two numbers (2) Return value: Variable-type data (3) Example: Perform basic arithmetic calculations This will calculate 【(66÷ 2)+3】× 2-5=? You can check the result using the FPV window. Note: Arithmetic calculations cannot be performed on lists.
  • Page 109 2. (0)-(0) (1) Description: Subtract one number from another (2) Return value: Variable-type data (3) Example: Calculate an arithmetic progression This will calculate an arithmetic progression according to the formula An=A1+ (n-1) *d, with the first calculate item as 1 and a tolerance of 2.
  • Page 110 Note: Arithmetic calculations cannot be performed on lists. 3. (0)*(0) Description: Multiply two numbers Return value: Variable-type data Example: Generate reverse display This allows you to rotate the chassis manually and observe how the value changes in the FPV window. Because this is the reverse display, when the gimbal is rotating on the right side of the chassis, the value will always be negative;...
  • Page 111 Note: Arithmetic calculations cannot be performed on lists. 5. Select random value between (1) to (10) (1) Description: Select a random value from a specified range (2) Type: Information block (variable-type data) (3) Example: Play a number guessing game Guess a number to enter and compare it to the random value generated by the robot. If your answer is greater than or equal to the robot’s number, the chassis will flashing green light to indicate that the answer is correct;...
  • Page 112 Note: If the values you enter within the specified range are all integers, the output will always be an integer. If any of the values you enter within the specified range is a decimal (whether it is the first, last, or any in between), the output will also be a decimal.
  • Page 113 7. Remainder of (0) divided by (1) (1) Description: Obtain the remainder of the first value divided by the second value (2) Type: Information block (variable-type data) (3) Example: Find the lowest common multiple The robot will find the lowest common multiple of 12 and 15.
  • Page 114 You can check the result using the FPV window. (LCM=60) Note: LCM is short for the lowest common multiple.
  • Page 115: Absolute Value

    8. Absolute value (0) (1) Description: Perform mathematical operations for a variety of functions, such as calculating absolute value, floor and ceiling functions, square root, and sine angle (2) Type: Information block (variable-type) (3) Example: Mathematical calculation You can check results using the FPV window.
  • Page 116 9. (0)==(0) “ ” “ ” (1) Description: Return True when two values are equal; otherwise, False is returned (2) Return value: Boolean (3) Example: Set flag bits All LEDs on the chassis will turn solid red when the users clap two times, Initially, the chassis displays a solid default color.
  • Page 117 Note: In programming, flag bits distinguish various states in order to make the robot execute different commands. 10. (0)!=(0) “ ” “ ” (1) Description: Return True when two values are not equal; otherwise, False is returned (2) Return value: Boolean (3) Example: Indicate successful identification of one person “...
  • Page 118 Note: “ ” “ ” “≠” is the symbol for unequal to in programming language and has the same meaning as in mathematical language. 11. (0)<(0) “ ” “ ” (1) Description: Return True if the first value is less than the second value; otherwise, False is returned.
  • Page 119 Note: This is often used with conditional statements. 12. (0)<=(0) “ ” “ ” (1) Description: Return the condition True if the first value is less than or equal to the second value; otherwise, False returned. (2) Return value: Boolean (3) Example: Accelerate rotation If the chassis is rotating at a rate less than or equal to 540 degrees/s, it will increase by 60 degrees/s per second while rotating to the right for 3 seconds at a time until the maximum value of 600 degrees/s is achieved and acceleration stops.
  • Page 120 Note: “ “ ” “≤” <=” is the symbol for less than or equal to in programming language and has the same meaning as in mathematical language. 13. (0)>(0) “ ” “ ” (1) Description: Return the condition True if the first value is larger than the second value; otherwise, False is returned.
  • Page 121 14. (0)>=(0) “ ” “ ” (1) Description: Return the condition True if the first value is greater than or equal to the second value; otherwise, False returned. (2) Return value: Boolean (3) Example: Partial response If the chassis front and rear armors were hit last, chassis front and rear LEDs will blink red; if the chassis armors were hit last on both sides, there is no response.
  • Page 122 15. ( ) and( ) “ ” “ ” (1) Description: Return the condition True when two conditions are met; otherwise, the condition False is returned. (2) Return value: Boolean (3) Example: Clap to summon the robot “ ” “ When a person stands one meter away from the robot and claps twice, the robot will approach.
  • Page 123 (3) Example: Emergency prompt When the armor is attacked or the chassis hits an obstacle, all the LEDs on the chassis will blink red. Note: “and, ” “ or, ” and “ not” are logical operations, and the returned result will be a Boolean value: “ True, ” or “ False. ” The “or”...
  • Page 124 Note: “and, ” “ or, ” and “ not” are logical operations, and the returned result will be a Boolean value: “ True, ” or “ False. ” The “not” of Boolean truth list: 18. Map (0) from low (0) high (1023) to low (0) high (4) (1) Description: Scale the set value according to the proportional relationship.
  • Page 125: Data Objects

    Data Objects 1. Create variable (1) Description: Create a name for a new variable. Type: Settings block Example: Name a new variable Each variable name must be unique and simple to understand. For example, we often name the variable for a marker in the sequence as Flag, and the variable used to store value as Number. Variable names need to begin with an underscore or a letter, and can only contain numbers, uppercase and lowercase letters, and underscores.
  • Page 126 (3) Example: Risk warning If the attitude angle of the roll axis of RoboMaster EP CORE chassis is greater than 50 or less than -50, the chassis LED will blink red to remind users that they should be careful of the risk of the robot rollover.
  • Page 127 You can check details about the time using the FPV window. The hour, minute and second values will change continuously. Notes: Variables save one piece of data, and lists save a string of data, which cannot be mixed. For a variable, the input value can be a number, a variable, or variable-type data, but cannot be a list or a list data type.
  • Page 128 4. Increase (#Variable#) by (1) (1) Description: Change current variable value; positive values indicate an increase while negative values indicate a decrease (2) Type: Execution block (3) Examples: Decrease variable value by 1, Translate in a figure-8 pattern ① Decrease variable value by 1 Assign a value to the variable, then configure the change in value: In the FPV window, you can see that the initial variable value of variable_e is 2.
  • Page 129 When you set the waiting time to 2 seconds and decrease the value by 1, the variable value of variable_e becomes 1. ② Translate in a figure-8 pattern It is an alternative configuration for setting the robot to translate in figure-8 pattern.
  • Page 130 5. Create list (1) Description: Create and names a list (2) Type: Settings block (3) Example: Name a new list...
  • Page 131 List names need to begin with an underscore or a letter and can only contain numbers, uppercase and lowercase letters, and underscores: Note: After the list is created, several related blocks will appear, which are responsible for adjust, assign, adding and deleting the list etc.
  • Page 132 You can check details using the FPV window: 7. Add (1) to the end of (#List#) (1) Description: Add an item to the end of a list (2) Type: Execution block (3) Example: Display multiples of 5 ≥ The configuration below allows you to obtain and display all multiples ( 0) of 5.
  • Page 133 Note: The input value can be a number, a variable, or variable-type data, but cannot be a list or a list-type data.
  • Page 134 8. Set (#List#) to (empty list) (1) Description: Assign values to a list (2) Type: Execution block (3) Example: Recognize a person In the FPV window, the list is configured to recognize a person and generate relevant information: Notes:...
  • Page 135 List values can be numbers, lists, or list-type data, but cannot be variables or variable-type data. You cannot perform arithmetic operations directly on a list. 9. Delete item (1) of (#List#) (1) Description: Delete an item from a list (2) Type: Execution block (3) Example: Delete the number of people...
  • Page 136 In the FPV window, the list length changes from 5 to 4 after deleting the first item. Before:...
  • Page 137 After: Notes: The user needs to know the serial number of the item before deleting it. After deleting an item, the number of items decreases by 1. All following items will come up by 1, of which the serial number reduces by 1 accordingly. 10.
  • Page 138 Before: After: 11. Insert (1) before item (1) of (#List#) (1) Description: Insert an item at a specific location in a list and shifts subsequent items down the list (2) Type: Execution block (3) Example: Insert program runtime timer Apply the red tape and observe the FPV window. You can see that the “program runtime” is inserted as the first item of the list, the original items are shifted down the list, and the total number of items increases by 1.
  • Page 139 Before: After:...
  • Page 140 12. Replace item (1) of (#List) with (1) (1) Description: Replace an item on the list (2) Type: Execution block (3) Example: Replace a value This will make every value in List_B be greater than the corresponding value in List_A by 1.
  • Page 141 Notes: The item must contain a value before it can be replaced. For example, if List_B is empty, it is not useful by replacing one item in List_B. 13. Item (1) of (#List#) (1) Description: Obtain a specific item on a list (2) Type: Information block (variable-type) (3) Example: Specify an item on a list...
  • Page 142 In the FPV window below, data2 = 7 and data3 = 5.
  • Page 143 14. The first (1) index of (#List#) ’ (1)Description: Obtain the location of the data s first occurrence in the current item (the number of the item) (2)Type: Information block (variable-type) (3)Example: Read the index value “ ” “ ” Create a list of {5, 1, 2, 1, 7}, and set the index number for the first You can check the result using the FPV window:...
  • Page 144 15. Total items for (#List#) (1) Description: Obtain the total number of items for a list (2) Type: Information block (variable-type data) (3) Example: Calculate the number of items You can check value changes using the FPV window. The length value starts at 2 and becomes 0 after deleting all items. Before:...
  • Page 145 After: 16. (#List#) contains (1)? “ ” “ ” (1) Description: Return True when a list contains an input value; otherwise, False is returned (2) Return value: Boolean (3) Example: List data judgement If a certain value is included in the list, all LEDs on the chassis blink red to indicate. Note: The judgment item must match exactly so the condition will be judged to be true.
  • Page 146 17. Create PID controller (1) Description: Create and names a PID controller Type: Settings block (3) Example: Name controller Note: After the controller is created, there will be three modules available to configure error settings, adjust parameters, and obtain output information. Python API: Class: rm_ctrl.PIDCtrl( ) 18.
  • Page 147 Note: Before running the program, make sure that the vision marker appears properly in the robot’s FOV. Moving Insufficient Rotation Upside Down Perspective Obstructed Too Fast sunlight Case Greatly Greatly Greatly Fail to Impact No Impact No Impact affected affected affected identify Python API:...
  • Page 148 (1) Description: Adjust the PID parameters; Kp is the proportional coefficient, Ki is the integral coefficient, and Kd is the differential coefficient. (2) Type: Settings block (3) Example: EP CORE’s line follow Modify parameters of Kp, Ki, and Kd to optimize the closed-loop control system. Note: Function Features...
  • Page 149 Differential It can reflect change of speed of the Cannot eliminate the Helps reduce adjustment time and improve Control error signal, and have immediate steady-state error of the system quality. (D Control) control when the error just occurs. system. Find out more about PID in the RoboMaster App by searching for the “Follow Vision Marker” project in the Road to Mastery section.
  • Page 150 Python API: Class: rm_ctrl.PIDCtrl( ) ● Function: ■ get_output( ) ● Return value ■ output(float)
  • Page 151 Functions 1. #Function# (1) Description: Package a program that needs to appear multiple times into a function, making it convenient to use Type: Function block (3) Example: Hit rotation If the armor pieces on either side of the chassis are attacked, it will play the hit sound effect and the chassis will rotate right at 360°...
  • Page 152 After a function has been created, the packaged block will appear for use: Using functions helps make the whole program more concise and clear.

Table of Contents