Skip to main content

Robot Kolunun Programlanması - Python

Teacher Toolbox icon Teacher Toolbox - Activity Outline

  • This exploration will introduce students to basic programming of the V5 Clawbot's Arm Motor. 
  • Learning to program the Arm Motor enables students to properly control the V5 Clawbot's arm movements. For more information about the instructions used in a Python project, visit the help information for VEXcode V5 Python.

Teacher Tips icon Teacher Tips - Using Autocomplete

Autocomplete is a feature in VEXcode V5 that predicts the rest of the command you are typing. As students are working in VEXcode V5, encourage them to use the Autocomplete feature to help with the Python syntax. You may notice an autocomplete function as you start to type the instruction. Use your “Up” and “Down” keys to select the name you want, then press “Tab'' or (Enter/Return) on your keyboard to make the selection. For more information on this feature check out the Python article. VEXcode V5 Python workspace with the start of a Drivetrain command typed, and the autocomplete window open showing the options for the rest of the command.

V5 Clawbot yola çıkmaya hazır!

Bu keşif size V5 Clawbot'un kolunu kullanarak bazı harika projeler yaratmaya başlamanız için gereken araçları sağlayacak.

  • Bu araştırmada kullanılacak VEXcode V5 Python talimatları:
    • arm_motor.spin_for(İLERİ, 90, DERECE)
    • arm_motor.set_position(0, DERECE)
    • bekle(2, SANİYE)
  • Talimat hakkında daha fazla bilgi edinmek için, daha fazla bilgi görmek üzere bir komutun yanındaki soru işareti simgesini seçin. 

    VEXcode V5, çalışma alanında girilen komut için bir Sürücü gösterir ve bu komut için sağ tarafta Yardım açılır. Yardım, Drive for'u, Drivetrain'i belirli bir mesafe boyunca hareket ettirmek olarak tanımlar ve komutun bir projede nasıl kullanılacağını açıklar.

  • Gerekli donanıma, mühendislik not defterinize ve VEXcode V5'e sahip olduğunuzdan ve hazır olduğunuzdan emin olun.
Gerekli Malzemeler:
Miktar Gerekli Malzemeler
1

VEX V5 Sınıf Başlangıç Seti (güncel yazılımla)

1

VEX kodu V5

1

Mühendislik Not Defteri

1

Clawbot ve Advanced TrainingBot (2 motorlu aktarma organları, jiroskopik sistem yok) örnek projesi

Adım 1: Keşfe Hazırlık

Etkinliğe başlamadan önce bu malzemelerin her birini hazır bulunduruyor musunuz? Aşağıdakilerin her birini kontrol edin:

  • Motorlar doğru portlara mı takılı?

  • Akıllı kablolartam olaraktüm motorlara mı takılmış?

  • Beyinmi açılıyor?

  • Pilşarjlı mımi?

Teacher Tips icon Teacher Tips

Model each of the troubleshooting steps for the students.

Adım 2: Yeni Bir Proje Başlatın

Projenize başlamadan önce doğru şablon projeyi seçin. Clawbot ve Advanced TrainingBot (Aktarma Organları 2 Motorlu, Jiroskop Yok) örnek projesi Clawbot'un motor konfigürasyonunu içermektedir. Şablon kullanılmadığı takdirde robotunuz projeyi doğru bir şekilde çalıştıramayacaktır.

Dosya menüsü açık ve Örnekleri Aç kırmızı kutuyla vurgulanmış şekilde VEXcode V5 Araç Çubuğu. Örnekleri Aç, Yeni Blok Projesi, Yeni Metin Projesi ve Aç öğelerinin altındaki dördüncü menü öğesidir.

Aşağıdaki adımları tamamlayın:

  • Dosya menüsünü açın.
  • SeçÖrnekler.

Metnin üstünde gri bir robot bulunan Clawbot ve Advanced Training Bot yazan simge.

  • Clawbot ve Advanced TrainingBot (2 Motorlu Aktarma Organları, Jiroskop Yok) örnek projesini seçip açın.
  • Kolu kontrol etmeyi programlayacağımız için projenizin adınıArmContrololarak değiştirin.
  • Projenizikaydedin.
  • ArmControl projesinin adının artık araç çubuğunun ortasındaki pencerede olduğundan emin olun.

VEXcode V5 Araç Çubuğu'ndaki proje adı iletişim kutusunda Arm Control yazıyor ve Slot 1'in seçildiği gösteriliyor.

