Zill Khan
/
ROS_HCSR04_test
Integration of HCSR04 with Nucleo board. ROS Enabled
main.cpp
- Committer:
- zillkhan
- Date:
- 2021-09-27
- Revision:
- 4:13cda079f08d
- Parent:
- 1:ca82df4237eb
- Child:
- 5:1a7d0889cbcf
File content as of revision 4:13cda079f08d:
#include <ros.h> #include <std_msgs/Float32.h> #include <std_msgs/String.h> #include "SHARPIR.h" ros::NodeHandle nh; std_msgs::Float32 data; ros::Publisher sharpir("sharpir", &data); SHARPIR Sensor(A0); int main() { float DistanceCM; nh.initNode(); nh.advertise(sharpir); while (1) { //creates an eternal loop DistanceCM=Sensor.cm(); //sprintf (buffer, "%f", DistanceCM); data.data = DistanceCM; sharpir.publish( &data ); nh.spinOnce(); wait_ms(1000); } }