Q
Dependencies: SRF05 ros_lib_kinetic TinyGPSPlus
PROJ515.hpp@0:215bdd87b602, 2019-04-22 (annotated)
- Committer:
- Luka_Danilovic
- Date:
- Mon Apr 22 18:28:24 2019 +0000
- Revision:
- 0:215bdd87b602
- Child:
- 1:ea2ee36038e7
Started adding ROS components;
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 | 0:215bdd87b602 | 8 | #include "ros.h" // ROS Library |
Luka_Danilovic | 0:215bdd87b602 | 9 | #include "sensor_msgs/Range.h" // ROS Sensor Messages component |
Luka_Danilovic | 0:215bdd87b602 | 10 | //#include "std_msgs/Char.h" // ROS Standard Messages component |
Luka_Danilovic | 0:215bdd87b602 | 11 | |
Luka_Danilovic | 0:215bdd87b602 | 12 | |
Luka_Danilovic | 0:215bdd87b602 | 13 | /* Definitions */ |
Luka_Danilovic | 0:215bdd87b602 | 14 | #define LEDS_OFF 0x00 // LED bus all off |
Luka_Danilovic | 0:215bdd87b602 | 15 | #define LEDS_ON 0x07 // LED bus all on |
Luka_Danilovic | 0:215bdd87b602 | 16 | #define ULS_EC PC_10 // Ultrasound Trigger Pin |
Luka_Danilovic | 0:215bdd87b602 | 17 | #define ULS_TG PC_11 // Ultrasound Echo Pin |
Luka_Danilovic | 0:215bdd87b602 | 18 | |
Luka_Danilovic | 0:215bdd87b602 | 19 | #define ROS_Baud 921600 // ROS Baud Rate |
Luka_Danilovic | 0:215bdd87b602 | 20 | #define frameID "ultrasound_range" // ROS frame ID |
Luka_Danilovic | 0:215bdd87b602 | 21 | |
Luka_Danilovic | 0:215bdd87b602 | 22 | #define ULTRASOUND 0x00 // Ultrasound |
Luka_Danilovic | 0:215bdd87b602 | 23 | #define PRINT_DATA 0x01 // Thread communication event to print data |
Luka_Danilovic | 0:215bdd87b602 | 24 | |
Luka_Danilovic | 0:215bdd87b602 | 25 | /* Declarations */ |
Luka_Danilovic | 0:215bdd87b602 | 26 | extern unsigned int cmDistance1; // Distance measured by u_sensor_1 in cm |
Luka_Danilovic | 0:215bdd87b602 | 27 | extern float sPeriod; // Sampling period of the sensors (sec) |
Luka_Danilovic | 0:215bdd87b602 | 28 | |
Luka_Danilovic | 0:215bdd87b602 | 29 | /* GPIO */ |
Luka_Danilovic | 0:215bdd87b602 | 30 | DigitalIn bttn(USER_BUTTON); // Onboard blue user button |
Luka_Danilovic | 0:215bdd87b602 | 31 | BusOut leds(LED1, LED2, LED3); // Onboard LEDs bus |
Luka_Danilovic | 0:215bdd87b602 | 32 | |
Luka_Danilovic | 0:215bdd87b602 | 33 | /* Instantiations */ |
Luka_Danilovic | 0:215bdd87b602 | 34 | HCSR04 usensor1(ULS_TG,ULS_EC); // Ultrasound sensor 1 |
Luka_Danilovic | 0:215bdd87b602 | 35 | Serial usbSer(USBTX, USBRX); // Serial over USB OTG |
Luka_Danilovic | 0:215bdd87b602 | 36 | NodeHandle nh; // Instance for ROS Node Handler |
Luka_Danilovic | 0:215bdd87b602 | 37 | Range ultrasound_msg; // Instance for ROS NavSatFix message |
Luka_Danilovic | 0:215bdd87b602 | 38 | // Instance for ROS publisher (Odometry Message) |
Luka_Danilovic | 0:215bdd87b602 | 39 | Publisher ultrasound_pub("ultrasound_range", &ultrasound_msg); |
Luka_Danilovic | 0:215bdd87b602 | 40 | |
Luka_Danilovic | 0:215bdd87b602 | 41 | /* Namespaces */ |
Luka_Danilovic | 0:215bdd87b602 | 42 | using namespace std; // Make all std symbols visible |
Luka_Danilovic | 0:215bdd87b602 | 43 | using namespace ros; // Make all ros symbols visible |
Luka_Danilovic | 0:215bdd87b602 | 44 | using namespace sensor_msgs; // Make all sensor_msgs symbols visible |
Luka_Danilovic | 0:215bdd87b602 | 45 | using namespace std_msgs; // Make all sdt_msgs symbols visible |
Luka_Danilovic | 0:215bdd87b602 | 46 | |
Luka_Danilovic | 0:215bdd87b602 | 47 | /* Threads and Signals */ |
Luka_Danilovic | 0:215bdd87b602 | 48 | //Thread myThread (osPriorityNormal); |
Luka_Danilovic | 0:215bdd87b602 | 49 | //EventFlags myEventFlag; |
Luka_Danilovic | 0:215bdd87b602 | 50 | |
Luka_Danilovic | 0:215bdd87b602 | 51 | /* Function Prototypes */ |
Luka_Danilovic | 0:215bdd87b602 | 52 | //void myFunctionPrototype(); |
Luka_Danilovic | 0:215bdd87b602 | 53 | |
Luka_Danilovic | 0:215bdd87b602 | 54 | /*============================================================================*/ |
Luka_Danilovic | 0:215bdd87b602 | 55 | #endif // End of inclusion |