RoombaEvents.cpp
Go to the documentation of this file.
00001 
00002 #include <iostream>
00003 #include <boost/thread.hpp>
00004 
00005 #include <ros/ros.h>
00006 #include <std_msgs/Bool.h>
00007 #include <sensor_msgs/Range.h>
00008 #include <random_numbers/random_numbers.h>
00009 
00010 using namespace std;
00011 
00012 int main(int argc, char** argv){
00013 
00014         ros::init(argc, argv, "fsm_roomba_events");
00015 
00016         ros::NodeHandle node;
00017         random_numbers::RandomNumberGenerator randomizer;
00018 
00019         ros::Publisher leftBumperPub = node.advertise<std_msgs::Bool>("/roomba/left_bumper", 1, false);
00020         ros::Publisher rightBumperPub = node.advertise<std_msgs::Bool>("/roomba/right_bumper", 1, false);
00021         ros::Publisher wallSensorPub = node.advertise<sensor_msgs::Range>("/roomba/wall_sensor", 1, false);
00022 
00023         ROS_INFO("Starting roomba event publisher...");
00024 
00025         while (ros::ok()) {
00026             std_msgs::Bool leftBumper, rightBumper;
00027             sensor_msgs::Range wallSensor;
00028 
00029             wallSensor.range = randomizer.uniformReal(0.2, 3);
00030             leftBumper.data = randomizer.uniformInteger(1, 5) == 1;
00031             rightBumper.data = randomizer.uniformInteger(1, 5) == 1;
00032 
00033             leftBumperPub.publish(leftBumper);
00034             rightBumperPub.publish(rightBumper);
00035             wallSensorPub.publish(wallSensor);
00036 
00037             boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
00038         }
00039 
00040         return 0;
00041 }
00042 
00043 


decision_making_examples
Author(s):
autogenerated on Wed Aug 26 2015 11:17:01