Gruppe 3 / Mbed 2 deprecated PES1

Dependencies:   Servo mbed pixy

Fork of PES by Gruppe 3

Files at this revision

API Documentation at this revision

Comitter:
itslinear
Date:
Tue Mar 21 12:42:01 2017 +0000
Child:
1:4e84271a70c6
Commit message:
hoiii

Changed in this revision

IRSensor.cpp Show annotated file Show diff for this revision Revisions of this file
IRSensor.h Show annotated file Show diff for this revision Revisions of this file
Kamera.cpp Show annotated file Show diff for this revision Revisions of this file
Kamera.h Show annotated file Show diff for this revision Revisions of this file
Motoren.cpp Show annotated file Show diff for this revision Revisions of this file
Motoren.h Show annotated file Show diff for this revision Revisions of this file
Roboter.cpp Show annotated file Show diff for this revision Revisions of this file
Roboter.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/IRSensor.cpp	Tue Mar 21 12:42:01 2017 +0000
@@ -0,0 +1,61 @@
+#include <cmath>
+#include "IRSensor.h"
+
+
+/**
+ * Creates an IRSensor object.
+ * @param distance an analog input object to read the voltage of the sensor.
+ * @param bit0 a digital output to set the first bit of the multiplexer.
+ * @param bit1 a digital output to set the second bit of the multiplexer.
+ * @param bit2 a digital output to set the third bit of the multiplexer.
+ * @param number the number of the sensor, either 0, 1, 2, 3, 4 or 5.
+ */
+IRSensor::IRSensor(AnalogIn* distance, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, int number)
+{
+    init(distance, bit0, bit1, bit2, number);
+}
+
+
+IRSensor::IRSensor()
+{
+}
+
+void IRSensor::init(AnalogIn* distance, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, int number)
+{
+
+    this->distance = distance;  // set local references to objects
+    this->bit0 = bit0;
+    this->bit1 = bit1;
+    this->bit2 = bit2;
+
+    this->number = number;
+}
+
+
+/**
+ * Deletes the IRSensor object.
+ */
+IRSensor::~IRSensor() {}
+
+/**
+ * Gets the distance measured with the IR sensor in [m].
+ * @return the distance, given in [m].
+ */
+float IRSensor::read()
+{
+    *bit0 = (number >> 0) & 1;
+    *bit1 = (number >> 1) & 1;
+    *bit2 = (number >> 2) & 1;
+
+    float d = -0.38f*sqrt(distance->read())+0.38f;  // calculate the distance in [m]
+    return d;
+}
+
+/**
+ * The empty operator is a shorthand notation of the <code>read()</code> method.
+ */
+IRSensor::operator float()
+{
+
+    return read();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/IRSensor.h	Tue Mar 21 12:42:01 2017 +0000
@@ -0,0 +1,34 @@
+#ifndef IR_SENSOR_H_
+#define IR_SENSOR_H_
+
+#include <cstdlib>
+#include <mbed.h>
+
+/**
+ * This is a device driver class to read the distance measured with a Sharp IR sensor.
+ */
+class IRSensor
+{
+
+public:
+
+    IRSensor(AnalogIn* distance, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, int number);
+    IRSensor();
+    
+    void        init(AnalogIn* distance, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, int number);
+    virtual     ~IRSensor();
+    float       read();
+
+    operator float();
+
+private:
+
+    AnalogIn*       distance;
+    DigitalOut*     bit0;
+    DigitalOut*     bit1;
+    DigitalOut*     bit2;
+
+    int             number;
+};
+
+#endif /* IR_SENSOR_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Kamera.cpp	Tue Mar 21 12:42:01 2017 +0000
@@ -0,0 +1,3 @@
+
+
+#include "Kamera.h"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Kamera.h	Tue Mar 21 12:42:01 2017 +0000
@@ -0,0 +1,22 @@
+#ifndef KAMERA_H
+#define KAMERA_H
+
+#include <mbed.h>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#endif 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motoren.cpp	Tue Mar 21 12:42:01 2017 +0000
@@ -0,0 +1,1 @@
+#include "Motoren.h"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motoren.h	Tue Mar 21 12:42:01 2017 +0000
@@ -0,0 +1,26 @@
+#ifndef MOTOREN_H
+#define MOTOREN_H
+
+#include <mbed.h>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#endif 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Roboter.cpp	Tue Mar 21 12:42:01 2017 +0000
@@ -0,0 +1,50 @@
+
+#include "Roboter.h"
+
+
+
+//timer object for ledshow and distance sensor
+Ticker t1;
+
+//lights up the led according to the sensor signal
+void ledDistance()
+{
+    for( int ii = 0; ii<6; ++ii)
+        sensors[ii]< 0.1f ? leds[ii] = 1 : leds[ii] = 0;
+}
+
+//blinks at startup and starts ledDistance task
+void ledShow()
+{
+    static int timer = 0;
+    for( int ii = 0; ii<6; ++ii)
+        leds[ii] = !leds[ii];
+
+    //quit ticker and start led distance show
+    if( ++timer > 10) {
+        t1.detach();
+        t1.attach( &ledDistance, 0.01f );
+    }
+}
+
+int IRSensor()
+{
+    pwmL.period(0.00005f); // Setzt die Periode auf 50 μs
+    pwmR.period(0.00005f);
+
+    pwmL = 0.5f; // Setzt die Duty-Cycle auf 50%
+    pwmR = 0.5f;
+    enableMotorDriver = 0;
+
+    t1.attach( &ledShow, 0.05f );
+
+    //init distance sensors
+    for( int ii = 0; ii<6; ++ii)
+        sensors[ii].init(&distance, &bit0, &bit1, &bit2, ii);
+
+    enable = 1;
+
+    while(1) {
+        wait( 0.2f );
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Roboter.h	Tue Mar 21 12:42:01 2017 +0000
@@ -0,0 +1,40 @@
+#ifndef ROBOTER_H
+#define ROBOTER_H
+
+#include <mbed.h>
+#include "Motoren.h"
+#include "IRSensor.h"
+#include "Kamera.h"
+
+class Roboter : class IRSensor
+{
+    
+public:
+
+    Roboter : IRSensor(distance,bit0,bit1,bit2,number)
+    
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#endif 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Mar 21 12:42:01 2017 +0000
@@ -0,0 +1,30 @@
+#include <mbed.h>
+#include "Roboter.h"
+
+DigitalOut led(LED1);
+
+//Periphery for distance sensors
+AnalogIn distance(PB_1); 
+DigitalOut enable(PC_1);
+DigitalOut bit0(PH_1);
+DigitalOut bit1(PC_2);
+DigitalOut bit2(PC_3);
+IRSensor sensors[6];
+
+//motor stuff
+DigitalOut enableMotorDriver(PB_2);
+PwmOut pwmL(PA_8);
+PwmOut pwmR(PA_9);
+
+//indicator leds arround robot
+DigitalOut leds[] = { PC_8, PC_6, PB_12, PA_7, PC_0, PC_9 };
+
+
+int main(){
+    
+    
+    
+    
+    
+return 0; 
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Mar 21 12:42:01 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e1686b8d5b90
\ No newline at end of file