2 #include <geometry_msgs/Twist.h> 12 #define KEYCODE_RIGHT 0x43 13 #define KEYCODE_LEFT 0x44 14 #define KEYCODE_UP 0x41 15 #define KEYCODE_DOWN 0x42 16 #define KEYCODE_B 0x62 17 #define KEYCODE_C 0x63 18 #define KEYCODE_D 0x64 19 #define KEYCODE_E 0x65 20 #define KEYCODE_F 0x66 21 #define KEYCODE_G 0x67 22 #define KEYCODE_Q 0x71 23 #define KEYCODE_R 0x72 24 #define KEYCODE_T 0x74 25 #define KEYCODE_V 0x76 39 memcpy(&raw, &
cooked,
sizeof(
struct termios));
40 raw.c_lflag &=~ (ICANON | ECHO);
44 tcsetattr(
kfd, TCSANOW, &raw);
50 int rc = read(
kfd, c, 1);
53 throw std::runtime_error(
"read failed");
58 HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
61 PeekConsoleInput(handle, &buffer, 1, &events);
64 ReadConsoleInput(handle, &buffer, 1, &events);
65 if (buffer.Event.KeyEvent.wVirtualKeyCode == VK_LEFT)
70 else if (buffer.Event.KeyEvent.wVirtualKeyCode == VK_UP)
75 else if (buffer.Event.KeyEvent.wVirtualKeyCode == VK_RIGHT)
80 else if (buffer.Event.KeyEvent.wVirtualKeyCode == VK_DOWN)
85 else if (buffer.Event.KeyEvent.wVirtualKeyCode == 0x42)
90 else if (buffer.Event.KeyEvent.wVirtualKeyCode == 0x43)
95 else if (buffer.Event.KeyEvent.wVirtualKeyCode == 0x44)
100 else if (buffer.Event.KeyEvent.wVirtualKeyCode == 0x45)
105 else if (buffer.Event.KeyEvent.wVirtualKeyCode == 0x46)
110 else if (buffer.Event.KeyEvent.wVirtualKeyCode == 0x47)
115 else if (buffer.Event.KeyEvent.wVirtualKeyCode == 0x51)
120 else if (buffer.Event.KeyEvent.wVirtualKeyCode == 0x52)
125 else if (buffer.Event.KeyEvent.wVirtualKeyCode == 0x54)
130 else if (buffer.Event.KeyEvent.wVirtualKeyCode == 0x56)
190 int main(
int argc,
char** argv)
209 puts(
"Reading from keyboard");
210 puts(
"---------------------------");
211 puts(
"Use arrow keys to move the turtle. 'q' to quit.");
221 catch (
const std::runtime_error &)
258 geometry_msgs::Twist twist;
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ros::Publisher twist_pub_
int main(int argc, char **argv)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
void publish(const boost::shared_ptr< M > &message) const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ROSCPP_DECL void shutdown()