Jump to content

Rudy

Utente ItLUG
  • Contenuti

    441
  • Registrato il

  • Ultima visita

  • Vittorie

    7

Tutto il contenuto inserito da Rudy

  1. Allego il programma per Line Follower con un sensore colore (porta 3) e due motori (B e C) di Dave Parker che ho tradotto in versione NXC /* Line Follower http://www.nxtprograms.com/NXT2/line_follower/ Copyright © 2007-2011 by Dave Parker. All rights reserved. This is a "Proportional Line Follower" with automatic self-calibration, using the Color Sensor in Light Sensor mode. The robot should start with the sensor directly over the center of the line. The robot will scan the line and the surface to the right of the line to self-calibrate the light values at the beginning, then it will follow the right edge of the line. */ /* Set the Speed and Gain variables to the selected values for the robot and the course. You can adjust these (see below). The Speed and Gain variables can be used to adjust the speed and steering response of the line following. You can adjust the values of these to suit different robots and different line courses. The Speed determines the overall speed of the robot when following straight parts of the line. You can use values up to 100. Higher values will go faster but are less able to handle tight turns in the line. Lower Speed will always help the driving be smoother, more accurate, and more able to handle right turns. The Gain determines how quickly the steering responds to the sensor readings. A higher number will apply more steering correction and a lower number less correction. A higher number may make a robot able to handle tighter turns, but too high of a gain will cause more "zig zag" driving motion due to over-correction, and ultimately failing to make some turns due to crossing over to the wrong side of the line. Lower gain results in smoother and faster overall driving but less ability to make sharp turns. You can use any number for the Gain (100 is a good starting point for testing), and the best results will depend a lot on the design of the robot, including the tire diameter, left-to-right spacing of the drive wheels, gearing, power level, the distance that the sensor is ahead of the wheels, and the height that the sensor is off of the surface. */ int Speed=60; int Gain=200; task main() { /* Here starts the auto-calibration part of the program, where the robot will scan the line and surface to determine the minimum and maximum brightness values. */ /* The lamp seems to have a small delay before turning on in Light Sensor mode, which might affect the auto calibration, so turn it on now and then wait for 0.2 sec. */ SetSensorType(IN_3,SENSOR_TYPE_COLORRED); SetSensorMode(IN_3,IN_MODE_PCTFULLSCALE); ResetSensor(IN_3); Wait(200); /* Initialize the Min variable to a large value and the Max variable to 0 so that the scanning logic will always set them. */ int Min=1000; int Max=0; /* Start a slow pivot turn to the right so that the sensor can scan the line and the area to the right of the line. */ OnFwd(OUT_B,25); OnRev(OUT_C,25); /* This loop repeatedly scans for light values under the sensor while the robot is pivoting to the right, and keeps track of the Min and Max values seen. */ /* Stop the pivot turn when motor B reaches 120 degrees. */ ResetRotationCount(OUT_B); while (MotorRotationCount(OUT_B)<120) { /* Get a reading from the Color Sensor in Light Sensor mode (outputs a number 0-100 in the "Detected Color" port), and store it in the Light variable. */ int Light=Sensor(IN_3); /* If the Light value from the sensor is less than the Min value seen so far, then update the Min variable with the new lower Light value. */ if (Light<Min) Min=Light; /* If the Light value from the sensor is greater than the Max value seen so far, then update the Max variable with the new lower Light value. */ if (Light>Max) Max=Light; } Off(OUT_BC); PlaySound(SOUND_DOUBLE_BEEP); Wait(300); /* Now that we know the Min and Max light values expected from the line and the surface, calculate the magnitude of the Range of values, which is Max - Min. */ int Range=Max-Min; /* Also calculate the average (midpoint) of the Min and Max values and store it in the Mid variable, as Mid = (Max + Min) / 2. The robot will expect to see this Mid light value right at the edge of the line, which is where it seeks to follow. */ int Mid = (Max + Min) / 2; /* Since the auto-calibration pivoted the robot to the right, pivot it back to the left before starting the line following. To get a nice straight start, pivot back until the sensor sees a value just darker than Mid value, which should put the sensor exactly over the right edge of the line, which is where it wants to follow. */ OnRev(OUT_B,25); OnFwd(OUT_C,25); while(Sensor(IN_3)<Mid) ; /* When the sensor finds the edge of the line to start at, stop the pivot turn and sound a beep tone to indicate that the auto-calibration is complete. */ Off(OUT_BC); PlayTone(523,800); Wait(300); /* Here starts the Line Following part of the program. It uses the Mid and Range variables computed by the auto-calibration, and also uses the Speed and Gain variables to control the overall speed and steering response. The Forever loop will continuously calculate and apply steering correction to the two drive motors based on light readings. */ while (true) { /* Get a reading from the Color Sensor in Light Sensor mode and subtract it from the Mid variable. The result will be the "error", which represents the distance off of the edge of the line that the robot is trying to follow. If the error is positive then the robot is off to the left, with the sensor seeing too much of the line. If the error is negative then the robot is off to the right, with the sensor seeing too much of the surface. The magnitude of the error represents how far off the edge it is. Multiply the error value by the Gain value, to increase the response to error by the specified factor. Then divide by the Range of calibrated light values to normalize the error with respect to the total expected range. Store the result in the Correction variable. */ int Correction=Mid-Sensor(IN_3); Correction *= Gain; Correction /= Range; if (Correction>Speed) Correction=Speed; if (Correction<Speed) Correction=-Speed; /* Use the Correction value to apply a steering correction to the two motors. Starting with the base Speed level specified, use (Speed + Correction) for the B motor and (Speed - Correction) for the C Motor. This will cause the robot to steer in the direction necessary to get back to the edge of the line, and by an amount that is proportional to how far the robot is off of the edge. If only slightly off, only a small correction is made. This keeps the driving fast and smooth. */ OnFwd(OUT_B,Speed+Correction); OnFwd(OUT_C,Speed-Correction); } } /* See if you can improve the robot design or make a new design that will perform better (follow faster or smoother). For example, the distance that the light sensor is mounted in front of the drive wheels affects how the line following, because it changes the sensor's response to the robot's steering. Experiment with different sensor positions and see if you can get better results. This Line Follower design might be able to go faster and/or smoother if the light sensor was closer to the wheels (not so far out in front). Making the wheel track wider left to right would probably help too. When you make adjustments to the robot, experiment with different values of the Speed and Gain variables in the LineFollowPro program to adapt for it. Can you make the power higher? Does adjusting the Gain higher or lower help? The standard NXT kit comes with only one light sensor, but if you have two light sensors, then it is possible to make a different kind of line following strategy that is sometimes more reliable than with one sensor. If you have two light sensors, try placing them on either side of the line so that they both see white when the robot is centered over the line. Then an example "Five State" strategy would be: When both sensors see white (e.g. > 75%), go straight. When the left sensor sees some black (e.g. 25-75%), make a slight left turn. When the left sensor sees all black (e.g. < 25%), make a hard left turn. When the right sensor sees some black, make a slight right turn. When the right sensor sees all black, make a hard right turn. The programming will be trickier because you must test both sensors. Note that for calibration, you only need to calibrate one sensor, and this same calibration will be used for the other sensor as well. Then consider this: What would a "proportional" strategy look like for two light sensors? Translated in NXC by Rudy 2013 */
  2. Visto che mastichi meglio di noi queste cose, come faresti un programma di line follower più veloce? Sono partito da questo: http://www.nxtprograms.com/NXT2/line_follower/steps.html Riesci a costruirne uno?
  3. La cosa migliore è fare ingegneria inversa, ovvero osservarla bene e rifarla meglio. Le salite secondo me sono fatte con una quantità esagerata di liftarm da 2, collegati dagli axle gommosi.
  4. Ecco la soluzione per RCX in NQC: int speedA, __speedA; int speedC, __speedC; int delay=1; task run_motorA() { while (true) { __speedA = speedA; if (__speedA > 0) {OnFwd(OUT_A);} if (__speedA < 0) {OnRev(OUT_A); __speedA =-__speedA;} Wait(__speedA); Off(OUT_A); Wait(delay); } } task run_motorC() { while (true) { __speedC = speedC; if (__speedC > 0) {OnFwd(OUT_C);} if (__speedC < 0) {OnRev(OUT_C); __speedC =-__speedC;} Wait(__speedC); Off(OUT_C); Wait(delay); } } task main() { speed = 0; start run_motorA; start run_motorC; speedA = 1; speedC = 1; Wait(200); speedA = -10; speedC = -10; Wait(200); speedA = 5; speedC = -5; Wait(200); speedA = 0; speedC = 0; }
  5. Inizio io: Palina - Sumo - RCX - BricxCC - fermo a Vienna 2012 Hydra - Sumo -NXT - BricxCC - fermo a Vienna 2013 Testarossa 2 basato su Yastreb - Sumo -NXT - BricxCC - fermo a Vienna 2013 Qubico 2 - Sumo -RCX - BricxCC - in costruzione avanzata (buone intenzioni: sensore di prossimità usando il trasmettitore IR dell'RCX e la routine sviluppata per la lettura della luce, scartata per la breve distanza) Villico - Follower - RCX - BricxCC - costruzione completata, software in alto mare ma ora è arrivato un aiutino e mi ci metto sotto...
  6. Intanto inizio con un grosso ringraziamento a Valter per una cosa tra di noi Siamo a fine anno, il gruppo di Vienna a che punto è arrivato? In questa fase è importantissimo il lavoro di gruppo, facciamo squadra per arrivare sul podio ;D Chiedo cortesemente a chi viene a Vienna 2014 di rispondere a questo post con: - robot partecipante, specialità (Sumo o Line Follower), software impiegato - fase dello sviluppo ed eventuale richiesta d'aiuto grazie in anticipo.
  7. Ottimo lavoro di gruppo!!! Siamo grandiosi!!
  8. sul secondo va invertito il carrello motore: una locomotiva col filo verso la cabina e l'altra col filo verso i vagoni cioè tutti e due i fili nella stessa direzione del treno), oppure invertire i carrelli sulla seconda Oppure se c'è spazio aggiungi uno switch PF 8869 tra il telecomando ed il motore per invertire la direzione.
  9. I problemi generano soluzioni, e ti anticipo le mie in "pseudocodice" Abbiamo rinunciato per i seguenti motivi: - Motori RCX difficili da controllare Risposta: uso i Power Function - Potenza motori con un RANGE 0-7 che non è per nulla proporzionale Risposta: uso una routine che li rende perfettamente proporzionali (grazie Giuliano!) - impossibilità di utilizzare i numeri con la virgola (x controller PID) Risposta: i calcoli si possono tranquillamente fare con gli interi (grazie Giancarlo!) - max 3 sensori di luce Risposta: nei limiti si vede la classe, ti ricordo che al terzo posto si è classificato un RCX con solo due sensori di luce
  10. Beato te... Sto ancora lottando con il software di Villico (che sta per l'abbreviativo italianizzato di Wile Coyote) :'( Velocissimo ma debordante... per cortesia puoi pubblicare il software che provo ad adattarlo? PS: GRRR... : le immagini ridimensionate con GIMP non superano i controlli di sicurezza e Youbrick non accetta la mia password... appena posso posto le foto di Villico (RCX+PF) 8) EDIT: Ecco Villico su YouBrick
  11. Vieni a vederlo a Bologna? 8)
  12. Il grande Daniele... grazie per avere ricordato questo suo vecchio progetto. Mi sa che unisco le due, il mio selettore meccanico e l'idea di Daniele: con sei interruttori dovrebbe funzionare. A che accende C e D B che accende E ed F Motori su CDEF Domani la provo. Grazie intanto per il primo contributo PS: Preferirei fare esclusivamente con elementi LEGO: controllo motori PF
  13. Chiedo venia, serve un interruttore che accenda un solo motore scelto su quattro, comandato meccanicamente dal motore NXT Per farla semplice: ogni motore ha un interruttore, normalmente spento. Quando il motore NXT raggiunge una certa posizione l'interruttore si sposta su acceso. Esempio per due motori: Metto affiancati due degli interruttori visti sopra, collegati al pacco batterie e a due motori (A e B) Posiziono l'asse sfalsato di 90° (A acceso e B spento) Infilo un assale per farli ruotare insieme Quando ruoto l'assale, spengo A e B si accende e viceversa La rotazione dell'assale posso controllarla con il motore NXT che ha il sensore di rotazione Ma con quattro motori (quindi quattro interruttori) che faccio? Spero di essermi spiegato meglio PS: Grazie GianCann ma la soluzione meccanica l'abbiamo dovuta scartare. Questa è migliore della mia comunque!
  14. Dopo la gita in Danimarca, a Claudio è venuta un'idea pazzerella, ed ha trovato in me chi gli ha dato corda... Siamo alla fase di progettazione di una gru per container, basata sulla Barman's Container Crane (si trova sul sito http://jurgenstechniccorner.com/instructies.html) solo che la vogliamo fare con l'NXT... In questo momento abbiamo un problema e chiediamo un aiuto per risolverlo: come possiamo fare un multiplexer LEGO per i motori? La prima soluzione completamente meccanica è quella di usare il pezzo del cambio che allego sotto, ma l'abbiamo scartata perchè introduce troppe complicazioni. Ora stiamo cercando una soluzione basata su una serie di interruttori, ovvero un interruttore rotante a quattro posizioni che permetta di accendere solo un motore alla volta, magari usando questi: Questi interruttori se l'asse è orizzontale sono spenti, quando è verticale sono accesi (rotazione di 90°) Con due è semplice, si mettono sfalsati di 90° e quando uno è acceso l'altro è spento e viceversa, ma con quattro come si può fare? Grazie in anticipo per le idee.
  15. Cavoli, che grande!! ??? Quando ne abbiamo parlato pensavo che te la potessi cavare con una decina di viti senza fine, ma non pensavo ad una cosa così imponente!! I miei complimenti vivissimi, una MOC davvero degna di nota... e per di più funzionante!!!
  16. Grazie Biffuz per la sovrastima delle mie capacità ma la cosa più interessante del video è che spesso tocca avere il coraggio di smontare quasi tutto per avere degli ottimi risultati! PS: Sto lavorando al contapalline, intanto ti ho spedito il mulino
  17. Rudy

    Novità 2014

    Sono furbi: per il piano aggiuntivo acquisti un altro modulare...
  18. Ho visto lo stesso team di sviluppo avere grosse difficoltà con questo software... qui lo dico e qui lo nego: Voci di corridoio dicono che ci siano grosse tensioni tra settore Education e Retail, che hanno esigenze del tutto opposte. Siccome sviluppare un software decente costa una follia, il risultato è una soluzione di compromesso che scontenta entrambi in egual modo e che possa essere usato sia dallo studente che si farebbe male imparando un linguaggio testuale che dal ragazzino che vuole solo videogiochi. Inoltre ci sono direttive secondo cui il brick dovrebbe venire programmato esclusivamente nel suo linguaggio proprietario, per questo scoraggiano lo sviluppo di software alternativo limitando al minimo le indiscrezioni sulle specifiche tecniche. Per il resto confermo che dentro ci hanno messo un cellulare con la sua versione di Linux. Si accende con calma perchè il suo firmware è compresso: per caricare ogni driver deve prima decomprimerlo La cosa buona è che se si mette un sistema operativo sulla schedina il brick fa il boot da quella senza bisogno di cambiare il firmware. Per spegnerlo più velocemente, se non si sono caricati nuovi programmi dall'ultimo spegnimento basta togliere le batterie (durante lo spegnimento fa la compressione dei nuovi dati) Per resettarlo, CTRL+ALT+CANC: si premono insieme i tre pulsanti, hanno tolto il reset hardware.
  19. Oltre ad eliminare i titoli di testa, ho un tip interessante: Nella cartella EV3 (di solito C:\Program Files (x86)\LEGO Software\LEGO MINDSTORMS EV3 Home Edition) aprire la cartella Resources, poi Blocks ed infine LEGO. Aprire con il blocco note il file blocks.xml Cambiare le righe <Flags>EducationOnly</Flags> in <Flags></Flags> nella descrizione dei blocchi extra Vengono aggiunti i blocchi per usare i sensori: Giroscopio Temperatura Ultrasonico EnergyMeter Suono Datalogging Quello che mi interessa è che può usare l'ultrasonico dell'NXT.
  20. Rudy

    MOC: Curiosity

    L'hanno già copiato... che velocità!!! E pure in Unity! http://www.lego.com/it-it/mindstorms/funzone/fixthefactory/ Mi spiace solo che Sabran non abbia ricevuto alcun riconoscimento per l'idea del gioco.
  21. Giusto per rimettere il discorso sul giusto binario - A casa si può fare quello che si vuole (PF, EV3 in WiFi, ... ) e soprattutto la consolle di comando che è il sogno di tutti i ferrovieri (che ovviamente richiede che ci sia costantemente una persona attaccata) - Ad un evento, dove il tracciato diventa multiutente, la sorveglianza deve essere necessariamente ridotta al minimo e ci sono interferenze sui PF le cose sono radicalmente diverse. Premesso questo, i moduli indipendenti sono la strada giusta. Per calcolare la lunghezza del treno secondo me basta aspettare che il sensore torni libero per 2 secondi (programma NQC): task main() { // setta il sensore porta 1 come luce SetSensorType(SENSOR_1,SENSOR_TYPE_LIGHT); SetSensorMode(SENSOR_1,SENSOR_MODE_RAW); // legge il sensore luce per la taratura int taratura = SENSOR_1; int luce=SENSOR_1; int soglia=100; int tempo=Timer(0); while (true) { // aspetta che arrivi il treno e fa la taratura del sensore luce=SENSOR_1; until (luce>(taratura+soglia)) { luce=SENSOR_1; // regolazione automatica della soglia per la luce // varia con la luce ambiente e le macchine fotografiche in giro taratura++; if (luce<taratura) taratura=luce; } // adesso il treno è arrivato: fa qualcosa // aspetta che il treno vada via dal sensore tempo=Timer(0)+2; until (tempo<Timer(0) { // aumenta il tempo se passa un vagone if (SENSOR_1<(taratura)) tempo=Timer(0)+2; } // adesso il treno è passato: fa qualcosa } } PS: non l'ho testato, sono sul lavoro mi potete dire se funziona?
  22. Ecco una foto di quattro pezzi buttati su per illustrare il meccanismo
  23. In una MOC ho visto uno sterzo che faceva lampeggiare le luci tramite un interrruttore: il motore faceva ruotare lo sterzo con una demoltiplica con l'ingranaggio bianco (frizione) Nel contempo sull'asse del motore c'era una vite senza fine che poteva scorrere La vite senza fine si ingranava a seconda del senso di marcia su due ingranaggi di quelli piccoli Ogni ingranaggio piccolo faceva girare una biella collegata all'interruttore. In questa maniera sterzando a destra il motore gira facendo andare a fondo corsa lo sterzo. Nel frattempo la vite senza fine scorre fino ad ingranare il primo ingranaggio. L'ingranaggio comincia a far girare la biella che muove avanti ed indietro l'interruttore. Con un elastico l'interruttore tende a tornare nella posizione di spento quando fermi tutto. Spero di essermi spiegato e che ti sia utile
  24. Ho recuperato l'adattatore seriale ed aggiornato il post precedente per i neofiti. Buon gioco! ;D
  25. Non puoi... è proprio lui!! Uguale!!! complimenti per la dinamicità della posa e l'espressione che riesci a dare!! Si vede che adesso hai più tempo per la tua passione
×
×
  • Crea nuovo...