Q
Dependencies: SRF05 ros_lib_kinetic TinyGPSPlus
PROJ515.hpp@1:ea2ee36038e7, 2019-05-01 (annotated)
- Committer:
- Luka_Danilovic
- Date:
- Wed May 01 16:17:43 2019 +0000
- Revision:
- 1:ea2ee36038e7
- Parent:
- 0:215bdd87b602
- Child:
- 2:7288dd12186e
- Child:
- 5:bf0d8b28771a
ROS - 1 Sensor implemented;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Luka_Danilovic | 0:215bdd87b602 | 1 | #ifndef __PROJ515_H__ //Inclusion safeguards |
Luka_Danilovic | 0:215bdd87b602 | 2 | #define __PROJ515_H__ //Definition of the inclusion |
Luka_Danilovic | 0:215bdd87b602 | 3 | /*============================================================================*/ |
Luka_Danilovic | 0:215bdd87b602 | 4 | |
Luka_Danilovic | 0:215bdd87b602 | 5 | /* Libraries */ |
Luka_Danilovic | 0:215bdd87b602 | 6 | #include "mbed.h" // Mbed RTOS |
Luka_Danilovic | 0:215bdd87b602 | 7 | #include "hcsr04.h" // HCSR04 ultrasound sensor libary |
Luka_Danilovic | 1:ea2ee36038e7 | 8 | #include <math.h> |
Luka_Danilovic | 1:ea2ee36038e7 | 9 | //#include "SRF05.h" // SRF05 ultrasound sensor libary |
Luka_Danilovic | 1:ea2ee36038e7 | 10 | //#include "SRF05_sp.h" // SRF05 single pin ultrasound sensor libary |
Luka_Danilovic | 0:215bdd87b602 | 11 | #include "ros.h" // ROS Library |
Luka_Danilovic | 0:215bdd87b602 | 12 | #include "sensor_msgs/Range.h" // ROS Sensor Messages component |
Luka_Danilovic | 0:215bdd87b602 | 13 | //#include "std_msgs/Char.h" // ROS Standard Messages component |
Luka_Danilovic | 0:215bdd87b602 | 14 | |
Luka_Danilovic | 0:215bdd87b602 | 15 | /* Definitions */ |
Luka_Danilovic | 0:215bdd87b602 | 16 | #define LEDS_OFF 0x00 // LED bus all off |
Luka_Danilovic | 0:215bdd87b602 | 17 | #define LEDS_ON 0x07 // LED bus all on |
Luka_Danilovic | 1:ea2ee36038e7 | 18 | |
Luka_Danilovic | 1:ea2ee36038e7 | 19 | #define USP_CF1 PE_2 // Cliff ultrasound 1 Trigger/Echo |
Luka_Danilovic | 1:ea2ee36038e7 | 20 | #define USP_CF2 PE_4 // Cliff ultrasound 2 Trigger/Echo |
Luka_Danilovic | 1:ea2ee36038e7 | 21 | #define USP_CF3 PE_5 // Cliff ultrasound 3 Trigger/Echo |
Luka_Danilovic | 1:ea2ee36038e7 | 22 | #define USP_CF4 PE_6 // Cliff ultrasound 4 Trigger/Echo |
Luka_Danilovic | 1:ea2ee36038e7 | 23 | |
Luka_Danilovic | 1:ea2ee36038e7 | 24 | #define USP_CB1 PF_8 // Curb ultrasound 1 Trigger/Echo |
Luka_Danilovic | 1:ea2ee36038e7 | 25 | #define USP_CB2 PF_7 // Curb ultrasound 2 Trigger/Echo |
Luka_Danilovic | 1:ea2ee36038e7 | 26 | #define USP_CB3 PF_9 // Curb ultrasound 3 Trigger/Echo |
Luka_Danilovic | 1:ea2ee36038e7 | 27 | #define USP_CB4 PG_1 // Curb ultrasound 4 Trigger/Echo |
Luka_Danilovic | 0:215bdd87b602 | 28 | |
Luka_Danilovic | 0:215bdd87b602 | 29 | #define ROS_Baud 921600 // ROS Baud Rate |
Luka_Danilovic | 0:215bdd87b602 | 30 | #define frameID "ultrasound_range" // ROS frame ID |
Luka_Danilovic | 0:215bdd87b602 | 31 | |
Luka_Danilovic | 1:ea2ee36038e7 | 32 | #define ULTRASOUND 0x00 // Ultrasound |
Luka_Danilovic | 0:215bdd87b602 | 33 | #define PRINT_DATA 0x01 // Thread communication event to print data |
Luka_Danilovic | 0:215bdd87b602 | 34 | |
Luka_Danilovic | 1:ea2ee36038e7 | 35 | /* Namespaces */ |
Luka_Danilovic | 1:ea2ee36038e7 | 36 | using namespace std; // Make all std symbols visible |
Luka_Danilovic | 1:ea2ee36038e7 | 37 | using namespace ros; // Make all ros symbols visible |
Luka_Danilovic | 1:ea2ee36038e7 | 38 | using namespace sensor_msgs; // Make all sensor_msgs symbols visible |
Luka_Danilovic | 1:ea2ee36038e7 | 39 | using namespace std_msgs; // Make all sdt_msgs symbols visible |
Luka_Danilovic | 1:ea2ee36038e7 | 40 | |
Luka_Danilovic | 0:215bdd87b602 | 41 | /* Declarations */ |
Luka_Danilovic | 1:ea2ee36038e7 | 42 | extern float cfDist1; // Distance returned by cliff u_sensor1 (cm) |
Luka_Danilovic | 1:ea2ee36038e7 | 43 | extern float cfDist2; // Distance returned by cliff u_sensor2 (cm) |
Luka_Danilovic | 1:ea2ee36038e7 | 44 | extern float cfDist3; // Distance returned by cliff u_sensor3 (cm) |
Luka_Danilovic | 1:ea2ee36038e7 | 45 | extern float cfDist4; // Distance returned by cliff u_sensor4 (cm) |
Luka_Danilovic | 1:ea2ee36038e7 | 46 | |
Luka_Danilovic | 1:ea2ee36038e7 | 47 | extern float cbDist1; // Distance returned by curb u_sensor1 (cm) |
Luka_Danilovic | 1:ea2ee36038e7 | 48 | extern float cbDist2; // Distance returned by curb u_sensor2 (cm) |
Luka_Danilovic | 1:ea2ee36038e7 | 49 | extern float cbDist3; // Distance returned by curb u_sensor3 (cm) |
Luka_Danilovic | 1:ea2ee36038e7 | 50 | extern float cbDist4; // Distance returned by curb u_sensor4 (cm) |
Luka_Danilovic | 1:ea2ee36038e7 | 51 | |
Luka_Danilovic | 1:ea2ee36038e7 | 52 | extern float wPeriod; // Waiting period for the sampling (sec) |
Luka_Danilovic | 0:215bdd87b602 | 53 | |
Luka_Danilovic | 0:215bdd87b602 | 54 | /* GPIO */ |
Luka_Danilovic | 0:215bdd87b602 | 55 | DigitalIn bttn(USER_BUTTON); // Onboard blue user button |
Luka_Danilovic | 0:215bdd87b602 | 56 | BusOut leds(LED1, LED2, LED3); // Onboard LEDs bus |
Luka_Danilovic | 0:215bdd87b602 | 57 | |
Luka_Danilovic | 0:215bdd87b602 | 58 | /* Instantiations */ |
Luka_Danilovic | 1:ea2ee36038e7 | 59 | //SRF05 USS_CF1(USP_CF1,USP_CF1); // Ultrasound sensor cliff 1 |
Luka_Danilovic | 1:ea2ee36038e7 | 60 | //SRF05 USS_CF2(USP_CF2,USP_CF2); // Ultrasound sensor cliff 2 |
Luka_Danilovic | 1:ea2ee36038e7 | 61 | //SRF05 USS_CF3(USP_CF3,USP_CF3); // Ultrasound sensor cliff 3 |
Luka_Danilovic | 1:ea2ee36038e7 | 62 | //SRF05 USS_CF4(USP_CF4,USP_CF4); // Ultrasound sensor cliff 4 |
Luka_Danilovic | 1:ea2ee36038e7 | 63 | // |
Luka_Danilovic | 1:ea2ee36038e7 | 64 | //SRF05 USS_CB1(USP_CB1,USP_CB1); // Ultrasound sensor cliff 1 |
Luka_Danilovic | 1:ea2ee36038e7 | 65 | //SRF05 USS_CB2(USP_CB2,USP_CB2); // Ultrasound sensor cliff 2 |
Luka_Danilovic | 1:ea2ee36038e7 | 66 | //SRF05 USS_CB3(USP_CB3,USP_CB3); // Ultrasound sensor cliff 3 |
Luka_Danilovic | 1:ea2ee36038e7 | 67 | HCSR04 USS_CB4(PG_1,PG_0); // Ultrasound sensor cliff 4 |
Luka_Danilovic | 1:ea2ee36038e7 | 68 | |
Luka_Danilovic | 1:ea2ee36038e7 | 69 | //Serial usbSer(USBTX, USBRX); // Serial over USB OTG |
Luka_Danilovic | 0:215bdd87b602 | 70 | NodeHandle nh; // Instance for ROS Node Handler |
Luka_Danilovic | 0:215bdd87b602 | 71 | Range ultrasound_msg; // Instance for ROS NavSatFix message |
Luka_Danilovic | 1:ea2ee36038e7 | 72 | |
Luka_Danilovic | 0:215bdd87b602 | 73 | // Instance for ROS publisher (Odometry Message) |
Luka_Danilovic | 1:ea2ee36038e7 | 74 | Publisher ultrasound_pub("/ultrasound/cb1", &ultrasound_msg); |
Luka_Danilovic | 0:215bdd87b602 | 75 | |
Luka_Danilovic | 0:215bdd87b602 | 76 | /* Threads and Signals */ |
Luka_Danilovic | 0:215bdd87b602 | 77 | //Thread myThread (osPriorityNormal); |
Luka_Danilovic | 0:215bdd87b602 | 78 | //EventFlags myEventFlag; |
Luka_Danilovic | 0:215bdd87b602 | 79 | |
Luka_Danilovic | 0:215bdd87b602 | 80 | /* Function Prototypes */ |
Luka_Danilovic | 0:215bdd87b602 | 81 | //void myFunctionPrototype(); |
Luka_Danilovic | 0:215bdd87b602 | 82 | |
Luka_Danilovic | 0:215bdd87b602 | 83 | /*============================================================================*/ |
Luka_Danilovic | 0:215bdd87b602 | 84 | #endif // End of inclusion |