Teacher Tips icon Teacher Tips

  • Since this is a beginning activity with programming, the teacher should model the steps, and then ask the students to complete the same actions. The teacher should then monitor the students to ensure that they are following the steps correctly.
  • Make sure that the students have selected Open Examples from the File menu.
  • Make sure that the students have selected the Clawbot and Advanced TrainingBot (Drivetrain 2-motor, No Gyro) example project.

          You can point out to the students that there are several selections to pick from on the Examples page. As they build and use other robots, they will have a chance to use different templates.

  • You can ask students to add their initials or the name of their group to the project name. This will help differentiate the projects if you ask the students to submit them.

Teacher Toolbox icon Teacher Toolbox - Saving Projects

  • Point out that when they first opened VEXcode V5, the window was labeled VEXcode Project. VEXcode Project is the default project name when VEXcode V5 is first opened. Once the project was renamed and saved, the display was updated to show the new project name. Using this window in the toolbar, it is easy to check that the students are using the correct project.
  • Tell the students that they are now ready to begin their first project. Explain to the students that by just following a few simple steps, they will be able to create and run a project that will raise and lower the Clawbot's arm.
  • Remind students to save their projects as they work. The articles in the Python section of the VEX Library explains saving practices in VEXcode V5.

Teacher Toolbox icon Teacher Toolbox - Stop and Discuss

This is a good point to pause and have the student groups review the steps that were just completed on starting a new project in VEXcode V5.

Adım 3: Kolu Yukarı Hareket Ettirin

Şimdi kolun yükselmesini programlayarak başlayacağız!

# Kütüphane
vex'ten içe aktarır *

# Proje kodunu başlat
arm_motor.set_position(0, DEGREES)
  • Yukarıda gösterildiği gibi programlama alanına kolun başlangıç pozisyonunu ayarlamak için arm_motor.set_position()komutunu yazın.
arm_motor.set_position(0, DERECE)
arm_motor.spin_for(İLERİ, 90, DERECE)
  • Yukarıda gösterildiği gibi kolu yukarı hareket ettirmek için arm_motor.set_position() komutunun altına arm_motor.spin_for()komutunu ekleyin.

VEXcode V5 Araç Çubuğu, proje adının yanında açık yuva seçimiyle. 1. yuva seçilip kırmızı kutucukla vurgulanır ve proje adı Arm Control olarak yazılır.

  • Slot simgesini seçin. Projenizi Robot Beyni'ndeki mevcut slotlardan birine indirebilirsiniz. 1. Yuvayı seçin.

VEXcode V5'teki Araç Çubuğunun yeşil kol simgesinin etrafında kırmızı bir kutu ile görüntüsü

VEXcode V5'teki indirme düğmesinin etrafında kırmızı bir kutu bulunan araç çubuğu. Soldan sağa gösterilen simgeler Kontrolör, Beyin, İndir, Çalıştır ve Durdur'dur.

  • ArmControl projesini Robot Beynine indirmek için araç çubuğundakiİndirbutonuna tıklayın.

Teacher Toolbox icon Teacher Toolbox

If the students are using a computer, ask them now to disconnect the USB cable from the Robot Brain. Having the robot connected to a computer while running a project could cause the robot to pull on the connection cable.

V5 Beyin Ana Ekranı sol alt köşedeki 1. yuvada Kol Kontrol projesini gösterir. Üst satırda Sürücü, Aygıtlar, Ayarlar ve VEX simgeleri yer alıyor.

  • ArmControl projesinin seçtiğiniz yuvadaki beyne indirildiğini kontrol edin.

Teacher Toolbox icon Teacher Toolbox - Model First

Model running the project in front of the class before having all of the students try at once. Gather the students in one area and leave enough room for the Clawbot to move its arm. Demonstrate how to end the project and have the Clawbot's arm lower back to its resting position.

Tell the students it is now their turn to run their projects. Make sure that they have adequate space to safely have the Clawbot's arm raised.
 

  • Clawbot'ta projeyi projenin seçili olduğundan emin olun ve ardından Çalıştır düğmesine basın. İlk Pençe Kol projenizi oluşturduğunuz için tebrikler!

4. Adım: Şunu deneyin: Kolu Aşağıya Programlayın

Kolu yukarı hareket ettirecek şekilde programladığınıza göre şimdi de kolu aşağı veya aşağı hareket ettirecek şekilde programlayacaksınız.

V5 Clawbot'un kolu aşağıdayken yan görünümü

