main.cpp
Go to the documentation of this file.
00001 #include <ros/ros.h>
00002 #include <iostream>
00003 #include "keyboard.h"
00004 using namespace std;
00005 
00006 int main(int argc, char** argv)
00007 {  
00008   ros::init(argc, argv, "keyboard");
00009   ros::NodeHandle n("~");
00010 
00011   ros::Publisher pub_down = n.advertise<keyboard::Key>("keydown", 10);
00012   ros::Publisher pub_up = n.advertise<keyboard::Key>("keyup", 10);
00013 
00014   keyboard::Keyboard kbd;
00015   ros::Rate r(50);
00016   
00017   keyboard::Key k;
00018   bool pressed, new_event;
00019   while (ros::ok() && kbd.get_key(new_event, pressed, k.code, k.modifiers)) {
00020     if (new_event) {
00021       k.header.stamp = ros::Time::now();
00022       if (pressed) pub_down.publish(k);
00023       else pub_up.publish(k);
00024     }
00025     ros::spinOnce();
00026     r.sleep();
00027   }
00028   
00029   ros::waitForShutdown();
00030 }


keyboard
Author(s): v01d
autogenerated on Thu Feb 11 2016 23:16:45