25 #include <sensor_msgs/Joy.h> 30 #define KEYCODE_N 0x6E //run 31 #define KEYCODE_M 0x6D //mode 32 #define KEYCODE_H 0x68 //help 36 #define KEYCODE_A 0x61 37 #define KEYCODE_D 0x64 38 #define KEYCODE_S 0x73 39 #define KEYCODE_W 0x77 40 #define KEYCODE_Q 0x71 41 #define KEYCODE_E 0x65 45 #define KEYCODE_1 0x31 46 #define KEYCODE_2 0x32 47 #define KEYCODE_3 0x33 48 #define KEYCODE_4 0x34 49 #define KEYCODE_5 0x35 50 #define KEYCODE_6 0x36 51 #define KEYCODE_7 0x37 52 #define KEYCODE_8 0x38 57 #define KEYCODE_R 0x72 58 #define KEYCODE_T 0x74 59 #define KEYCODE_Z 0x7A 60 #define KEYCODE_U 0x75 61 #define KEYCODE_I 0x69 66 #define KEYCODE_S 0x73 67 #define KEYCODE_D 0x64 68 #define KEYCODE_F 0x66 69 #define KEYCODE_G 0x67 71 #define KEYCODE_Y 0x79 72 #define KEYCODE_X 0x78 73 #define KEYCODE_C 0x63 74 #define KEYCODE_V 0x76 75 #define KEYCODE_B 0x62 82 struct termios cooked,
raw;
88 tcsetattr(
kfd, TCSANOW, &cooked);
275 puts(
"Reading from keyboard");
276 puts(
"---------------------------");
277 puts(
"Use 'm' to toggle modes (joint/platform)");
278 puts(
"Use 'n' to toggle run");
279 puts(
"---------------------------");
280 puts(
"In platform_mode");
281 puts(
"Use 'wasd' to translate");
282 puts(
"Use 'qe' to yaw");
283 puts(
"---------------------------");
284 puts(
"In joint_mode");
285 puts(
"Use '1'-'7' and 'q'-'u' for arm");
286 puts(
"Use '8' and 'i' for tray");
287 puts(
"Use 'a'-'f' and 'y'-'v' for torso");
288 puts(
"---------------------------");
289 puts(
"Use 'h' to show this help");
290 puts(
"Hit 'SPACE' to stop movement");
295 int main(
int argc,
char **argv)
297 ros::init(argc, argv,
"keyboard_publisher");
301 puts(
"Reading from keyboard");
302 puts(
"---------------------------");
303 puts(
"Use 'm' to toggle modes (joint/platform)");
304 puts(
"Use 'n' to toggle run");
305 puts(
"---------------------------");
306 puts(
"In platform_mode");
307 puts(
"Use 'wasd' to translate");
308 puts(
"Use 'qe' to yaw");
309 puts(
"---------------------------");
310 puts(
"In joint_mode");
311 puts(
"Use '1'-'7' and 'q'-'u' for arm");
312 puts(
"Use '8' and 'i' for tray");
313 puts(
"Use 'a'-'f' and 'y'-'v' for torso");
314 puts(
"---------------------------");
315 puts(
"Use 'h' to show this help");
316 puts(
"Hit 'SPACE' to stop movement");
322 tcgetattr(
kfd, &cooked);
323 memcpy(&
raw, &cooked,
sizeof(
struct termios));
324 raw.c_lflag &=~ (ICANON | ECHO);
330 tcsetattr(
kfd, TCSANOW, &
raw);
343 sensor_msgs::Joy
msg;
345 msg.buttons.resize(12);
348 if(read(
kfd, &c, 1) < 0)
void publish(const boost::shared_ptr< M > &message) const
void composeJoyMessage(sensor_msgs::Joy &msg, char c)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
int main(int argc, char **argv)
ROSCPP_DECL void spinOnce()
struct termios cooked raw