VEX V5 Pençebot'un kolu aşağıdayken görüntüsü

  • ArmControl projenize ikinci bir arm_motor.spin_for()komutu ekleyin; böylece kol 90 dereceye kadar yükselir, 2 saniye bekler ve sonra tekrar aşağı iner.
    • İpucu:Komut içerisinde yönü değiştirmeniz gerekecektir.
  • waitkomutu çalışırken kolun pozisyonunu koruduğuna dikkat edin. Motor, kolu yer çekimine karşı tutmak için aküden güç alır. Bunun nedeni, motorun durdurulması için varsayılan ayarıntutayarı olmasıdır. Durdurma için iki ayar daha var -frenveserbest sürüş. Bunları başka bir laboratuvarda öğreneceksiniz.

Teacher Toolbox icon Teacher Toolbox - Solution

The solution to the challenge is below. To lower the arm, students needed to change the “FORWARD” parameter to “REVERSE” in the arm_motor.spin_for() command that was added.

# Begin project code
arm_motor.set_position(0, DEGREES)
arm_motor.spin_for(FORWARD, 90, DEGREES)
wait(2, SECONDS)
arm_motor.spin_for(REVERSE, 90, DEGREES)

Adım 5: Uçuş Trafik Kontrolörü Mücadelesini Tamamlayın

V5 Clawbot'un kolu yukarı kaldırılmış ve altındaki oklar yukarı ve aşağı hareketi gösteriyor.

V5 Clawbot'un kolunun yukarı ve aşağıyı gösteren kırmızı oklarla kaldırılmış halinin görüntüsü, Clawbot'un kolunu nasıl kaldırabildiğini ve indirebildiğini gösteriyor Uçuş Trafik Kontrolörü Mücadelesinde, Clawbot kolunu bir kez 90 derece yukarı aşağı hareket ettirmeli, 3 saniye beklemeli, kolunu iki kez 45 derece yukarı aşağı hareket ettirmeli, 5 saniye beklemeli ve ardından kolunu üç kez 90 derece yukarı aşağı hareket ettirmeli.

İşte Pençebot'un davranışlarının listesi:

  • Kolunuzu 90 derece yukarı ve aşağı hareket ettirin.
  • 3 saniye bekleyin.
  • Kolunuzu 45 derece yukarı ve aşağı hareket ettirin.
  • Kolunuzu 45 derece yukarı ve aşağı hareket ettirin.
  • 5 saniye bekleyin.
  • Kolunuzu 90 derece yukarı ve aşağı hareket ettirin.
  • Kolunuzu 90 derece yukarı ve aşağı hareket ettirin.
  • Kolunuzu 90 derece yukarı ve aşağı hareket ettirin.

Teacher Toolbox icon Teacher Toolbox - Solution

Most of the commands within this challenge are arm_motor.spin_for(). After adding a command for moving the arm upward, and one for moving the arm downward, you can highlight the two commands, right-click, and then choose to copy and paste them as many times as needed. Then the parameters can be changed to meet the challenge and wait commands can be added between.VEXcode V5 Python project in the workspace with two spin for blocks highlighted and the context menu open to the right. The Copy option in the context menu is highlighted. Copy appears between Cut and Paste.

  • Review an example Flight Traffic Controller Challenge solution here: 
# Begin project code
arm_motor.set_position(0, DEGREES)
arm_motor.spin_for(FORWARD, 90, DEGREES)
arm_motor.spin_for(REVERSE, 90, DEGREES)
wait(3, SECONDS)
arm_motor.spin_for(FORWARD, 45, DEGREES)
arm_motor.spin_for(REVERSE, 45, DEGREES)
arm_motor.spin_for(FORWARD, 45, DEGREES)
arm_motor.spin_for(REVERSE, 45, DEGREES)
wait(5, SECONDS)
arm_motor.spin_for(FORWARD, 90, DEGREES)
arm_motor.spin_for(REVERSE, 90, DEGREES)
arm_motor.spin_for(FORWARD, 90, DEGREES)
arm_motor.spin_for(REVERSE, 90, DEGREES)
arm_motor.spin_for(FORWARD, 90, DEGREES)
arm_motor.spin_for(REVERSE, 90, DEGREES)

More advanced students might use loops to simplify the solution.

# Begin project code
arm_motor.set_position(0, DEGREES)
arm_motor.spin_for(FORWARD, 90, DEGREES)
arm_motor.spin_for(REVERSE, 90, DEGREES)
wait(3, SECONDS)
for repeat_count in range(2): 
    arm_motor.spin_for(FORWARD, 45, DEGREES)
    arm_motor.spin_for(REVERSE, 45, DEGREES)
wait(5, SECONDS)
for repeat_count in range(3):
    arm_motor.spin_for(FORWARD, 90, DEGREES)
    arm_motor.spin_for(REVERSE, 90, DEGREES)