Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed ros_lib_kinetic
main.cpp
- Committer:
- ElevatedSounds
- Date:
- 2018-07-25
- Revision:
- 0:4735537ba7a7
- Child:
- 1:62257cc9f659
File content as of revision 0:4735537ba7a7:
#include "mbed.h"
#include <ros.h>
#include <std_msgs/Int16.h>
#include <std_msgs/Bool.h>
DigitalIn leakSensor(PC_2);
DigitalIn killSwitch(PC_3);
DigitalOut myled(LED1);
ros::NodeHandle nh;
std_msgs::Bool leak_msg;
ros::Publisher leak_publisher("leak", &leak_msg);
std_msgs::Bool killSwitch_msg;
ros::Publisher killSwitch_publisher("killSwitch", &killSwitch_msg);
int main()
{
nh.initNode();
nh.advertise(leak_publisher);
nh.advertise(killSwitch_publisher);
while (1)
{
if(leakSensor)
{
leak_msg.data = 1;
}
else
{
leak_msg.data = 0;
}
leak_publisher.publish(&leak_msg);
if(killSwitch)
{
killSwitch_msg.data = 1;
}
else
{
killSwitch_msg.data = 0;
}
killSwitch_publisher.publish(&killSwitch_msg);
nh.spinOnce();
wait_ms(200);
}
}