Objective
This tutorial is more of a presentation to show how to go from a robot design to a CrcDuino code capable of performing sequential actions. The relatable and simple example used is based on the 2020-11-23 webinar on Autonomous robot design.
Note |
---|
Before looking at tutorial 11, watch the Autonomous Robot Design Webinar. |
...
Objectif
Ce tutoriel est plutôt une présentation qui sert à vous montrer comment partir d’un concept de robot à un code CRCduino capable d’exécuter des actions séquentielles. L’exemple simple et typique qui est utilisé est basé sur le webinaire du 2020-11-23 sur la conception de robots autonomes.
Note |
---|
Avant de regarder le tutoriel 11, allez écouter le webinaire sur la conception de robots autonomes. |
Diagrames
View file | ||
---|---|---|
|
...
Présentation vidéo
...
Code
Download the Arduino IDE .ino fileTéléchargez le code de démonstration:
View file | ||
---|---|---|
|
This is a transcript of the codeQui est ici retranscrit:
Code Block | ||
---|---|---|
| ||
//*************************************************************************** // ThisCe code accompanies the Cereal box example in theaccompagne l'exemple boite à céréale du webinaire du 2020-11-23 sur Robotla conception Designde Webinarrobot //*************************************************************************** #include <CrcLib.h> //Step managementvariables variabled'état declaration bool step0etape0 = LOWfalse; bool step1etape1 = LOWfalse; bool step2etape2 = LOWfalse; bool step3etape3 = LOWfalse; bool step4etape4 = LOWfalse; bool step5etape5 = LOWfalse; bool step6etape6 = LOWfalse; //*************************************************************************** void setup() { CrcLib::Initialize(); //We Nous wantsouhaitons toetre beà inl'étape step00 uponau startupdémarrage step0etape0 = HIGHtrue; step1etape1 = LOWfalse; step2etape2 = LOWfalse; step3etape3 = LOWfalse; step4etape4 = LOWfalse; step5etape5 = LOWfalse; step6etape6 = LOWfalse; } //*************************************************************************** void loop() { CrcLib::Update(); //------------------ if if(step0 == HIGH) { (etape0) { //The actionLes youactions wantque tonous executesouhaitons duringeffectuer step0à goesl'étape here0 // "DO NOTHING"RIEN ifif ( true ) { // ReplaceÀ "true"remplacer bypar thela condition representingaprès transitionlaquelle 0-1transitioner à l'étape 1 { //...we// On change thed'état stepscourant configuration to take another if() statement during the next scans step0 = LOW; step1 = HIGH; step2 = LOW; step3 = LOW; step4 = LOW; step5 = LOW; step6 = LOW; etape0 = false; etape1 = true; etape2 = false; etape3 = false; etape4 = false; etape5 = false; etape6 = false; } } //------------------ if if(step1 == HIGH) { (etape1) { //The actionLes youactions wantque tonous executesouhaitons duringeffectuer step1à goesl'étape here1 ifif ( true ) { // ReplaceÀ "true"remplacer bypar thela condition representingaprès transitionlaquelle 1-2transitioner à l'étape 2 { //...we On change thed'état stepscourant configuration to take another if() statement during the next scans step0 = LOW; step1 etape0 = false; etape1 = LOWfalse; step2etape2 = HIGHtrue; step3etape3 = LOWfalse; step4etape4 = LOWfalse; step5etape5 = LOWfalse; step6etape6 = LOWfalse; } } //------------------ if if(step2 == HIGH) { (etape2) { //The actionLes youactions wantque tonous executesouhaitons duringeffectuer step2à goesl'étape here2 ifif ( true ) { // ReplaceÀ "true"remplacer bypar thela condition representingaprès transitionlaquelle 2-3transitioner à l'étape 3 { //...we On change thed'état stepscourant configuration to take another branch ( if() statement ) during the next scans step0 = LOW; step1 = LOW; step2 = LOW; step3 = HIGH; step4 = LOW; step5 = LOW; step6 = LOW; etape0 = false; etape1 = false; etape2 = false; etape3 = true; etape4 = false; etape5 = false; etape6 = false; } } //------------------ // // Et ainsi de suite pour //And so on for Step les étapes 3, 4, andet 5 // //------------------ if(step6 == HIGH) { if (etape6) { //Do nothingLes inactions Stepque 6nous souhaitons effectuer à l'étape 6 //We want to stay here forever (until the CrcDuino is shut down), so don't update memory } L'étape finale, on reste ici jusqu'à ce que le CRCduino soit éteint, alors on ne met pas à jour l'état } } |