├── SECURITY.md ├── README.md ├── Robomaster S1 Rocks.py ├── Robomaster S1 Line Follower.py ├── RGB Pink Dimmer.py ├── Clap Scheme Examples.py ├── Break Robomaster S1.py ├── Random Led Loop Functions.py ├── RGB Colour Dimmers.py ├── Hit Detector Scheme Examples.py ├── Robomaster S1 Led Colour Dimmer Functions.py ├── Robomaster S1 Colour Dimmer Functions.py ├── RGB Trail Colour Chasers.py ├── Led Loop Functions.py ├── Robomaster S1 Shooting Gallery.py ├── Clap Disco Lamp.py ├── RGB Colour Chasers.py ├── Robomaster S1 Light Functions Template.py ├── Robomaster S1 Light Showoff.py ├── Robomaster S1 Counts.py ├── Led Looping Templates.py ├── LED LOOPERS.py ├── Robomaster S1 Random Generator Examples.py └── Robomaster S1 Led Looping Templates.py /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Use this section to tell people about which versions of your project are 6 | currently being supported with security updates. 7 | 8 | | Version | Supported | 9 | | ------- | ------------------ | 10 | | 5.1.x | :white_check_mark: | 11 | | 5.0.x | :x: | 12 | | 4.0.x | :white_check_mark: | 13 | | < 4.0 | :x: | 14 | 15 | ## Reporting a Vulnerability 16 | 17 | Use this section to tell people how to report a vulnerability. 18 | 19 | Tell them where to go, how often they can expect to get an update on a 20 | reported vulnerability, what to expect if the vulnerability is accepted or 21 | declined, etc. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # README 2 | ![20200624_150719](https://github.com/ROBOMASTER-S1/ROBOMASTER-S1-Python-Examples/assets/34896540/a429ea6e-3154-4028-a834-b3f0f2f8c60d) 3 | ROBOMASTER-S1-Python-Examples 4 | 5 | Learning how to program the Robomaster S1 in Python 6 | 7 | Note: you must install the Robomaster S1 app, either on your wireless mobile device or on your computer, via Wi-Fi. 8 | Next after installing the Robomaster S1 App, you will have to update the firmware for the Robomaster S1. 9 | Next you must calibrate the Robomaster S1 so it can work properly. 10 | 11 | Note: to be able to program the Robomaster S1 in Scratch or Python, you must run the Robomaster S1 app, then connect 12 | the Robomaster S1 to it, via wireless mobile device or on your computer, via Wi-Fi. 13 | 14 | I am almost a complete Walking Human Computer Science Research Laboratory Machine on Two Legs. 😁 15 | -------------------------------------------------------------------------------- /Robomaster S1 Rocks.py: -------------------------------------------------------------------------------- 1 | # The Robomaster S1 Rocks 2 | # Make the Robomaster S1 rock back and forth. 3 | # See what happens when you type and execute/run 4 | # this Python program example. 5 | 6 | robot=robot_ctrl 7 | gimbal=gimbal_ctrl 8 | chassis=chassis_ctrl 9 | media=media_ctrl 10 | led=led_ctrl 11 | define=rm_define 12 | 13 | l1,l2=0,255 14 | 15 | def start(): 16 | 17 | robot.set_mode(define.robot_mode_free) 18 | 19 | chassis.set_rotate_speed(120) 20 | gimbal.set_rotate_speed(120) 21 | 22 | led.set_flash(define.armor_all,4) 23 | led.set_top_led(define.armor_top_all,l1,l2,l1,define.effect_marquee) 24 | led.set_bottom_led(define.armor_bottom_all,l1,l2,l1,define.effect_flash) 25 | led.gun_led_on() 26 | 27 | for i in range(2): 28 | gimbal.rotate(define.gimbal_right) 29 | chassis.rotate_with_time(define.anticlockwise,0.3) 30 | gimbal.rotate(define.gimbal_left) 31 | chassis.rotate_with_time(define.clockwise,0.6) 32 | gimbal.rotate(define.gimbal_right) 33 | chassis.rotate_with_time(define.anticlockwise,0.3) 34 | 35 | led.turn_off(define.armor_all) 36 | led.gun_led_off();gimbal.stop() 37 | chassis.stop();gimbal.recenter() 38 | -------------------------------------------------------------------------------- /Robomaster S1 Line Follower.py: -------------------------------------------------------------------------------- 1 | # Here is the Robomaster S1 Line Follower Python program 2 | # example. I found this code on the dji Robomaster S1 app, 3 | # via cell phone only; not from my PC. I hope this code works. 4 | # I have aluminium bumpers on my Robomaster S1 and it 5 | # does not work for me. However, I did try to tweak what I 6 | # have here, I just hope it can work for others... 7 | 8 | robot=robot_ctrl 9 | gimbal=gimbal_ctrl 10 | chassis=chassis_ctrl 11 | media=media_ctrl 12 | vision=vision_ctrl 13 | armor=armor_ctrl 14 | led=led_ctrl 15 | define=rm_define 16 | 17 | pid=rm_ctrl.PIDCtrl() 18 | 19 | def start(): 20 | robot.set_mode(define.robot_mode_chassis_follow) 21 | gimbal.rotate_with_degree(define.gimbal_down,20) 22 | vision.enable_detection(define.vision_detection_line) 23 | vision.line_follow_color_set(define.line_follow_color_blue) 24 | vision.set_marker_detection_distance(1) 25 | 26 | pid.set_ctrl_params(330,0,28) 27 | while True: 28 | LineList=RmList(vision_ctrl.get_line_detection_info()) 29 | if len(LineList) == 42: 30 | if LineList[2] >= 1: 31 | robot_ctrl.set_mode(define.robot_mode_chassis_follow) 32 | variable_x = LineList[19] 33 | pid.set_error(variable_x - 0.5) 34 | gimbal.rotate_with_speed(pid.get_output(),0) 35 | chassis.set_trans_speed(.2) 36 | chassis.move(0) 37 | -------------------------------------------------------------------------------- /RGB Pink Dimmer.py: -------------------------------------------------------------------------------- 1 | # Let's make the Robomaster S1 become a cool RGB Pink Dimmer effect with this 2 | # fun Robomaster S1 Python program example. Simply type and execute/run this 3 | # program example below and see what happens. 4 | 5 | # Create some strings to shorten some of the long Robomaster S1 Python commands, 6 | # such as those long led commands. Give these strings similar names to the ones 7 | # used for parts of Robomaster S1's Python commands. For example: 8 | ''' 9 | robot=robot_ctrl 10 | gimbal=gimbal_ctrl 11 | chassis=chassis_ctrl 12 | blaster=ir_blaster_ctrl 13 | gun=gun_ctrl 14 | led=led_ctrl 15 | armor=armor_ctrl 16 | vision=vision_ctrl 17 | media=media_ctrl 18 | distance=ir_distance_sensor_ctrl 19 | sensor=sensor_adapter_ctrl 20 | define=rm_define 21 | 22 | led_ctrl.set_bottom_led(rm_define.armor_bottom_right,255,0,0,rm_define.effect_always_on) 23 | 24 | led.set_bottom_led(define.armor_bottom_right,255,0,0,define.effect_always_on) 25 | ''' 26 | # This is what unpacking variables looks like in Python. Unpacking variables 27 | # involves just one equal (=) sign, without having to index through a list. Just 28 | # simply call the actual variable you want to use, and it will keep its positional 29 | # index value intact. Sometimes it's a good idea to unpack variables instead, 30 | # rather than creating a list with indexes that might not be useful in some cases. 31 | # For example: 32 | 33 | # x1,x2,x3,x4,x5 = 0,255,-1,1,2 34 | 35 | # Let's have some fun and unpack these strings into variables instead of the actual 36 | # integer numbers themselves. 37 | 38 | # For example: 'x1,x2,x3,x4,x5' are called variables and the actual integer numbers 39 | # '0,255,-1,1,2' are called values, which the variables hold integer numbers, or 40 | # text as well; not shown here. 41 | 42 | # Create a while-loop to repeat the two for-loops twice, using the function called 43 | # "rgb_pink_dimmer()". 44 | 45 | led=led_ctrl 46 | define=rm_define 47 | x1,x2,x3,x4,x5=0,255,-1,1,2 48 | 49 | def start(): 50 | led.turn_off(define.armor_all) 51 | time.sleep(x4) 52 | 53 | def rgb_pink_dimmer(): 54 | for i in range(x1,x2): 55 | led.set_top_led(define.armor_top_all, 56 | i,x1,i,define.effect_always_on) # Pink 57 | 58 | led.set_bottom_led(define.armor_bottom_all, 59 | i,x1,i,define.effect_always_on) # Pink 60 | 61 | for i in range(x2,x1,x3): 62 | led.set_top_led(define.armor_top_all, 63 | i,x1,i,define.effect_always_on) # Pink 64 | 65 | led.set_bottom_led(define.armor_bottom_all, 66 | i,x1,i,define.effect_always_on) # Pink 67 | x=x1 68 | while x