Skip to main content

Robot Kolunun Programlanması - C++

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 text program, visit the help information.

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 keşifte kullanılacak VEXcode V5 talimatları:
    • ArmMotor.spinFor(ileri, 90,derece);
    • ArmMotor.setPosition(0, derece);
    • bekle(2, saniye);
  • Talimat hakkında daha fazla bilgi edinmek için Yardım seçin ve ardından daha fazla bilgi görmek için 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 TrainingBot 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 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 Template (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 MyProject1. MyProject1 is the default project name when VEXcode V5 is first opened. Once the project was renamed Drive 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. This article from the VEX Robotics Knowledge Base 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!

int main() {
  // Robot Yapılandırması Başlatılıyor. ÇIKARMAYIN!
  vexcodeInit();

  ArmMotor.setPosition(0, derece);

}
  • Yukarıda gösterildiği gibi programlama alanına kolun başlangıç pozisyonunu ayarlamak için ArmMotor.setPosition(); komutunu yazın.
  ArmMotor.setPosition(0, derece);
  ArmMotor.spinFor(ileri, 90, derece);
  • Yukarıda gösterildiği gibi kolu yukarı hareket ettirmek için ArmMotor.setPosition() komutunun altına ArmMotor.spinFor(); komutunu ekleyin. Spin For komutunun Set Position komutuyla eşleşecek şekilde girintili olduğundan ve tüm komutların süslü parantez içinde olduğundan emin olun.

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 simgesine tıklayın. Projenizi Robot Beyni'ndeki mevcut slotlardan birine indirebilirsiniz. 1. Yuvaya tıklayın.

VEXcode V5'teki yeşil Beyin simgesinin etrafında kırmızı bir kutu bulunan araç çubuğu. Beyin simgesi Kontrolcü simgesinin sağında ve İndir düğmesinin solundadır.

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.

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

Teacher Toolbox icon Teacher Toolbox - Help with Text

  • 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 - Option to 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 raise.

  • Clawbot'ta projeyiprojenin 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.

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

  • ArmControl projenize ikinci bir ArmMotor.spinFor(); talimatı ekleyin; böylece kol 90 dereceye kadar yükselir, 2 saniye bekler ve sonra tekrar aşağı iner.
    • İpucu:Talimat içindeki 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 ArmMotor.spinFor(); instruction that was added.

// Begin project code
int main() {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();

  ArmMotor.setPosition(0, degrees);
  ArmMotor.spinFor(forward, 90, degrees);
  wait(2,seconds);
  ArmMotor.spinFor(reverse, 90, degrees);
  
}

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

VEXcode V5 Clawbot'un kolu kaldırılmış ve kırmızı oklar yukarı ve aşağıyı gösteriyorUç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 instructions within this challenge are ArmMotor.spinFor();. After adding an instruction for moving the arm upward, and one for moving the arm downward, you can highlight the two instructions, 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(); instructions can be added between.

VEXcode V5 C++ project in the workspace with the Arm Motor set position command highlighted and the context menu open. The cursor is hovering over the Copy command in the context menu, which is the eleventh command in the list, right after Cut.

  • Flight Traffic Controller Challenge Solution: 
// Begin project code
int main() {

  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();

  ArmMotor.setPosition(0, degrees);
  ArmMotor.spinFor(forward, 90, degrees);
  ArmMotor.spinFor(reverse, 90, degrees);
  wait(3, seconds)
  ArmMotor.spinFor(forward, 45, degrees);
  ArmMotor.spinFor(reverse, 45, degrees);
  ArmMotor.spinFor(forward, 45, degrees);
  ArmMotor.spinFor(reverse, 45, degrees);
  wait(5, seconds)
  ArmMotor.spinFor(forward, 90, degrees);
  ArmMotor.spinFor(reverse, 90, degrees);
  ArmMotor.spinFor(forward, 90, degrees);
  ArmMotor.spinFor(reverse, 90, degrees);
  ArmMotor.spinFor(forward, 90, degrees);
  ArmMotor.spinFor(reverse, 90, degrees);
  
 }