Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
projektews2013:wwsr:start [2013/12/12 14:24] yuri_gbur |
projektews2013:wwsr:start [2016/01/21 12:45] (aktuell) |
||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
====== Wheelpowered, WLANcontrolled Support Robot (Florian René Beier,Konrad Yuri Gbur) ====== | ====== Wheelpowered, WLANcontrolled Support Robot (Florian René Beier,Konrad Yuri Gbur) ====== | ||
- | [[projekteWs2013:WWSR:start:Quellcodes| Quellcodes]] | ||
+ | Der WWSR ist wie der Name schon vermuten lässt ein fahrender Roboter, der sich durch seine Orientierung am WLAN auszeichnet. Wie das genau funktioniert steht in der Projektdokumentation. | ||
+ | [[projekteWs2013:WWSR:start:Quellcodes| Quellcodes]]\\ | ||
+ | [[projekteWs2013:WWSR:start:Projektdokumentation| Projektdokumentation]]\\ | ||
+ | {{:projektews2013:wwsr:robotik_projektplanung.pdf|}} | ||
- | <file C++ SimpleReceiveSoftwareSerial_Mega.ino> | + | //"Ein Roboterprogrammierer ist eine Maschine die Koffein in Programmcode umwandelt"// |
- | // How to send OSC messages from an Arduino. | + | {{:projektews2013:wwsr:ufqhpdp.jpg |}} |
- | // This Example is in the public domain. | + | |
- | + | ||
- | // Important known issues: | + | |
- | // The Wifly provides no means to get the data from a single UDP package at a time | + | |
- | // Everything is just dumped to the serial connection. | + | |
- | // The only hint that a package is finished is that reading from the serial *might* time out | + | |
- | // To make things work anyway: | + | |
- | // 1. Use a high baud rate for communication with the Wifly: 115200 on a hardware serial is perfect. | + | |
- | // 2. Adjust the timeout in server.availableCheck(). 2ms works fine with 115200baud. | + | |
- | // 3. If possible, let the controlling Program pause at least 1.5 times the timout between sending OSC messages. | + | |
- | + | ||
- | #include <WiFlyHQ.h> | + | |
- | #include <ArdOSCForWiFlyHQ.h> | + | |
- | #include <Servo.h> | + | |
- | //#include <SoftwareSerial.h> | + | |
- | //SoftwareSerial softSerial(2,3); // Rx is the recieving pin, Tx is the transmitting pin | + | |
- | + | ||
- | WiFly wifly; | + | |
- | OSCServer server(&wifly); | + | |
- | int winkel = 0; | + | |
- | int ledPin=13; | + | |
- | Servo myservo; | + | |
- | void setup() | + | |
- | { | + | |
- | myservo.attach(22); | + | |
- | myservo.write(winkel); | + | |
- | Serial.begin(115200); | + | |
- | //use the convenient setup. | + | |
- | wifly.setupForUDP<HardwareSerial>( | + | |
- | &Serial3, //the serial you want to use (this can also be a software serial) | + | |
- | 57600, // if you use a hardware serial, I would recommend the full 115200. This does not work with a software serial. | + | |
- | true, // should we try some other baudrates if the currently selected one fails? | + | |
- | "arduinonet", //Your Wifi Name (SSID) | + | |
- | "florian3", //Your Wifi Password | + | |
- | "WiFly", // Device name for identification in the network | + | |
- | 0, // IP Adress of the Wifly. if 0 (without quotes), it will use dhcp to get an ip | + | |
- | 8000, // WiFly receive port | + | |
- | "255.255.255.255", // Where to send outgoing Osc messages. "255.255.255.255" will send to all hosts in the subnet | + | |
- | 8001, // outgoing port | + | |
- | true // show debug information on Serial | + | |
- | ); | + | |
- | wifly.printStatusInfo(); //print some debug information | + | |
- | + | ||
- | pinMode(ledPin,OUTPUT); //prepare to fade th einternal LED by OSC | + | |
- | // Register a callback fuction of the LED fading. | + | |
- | // When a message is with the adress "/ard/ledFade" is received, "setLedFade" will be invoked. | + | |
- | server.addCallback("/ard/ledFade",&setLedFade); | + | |
- | wifly.startCommand(); | + | |
- | + | ||
- | } | + | |
- | + | ||
- | + | ||
- | void loop() | + | |
- | { | + | |
- | //check for new incoming messages. If a message with a registered adress is recieved, the callback function will be invoked. | + | |
- | if(server.availableCheck(2)>0) | + | |
- | { | + | |
- | //debugoutln("alive!"); //callback after process | + | |
- | } | + | |
- | Serial.println(wifly.getRSSI()); | + | |
- | if(winkel < 180){ | + | |
- | winkel++; | + | |
- | + | ||
- | } | + | |
- | if(winkel>=180){ | + | |
- | winkel=0; | + | |
- | } | + | |
- | myservo.write(winkel); | + | |
- | delay(50); | + | |
- | + | ||
- | } | + | |
- | + | ||
- | void setLedFade(OSCMessage *_mes){ | + | |
- | //get 1st argument(int32) and use it to fade the LED | + | |
- | int fadeValue=_mes->getArgInt32(0); | + | |
- | Serial.println(fadeValue); | + | |
- | analogWrite(ledPin,fadeValue ); | + | |
- | } | + | |
- | </file> | + | |
- | + | ||
- | Diesen Code hat Felix zum testen verwendet. | + | |
- | <file C++ FeliSignalStrength_Mega.ino> | + | |
- | // Shows how to set up an OSC controlled parameter using the WiFlyHQ and ArdOSCForWiFlyHQ libraries | + | |
- | // Created 2012 by Felix Bonowski. | + | |
- | // This example code is in the public domain. | + | |
- | + | ||
- | //by adding this define, we tell the compiler that we want to use the OSC functionality of the library | + | |
- | #define USE_OSC | + | |
- | // osc functionality depends on other libraries that can be found on my GitHub Page | + | |
- | #include <WiFlyHQ.h> | + | |
- | #include <ArdOSCForWiFlyHQ.h> | + | |
- | #include <ArduPar.h> | + | |
- | + | ||
- | //uncomment this to use a software serial if you dont own a MEGA | + | |
- | //#include <SoftwareSerial.h> | + | |
- | //SoftwareSerial softSerial(softSerialRx,softSerialTx); | + | |
- | + | ||
- | + | ||
- | WiFly wifly; //create an instance of a Wifly Interface | + | |
- | OSCServer oscServer(&wifly); //This will receive and parse incolming messages | + | |
- | + | ||
- | + | ||
- | // Create an integer setting that can by set via Serial and will remember its value even if the board is powered off. | + | |
- | // It needs to be setup() to be of any use. | + | |
- | IntArduPar someIntSetting; | + | |
- | + | ||
- | + | ||
- | void setup(){ | + | |
- | Serial.begin(115200); //start Serial Communication to PC | + | |
- | + | ||
- | wifly.setupForUDP<HardwareSerial>( | + | |
- | &Serial3, //the serial you want to use (this can also be a software serial) | + | |
- | 115200, // if you use a hardware serial, I would recommend the full 115200. This does not work with a software serial. | + | |
- | true, // should we try some other baudrates if the currently selected one fails? | + | |
- | "wlanName", //Your Wifi Name (SSID) | + | |
- | "wlanPasswd", //Your Wifi Password | + | |
- | "WiFly", // Device name for identification in the network | + | |
- | 0, // IP Adress of the Wifly. if 0 (without quotes), it will use dhcp to get an ip | + | |
- | 8000, // WiFly receive port | + | |
- | "255.255.255.255", // Where to send outgoing Osc messages. "255.255.255.255" will send to all hosts in the subnet | + | |
- | 8001, // outgoing port | + | |
- | true // show debug information on Serial | + | |
- | ); | + | |
- | + | ||
- | wifly.printStatusInfo(); //print some debug information | + | |
- | + | ||
- | // By defining a global Osc server for all settings, we do not have to specify it in every setup. | + | |
- | // This way, you can swith on and off osc without breaking the setup() calls in your own modules. | + | |
- | globalArduParOscServer=&oscServer; | + | |
- | + | ||
- | //we need to set up the someIntSetting to make it useful: | + | |
- | someIntSetting.setup( | + | |
- | F("/someInt"), // The command used to change the parameter. The F("blah") syntax saves memory by putting the command into flash-memory. (look up "progmem strings" if you care) | + | |
- | 0, // The lowest value the parameter can have. | + | |
- | 10 // The highest value the parameter can have. | + | |
- | ); | + | |
- | wifly.startCommand(); | + | |
- | + | ||
- | } | + | |
- | void loop(){ | + | |
- | //wifly.ping("192.168.43.139"); | + | |
- | Serial.println(wifly.getRSSI()); | + | |
- | delay(100); | + | |
- | } | + | |
- | </file> | + |