Skip to content

Commit

Permalink
Merge pull request #26 from CleoQc/master
Browse files Browse the repository at this point in the history
Non blocking line follower and light follower. Expose parameters in Javascript
  • Loading branch information
CleoQc authored Dec 10, 2018
2 parents bc3a17a + 80b1b65 commit fc5d7e8
Show file tree
Hide file tree
Showing 7 changed files with 331 additions and 238 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,17 @@ gigglebot.setSpeed(gigglebotWhichMotor.Both, gigglebotWhichSpeed.Slowest)
```

### Following a line #linefollow
The GiggleBot comes with two line sensors that allows it to follow either a thick line or a thin line. The thick line is thick enough that both sensors will attempt to be over the line , while the thin line is thin enough to fit between the two sensors,and each sensor will attempt to avoid the line.
The GiggleBot comes with two line sensors that allows it to follow either a thick line or a thin line. The thick line is thick enough that both sensors will attempt to be over the line, while the thin line is thin enough to fit between the two sensors and each sensor will attempt to avoid the line.

```blocks
gigglebot.lineFollow(gigglebotLineType.Thick)
input.onButtonPressed(Button.A, function () {
gigglebot.lineFollow(gigglebotLineType.Thick)
})
```

### Reading the line sensors #linereadsensor

You can also access the line sensors values directly. This allows you to write a line follower logic that is tailored to your specific needs.
You can also access the line sensors values directly by using the blocks under the "more..." section. This allows you to write a line follower logic that is tailored to your specific needs.

```blocks
basic.showNumber(gigglebot.lineReadSensor(gigglebotWhichTurnDirection.Right))
Expand All @@ -97,19 +99,20 @@ basic.forever(() => {

### Following a light #lightfollow

The GiggleBot comes with two light sensors that allows it to follow a spotlight, a little bit like a cat would. Shining a flashlight onto one eye will get the GiggleBot to turn in that direction. You need to put this block in a loop. You may use a forever loop or one where you control the end condition. Make sure you stop the robot when exiting the loop!
The GiggleBot comes with two light sensors that allows it to follow a spotlight, a little bit like a cat would. Shining a flashlight onto one eye will get the GiggleBot to turn in that direction. The robot will go straight if the two sides receive similar lighting conditions.
```blocks
input.onButtonPressed(Button.A, () => {
while (!(input.buttonIsPressed(Button.B))) {
gigglebot.lightFollow()
}
input.onButtonPressed(Button.A, function () {
gigglebot.lightFollow()
})
input.onButtonPressed(Button.B, function () {
gigglebot.stop()
})
```

### Reading the light sensor values #lightreadsensor

You can also read the light sensors values directly in order to implement a different behaviour, like having the GiggleBot fall asleep when it gets dark, and wake up when there's light.
You can also read the light sensors values directly in order to implement a different behaviour, like having the GiggleBot fall asleep when it gets dark, and wake up when there's light. The light sensor reading block can be found under the "more..." section.

```blocks
basic.forever(() => {
Expand Down
111 changes: 60 additions & 51 deletions _locales/fr/gigglebot-jsdoc-strings.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,61 @@
{
"gigglebot": "Custom blocks",
"gigglebot.distanceSensorReadRangeContinuous": "Get a reading of how far an obstacle is from the distanse sensor.",
"gigglebot.distanceSensorReadRangeSingle": "Distance Sensor: takes a single reading.",
"gigglebot.distanceSensorTestForObstacle": "Test for the presence of an obstacle.",
"gigglebot.distanceSensorTestForObstacle|param|dist": "how many millimeters; eg: 100",
"gigglebot.distanceSensorTestForObstacle|param|inequality": "less than or more than, closer than or farther than",
"gigglebot.driveMillisec": "Will let gigglebot move forward or backward for a number of milliseconds.\nDistance covered during that time is related to the freshness of the batteries.",
"gigglebot.driveMillisec|param|delay": "for how many milliseconds; eg: 1000",
"gigglebot.driveMillisec|param|dir": "forward or backward; ",
"gigglebot.driveStraight": "Will let gigglebot move forward or backward until told otherwise (either by a stop block or a turn block).",
"gigglebot.driveStraight|param|dir": "forward or backward",
"gigglebot.followThinLine": "This code allows the Gigglebot to follow a line thin enough to fall between the two sensors. \nThe robot will stop when both of its sensors will detect black.",
"gigglebot.gigglebotSpin": "Gigglebot will spin on itself until told otherwise, like a turn but staying in the same spot. Especially useful when drawing.",
"gigglebot.gigglebotSpinMillisec": "Gigglebot will spin on itself for the provided number of milliseconds, like a turn but staying in the same spot. Especially useful when drawing",
"gigglebot.gigglebotSpinMillisec|param|delay": "how many milliseconds; eg: 1000",
"gigglebot.gigglebotSpinMillisec|param|turn_dir": "turning left or right",
"gigglebot.gigglebotSpin|param|turn_dir": "left or right;",
"gigglebot.leftPower": "return current power setting of the left motor",
"gigglebot.lightFollow": "Will follow a spotlight shone on its eyes. If the spotlight disappears the gigglebot will stop.",
"gigglebot.lightReadSensor": "Reads left or right light sensor. \nThe light sensors are placed in front of each eye neopixel, they're tiny! \nThe range is 0 through 1023, although in reality rarely above ~950.",
"gigglebot.lightReadSensor|param|which": "left or right",
"gigglebot.lineFollow": "A thin black line would fall between the two sensors. The gigglebot will stop when both sensors are reading black.\nA thick black line would have the two sensors on top of it at all times. The gigglebot will stop when both sensors are reading white.",
"gigglebot.lineFollow|param|type_of_line": "thin line or thick line",
"gigglebot.lineReadSensor": "Reads left or right line sensor",
"gigglebot.lineReadSensor|param|which": "left or right",
"gigglebot.lineSensorsRaw": "Reads the two line sensors",
"gigglebot.lineTest": "Will return true if the whole line sensor is reading either black or white.\n@param color: black or white",
"gigglebot.motorPowerAssign": "Assigns power to a motor, or the same power to both motors\nValues from 101 through 127, and -128 through -101 are used to float the motor.\n@param motor: left or right motor, or both\n@param power: a value between -100 and 100",
"gigglebot.motorPowerAssignBoth": "Assigns potentially different powers to both motors in one call. \nValues from 101 through 127, and -128 through -101 are used to float the motor.\n@param left_power: the power to assign to the left motor (between -100 and 100)\n@param right_power: the power to assign to the right motor (between -100 and 100)",
"gigglebot.motorTrimSet": "This allows the user to correct the motors on the Gigglebot if it's not driving straight\n@param dir: if the gigglebot drives to the left, then correct to the right. Vice versa. \n@param trim_value: a correction value between 0 and 100, but most likely below 10",
"gigglebot.rightPower": "return current power setting of the right motor",
"gigglebot.setLeftPower": "Assigns a new power value to the left motor\nValues from 101 through 127, and -128 through -101 are used to float the motor.",
"gigglebot.setLeftPower|param|leftpower": "new value for the power setting of the left motor (-100 < leftpower < 100)",
"gigglebot.setRightPower": "Assigns a new power value to the right motor\nValues from 101 through 127, and -128 through -101 are used to float the motor.",
"gigglebot.setRightPower|param|rightpower": "new value for the power setting of the right motor. (-100 < rightpower < 100)",
"gigglebot.setSpeed": "You can set the speed for each individual motor or both together. The higher the speed the less control the robot has.\nYou may need to correct the robot (see block in \"more...\" section). A faster robot needs more correction than a slower one.\nIf you want to follow a line, it will work best at a lower speed.\nActual speed is dependent on the freshness of the batteries.\n@param motor: left, right or both motors\n@param speed: how fast the robot goes.",
"gigglebot.steer": "Gigglebot will drive forward while steering to one side. \nUseful when it needs to go around an obstacle, or orbit around an object.\n0% means no steering, the same as the 'drive' block. 100% is the same as the 'turn' block.",
"gigglebot.steerMillisec": "Gigglebot will drive forward while steering to one side for the provided number of milliseconds. \nUseful when it needs to go around an obstacle, or orbit around an object.\n0% means no steering, the same as the 'drive' block. 100% is the same as the 'turn' block.",
"gigglebot.steerMillisec|param|delay": "for how many milliseconds; eg: 1000",
"gigglebot.steerMillisec|param|dir": "which direction to steer, left or right",
"gigglebot.steerMillisec|param|percent": "the variation in power between left and right; eg: 0, 20, 50, 100",
"gigglebot.steer|param|dir": "to the left or to the right",
"gigglebot.steer|param|percent": "value between 0 and 100 to control the amount of steering",
"gigglebot.stop": "stops the robot.",
"gigglebot.turn": "Will make gigglebot turn left or right until told otherwise (by a stop block or a drive block).",
"gigglebot.turnMillisec": "Will make gigglebot turn left and right for a number of milliseconds. How far it turns depends on the freshness of the batteries.",
"gigglebot.turnMillisec|param|delay": "for how many milliseconds; eg: 1000",
"gigglebot.turnMillisec|param|turn_dir": "turning left or right",
"gigglebot.voltageShow": "Displays the current battery voltage. Anything lower than 3.4 is too low to run the motors",
"gigglebotWhichUniqueMotor": "Use this file to define custom functions and blocks.\nRead more at https://makecode.microbit.org/blocks/custom"
}
"gigglebot": "blocs",
"gigglebot.distanceSensorReadRangeContinuous": "Prendre une lecture de la distance jusqu'à l'obstacle",
"gigglebot.distanceSensorReadRangeSingle": "Prendre une lecture simple de la distance",
"gigglebot.distanceSensorTestForObstacle": "Tester la présence d'un obstacle",
"gigglebot.distanceSensorTestForObstacle|param|dist": "combien de millimètres; eg: 100",
"gigglebot.distanceSensorTestForObstacle|param|inequality": "moins que ou plus que, plus proche que ou plus loin que",
"gigglebot.driveMillisec": "Le GiggleBot avancera ou reculera pendant un certain nombre de millisecondes\nLa distance parcourue pendant ce temps dépend de la puissance des batteries.",
"gigglebot.driveMillisec|param|delay": "pendant combien de millisecondes; eg: 1000",
"gigglebot.driveMillisec|param|dir": "avancer ou reculer",
"gigglebot.driveStraight": "Le GiggleBot avancera ou reculera jusqu'à ordre contraire (soit par un bloc Arrêt ou un autre bloc).",
"gigglebot.driveStraight|param|dir": "avancer ou reculer",
"gigglebot.gigglebotSpin": "Le GiggleBot pivotera sur lui-même jusqu'à ordre contraire, en restant sur place. Particulièrement utile pour dessiner.",
"gigglebot.gigglebotSpin|param|turn_dir": "vers la gauche ou vers la droite;",
"gigglebot.leftPower": "la puissance du moteur de gauche",
"gigglebot.lightFollow": "Le GiggleBot ira vers la lumière. Si le robot se retrouve dans le noir, il arrêtera.",
"gigglebot.lightFollowStatus": "Vrai si le robot est présentement en train de suivre une lumière.\r\nFaux autrement.",
"gigglebot.lightFollow|param|light_threshold": "la quantité de luminosité requise pour considérer que le GigleBot est dans le noir, par exemple s'il est emprisonné dans une boîte; eg: 10",
"gigglebot.lightFollow|param|mode": "suivre ou éviter la lumière",
"gigglebot.lightFollow|param|sensitivity": "la différence requise entre les deux capteurs de lumière pour faire tourner le GiggleBot; eg: 20",
"gigglebot.lightReadSensor": "Lire le capteur de lumière de gauche ou de droite. \nLes capteurs de lumière sont situés juste en avant des yeux, ils sont tout petits!\nLes valeurs vont de 0 à 1023, en réalité rarement plus que ~950.",
"gigglebot.lightReadSensor|param|which": "gauche ou droite",
"gigglebot.lineFollow": "Une ligne mince passera entre les deux capteurs et le GiggleBot arrêtera lorsque les deux capteurs détecteront du noir.\nUne large ligne noire sera plus large que la distance entre les deux capteurs. Le GiggleBot arrêtera lorsque les deux capteurs détecteront du blanc.",
"gigglebot.lineFollowStatus": "Vrai lorsque le robot suit une ligne.\r\nFaux autrement.",
"gigglebot.lineFollow|param|specific_line_threshold": "modifie la valeur par défaut du seuil de détection d'une ligne pour une meilleure adaptation à l'environnement du GiggleBot.",
"gigglebot.lineFollow|param|type_of_line": "ligne large ou mince.",
"gigglebot.lineReadSensor": "Lit le capteur de gauche ou de droite.",
"gigglebot.lineReadSensor|param|which": "gauche ou droite",
"gigglebot.lineSensorsRaw": "Lit les deux capteurs",
"gigglebot.lineTest": "Vrai si les deux capteurs détectent soit du noir, soit du blanc.\n@param color: noir ou blanc",
"gigglebot.motorPowerAssign": "Assigne une puissance à un moteur, ou la même puissance aux deux moteurs\nLes valeurs possibles vont de 101 à 127, et les valeurs de -128 à -101 sont utilisés pour laisser le moteur aller sur son élan.\n@param motor: moteur de gauche ou de droite, ou les deux\n@param power: une valeur entre -100 et 100",
"gigglebot.motorPowerAssignBoth": "Assigne de nouvelles puissances potentiellement différentes aux deux moteurs en un seul bloc. \nValues from 101 through 127, and -128 through -101 are used to float the motor.\n@param left_power: la puissance du moteur de gauche (entre -100 et 100)\n@param right_power: la puissance du moteur de droite (entre -100 et 100)",
"gigglebot.motorTrimSet": "Permet de corriger les moteurs lorsque le GiggleBot ne se déplace pas en ligne droite.\r\n@param dir: si le GiggleBot dévie vers la gauche, corriger vers la droite ou vice versa. \r\n@param trim_value: une valeur de correction entre 0 et 100, probablement en deça de 10",
"gigglebot.rightPower": "la valeur courante de la puissance du moteur de droite",
"gigglebot.servoMove": "Positionne un servomoteur à une position précise spéficiée en degrés",
"gigglebot.servoMove|param|degree": "quelle position, de 0 à 180 degrés",
"gigglebot.servoMove|param|which": "servomoteur de gauche ou de droite",
"gigglebot.setLeftPower": "Assigne une puissance au moteur de gauche\nLes valeurs possibles vont de 101 à 127, et les valeurs de -128 à -101 sont utilisés pour laisser le moteur aller sur son élan.\n@param motor: moteur de gauche ou de droite, ou les deux\n@param power: une valeur entre -100 et 100",
"gigglebot.setLeftPower|param|leftpower": "nouvelle valeur de la puissance du moteur de gauche (-100 < leftpower < 100). Les valeurs de 101 à 127 ou de -128 à -101 privent le moteur de sa puissance.",
"gigglebot.setLineFollowerThreshold": "Une méthode purement Javascript permettant de changer le seuil de réponse du détecteur de ligne.",
"gigglebot.setRightPower": "Assigne une puissance au moteur de droite\nLes valeurs possibles vont de 101 à 127, et les valeurs de -128 à -101 sont utilisés pour laisser le moteur aller sur son élan.\n@param motor: moteur de gauche ou de droite, ou les deux\n@param power: une valeur entre -100 et 100",
"gigglebot.setRightPower|param|rightpower": "nouvelle valeur de la puissance du moteur de droite (-100 < leftpower < 100). Les valeurs de 101 à 127 ou de -128 à -101 privent le moteur de sa puissance.",
"gigglebot.setSpeed": "Ajuster la vitesse de chacun des moteurs, ou les deux en même temps. Plus le GiggleBot va vite, moins il sera précis.\nIl est possible que les moteurs aient besoin d'être corrigés avec le bloc correspondant. Plus le GiggleBot est rapide plus il aura besoin de correction\nPour suivre une ligne il est préférable d'y aller à vitesse lente.\nLa vitesse dépend de la puissance des batteries.\n@param motor: gauche, droite, ou les deux\n@param speed: la vitesse du robot.",
"gigglebot.SpinMillisec": "Le GiggleBot pivotera sur place pendant X millisecondes, en restant sur place. Très pratique pour dessiner.",
"gigglebot.SpinMillisec|param|delay": "combien de millisecondes; eg: 1000",
"gigglebot.SpinMillisec|param|turn_dir": "tourner vers la gauche ou vers la droite",
"gigglebot.steer": "Le GiggleBot avancera en courbant vers la droite ou la gauche.\nUtile pour contourner un obstacle ou pour être en orbite autour d'un objet.\n0% indique aucune courbure et revient à avancer, 100% donne le même résultat que le bloc Tourner",
"gigglebot.steerMillisec": "Le GiggleBot avancera en courbant vers la droite ou la gauche pendant X milliseconded. \nUtile pour contourner un obstacle ou pour être en orbite autour d'un objet.\n0% indique aucune courbure et revient à avancer, 100% donne le même résultat que le bloc Tourner",
"gigglebot.steerMillisec|param|delay": "combien de millisecondes; eg: 1000",
"gigglebot.steerMillisec|param|dir": "courber vers la droite ou vers la gauche",
"gigglebot.steerMillisec|param|percent": "la différence de puissance entre le moteur gauche et le moteur droit; eg: 0, 20, 50, 100",
"gigglebot.steer|param|dir": "vers la droite ou vers la gauche",
"gigglebot.steer|param|percent": "une valeur entre 0 et 100 qui contrôle la courbe",
"gigglebot.stop": "Arrêter le robot.",
"gigglebot.turn": "Le GiggleBot tournera vers la gauche ou la droite tant qu'un autre bloc ne l'interrompe.",
"gigglebot.turnMillisec": "Le GiggleBot tournera vers la gauche ou la droite pendant X millisecondes.",
"gigglebot.turnMillisec|param|delay": "combien de millisecondes; eg: 1000",
"gigglebot.turnMillisec|param|turn_dir": "vers la gauche ou vers la droite",
"gigglebot.voltageShow": "Affiche le voltage des batteries. Moins que 3.4 indique des batteries trop faibles pour faire bouger le GiggleBot",
"gigglebotWhichUniqueMotor": ""
}
Loading

0 comments on commit fc5d7e8

Please sign in to comment.