Программирование spike на python

Программирование на Python на базе SP­IKE Prime и EV3 в 7-11 классах. Видеозапись вебинара

Приглашаем к просмотру учителей информатики 7-11 классов, педагогов центров детского развития, а также специалистов дополнительного образования.

Продолжительность вебинара 45 мин (1 акад. ч)

Стоимость доступа к видеозаписи 200 рублей. (в стоимость входит также именной электронный сертификат ИНТ (образовательная лицензия ИНТ № 037511 от 19.05.2016). Сертификат оформляется и высылается на ФИО и адрес электронной почты, указанные при регистрации.

Ссылка на видеозапись высылается после поступления оплаты на счет ИНТ на адрес электронной почты покупателя, указанный при регистрации. Если после оплаты в течение двух рабочих дней вы не получите от Учебного центра письмо с ссылкой на видеозапись, проверьте, не попало ли оно в папку СПАМ или НЕЖЕЛАТЕЛЬНАЯ ПОЧТА.

Доступ к видеозаписи открывается на 15 дней с даты отправки ссылки.

ПОДРОБНЕЕ О ВЕБИНАРЕ

Полное название вебинара Программирование на Python на базе SP­IKE Prime и EV3 в 7-11 классах средней школы и в дополнительном образовании.

Python — один из самых популярных языков программирования мобильных приложений в мире. На вебинаре рассказывается о том, какие новые возможности раннего профориентирования открывает применение языка программирования Python на уроках информатики при работе с решениями SPIKE™ Prime и MINDSTORMS® EV3 от LEGO® Education, а также:

  • о различных стратегиях использования Python на платформах EV3 и SPIKE™ Prime;
  • о том, как настроить и организовать работу на Python с решениями LEGO Education;
  • о возможностях интеграции SPIKE Prime и EV3 в школьные курсы информатики;
  • о доступных учебных курсах по информатике от LEGO Education;
  • о том, какие методические материалы LEGO Education можно использовать, чтобы познакомить учеников с примерами применения передовых IT-технологий в реальном мире;
  • о программах повышения квалификации от LEGO Education для педагогов информатики.
Читайте также:  Программирование python mac os

Ведет вебинар Андрей Пешков — методист и разработчик образовательных программ, тренер компании LEGO Education.

По всем вопросам вы можете обратиться по телефону горячей линии 8 (800) 555 19 56 (звонок по РФ бесплатный), 8 (903) 614 85 79 или по электронной почте training [at] int-edu.ru

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

These are the programs we use every day as a team for programming the LEGO SPIKE PRIME for competitions such as the First Lego League. Feel free to use this code and tag us on social media if you do so

License

GO-Robot-FLL/Python-for-Spike-Prime

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

These are some basic programs that are useful if you are building and programming the LEGO SPIKE PRIME. We use this code for competing in the FLL ourselves and have received multiple awards for our robot design. We strongly recommend that you use VS Code for your programming, the instructions for doing so are below. You can however also paste this into the SPIKE or MINDSTORMS software.

Programs and Features included

  • follows line until specified color/distance is reached
  • acceleration/braking
  • dynamic PID control for smooth driving
  • turns until specified color/angle is reached
  • acceleration/braking
  • different turning styles (on the spot/curve)
  • drives in a straight line until specified distance/color is reached
  • accelerating/braking
  • dynamic PID control for smooth driving
  • alignment with lines
  • parallel code execution for turning motors while driving
  • turns in a large arc, to be able to turn around objects until ending condition is reached
  • accelerating breaking
  • various ending conditions
  • allows you to break out of currently running function back into main
  • press right button to activat
  • save significant amounts of time and is less prone to crashing the hub than middle button

Necessary extensions/Programs for use in VS Code:

Visual Studio Code Python Lego Spike Prime/Mindstorms Robot Inventor Extension by Peter Staev

Fully charged battery voltage

When the battery is fully charged the voltage is roughly 8300. This will vary based on how the wear and tear of your battery. We recommend charging the robot when the battery voltage drops below 8000 mV, as there is a reduction in torque.

Click the button LEGO Hub: Disconnected on the left hand side of the blue bottom bar. A dropdown menu will open at the top of the screen, try out all the COM options it gives you until you are connected. Note: You have to have previously connected to the hub in the Spike or Mindstorms software first.

How to upload a program to the hub:

Press CTRL SHIFT P and select LEGO Hub: upload program from the dropdown menu. Choose Python: regular. Choose the slot you want the program to be saved in on the hub.

Press CTRL + SHIFT + P and select LEGO Hub: start program from the dropdown menu. Select the slot of the program you want to start on the hub. Note: This step can be skipped if you have autostart activated.

How to enable precompiling:

To precompile the main.py on the PC/laptop, go to the extension page and select the extension. Then click on the settings symbol and activate Lego Spike Prime Mindstorms: Compile Before Upload. This will allow the program to start faster.

If you find a bug, kindly report it to go.robot@gmynasium-ottobrunn.de We will try to fix it as soon as possible. If you have any questions regarding the code, please reach out to us using the same Email adress.

For further info on working with Spike Prime in VS Code see:

Thanks to Peter Staev for making it possible for us to use access in depth features of Spike Prime and for enabling us to use VS Code to program.

This program uses features of extensions that use unofficial and undocumented APIs. They can change without notice. Functions tested on Windows 10/11 connecting to a LEGO MINDSTORMS Spike Prime Hub.

LEGO and MINDSTORMS are registered trademarks of the LEGO Group. SPIKE is a trademark of LEGO Group.

About

These are the programs we use every day as a team for programming the LEGO SPIKE PRIME for competitions such as the First Lego League. Feel free to use this code and tag us on social media if you do so

Источник

LEGO Spike Prime – “Translate” Programming Blocks into Python Code

In my previous post, I introduced how to set a mission for LEGO Spike Prime and implement the task with LEGO Spike programming blocks. As I mentioned before, Lego Spike Prime supports MicroPython pretty well. Most of the programming blocks could find corresponding Python functions.

In this post, I will demonstrate how to “translate” my previous programming blocks into Python code. I will also show an issue encountered when writing Python code and a way to work around it.

The programming blocks and mission setting could be found at this post. Since the programming blocks are long, I will not list them here again.

“Start_off” function

The program initiates two colour sensors and one distance sensor at the beginning. In “start_off” function, most of the code has corresponding programming blocks, so it is pretty convenient to “translate” programming blocks into the Python code. MotorPair objects are used to control 2 motors simultaneously in opposite directions. Please note that “wait until” block could not be translated directly since Python has not such kind of loop statement. I need to use “while” loop to replace it and make proper adjustment to make code run well.

“start_line_sensing” Function

The distance sensor sometimes will return None type, which I believe is a bug of the current MicroPython version. To workaround this problem, we need to check if the retrieved value of “get_distance_cm” is equal to None. Otherwise, since None type is different from float type, the system will throw out a runtime error and the whole program will stop.

The Python code here realizes the same functionality as block programming. It uses proportional line following method to control the movement of the motors.

“move_clip” Function

This function is simple. It just drives a single motor which connects to Port F to run clockwise or counter-clockwise for a certain degree.

“send_to_destination” Function

This function will send an object to the destination. The code is similar to the above “start_line_sensing” function. It uses proportional line following method to trace the black line until color sensor on Port E identifies color red, which is the edge of the destination.

“return_to_base” Function

This function returns the vehicle robot to the starting place. However, after using Motor object to control Port B and Port D motor, the program stops unexpectedly. It seems the problem happens when using MovePair and Motor objects to control the same ports. It is a bug of the current MicroPython version.

To workaround this problem, I should only use MovePair objects to control the two motors. The following is a method to implement it.

Update of “return_to_base” Function

In the following code, Motor object related code has been replaced with a function called “run_until_touching_red_line”. Except this, all the other code is the same as the previous version. I will explain “run_until_touching_red_line” function below.

“run_til_touching_red_line” Function

This function sets two variables “motor_b_status” and “motor_d_status” which represent the move/stop status of Port B motor and Port D motor. Color sensor E and C are mounted to the side of Port B and Port D motor, respectively. In while loop, when colour sensor E identifies red colour, it will set the “motor_b_status” to 0, meaning that the motor B on its side should stop running.

After that, the program checks the value of “motor_d_status”. If “motor_d_status” is 0, meaning that the other motor has stopped running, the program knows that it could stop both motors by calling motor_pair.stop() and exiting the while loop. If “motor_d_status” is equal to 1, the program will call motor_pair.start_tank(0,30), so that only the motor D on the other side keeps moving.

The same logic applies when colour sensor C identifies red colour. Through using the two variables “motor_b_status” and “motor_d_status”, MotorPair function could specify the speed of each motor correctly.

That is all the MicroPython code in order to accomplish the same mission done by programming blocks. If you are keen to try it yourself, you could copy the above code into Python canvas and check how it works. Enjoy the coding and have fun!

Источник

Оцените статью