游戏手柄之自定义按钮控制海龟

该文为基础上https://blog.csdn.net/qq_34935373/article/details/87905784

想通过游戏手柄自定义话题,自定义按键实现对海龟的控制。于是有了本文

新建节点/joymsg_pub_node和话题/joycontrol_topic.

在src/目录下新建功能包joy_msg,在joy_msg/src的新建源文件joymsg_pub.cpp。代码如下::

#include "ros/ros.h"

#include<geometry_msgs/Twist.h>

#include <iostream>

#include <sstream>

#include <stdio.h>              //perror()

#include <unistd.h>            //fork()

#include <stdlib.h>

#include <errno.h>            //errno, EINTR

#include <string.h>           //strlen()

#include <fcntl.h>

#include <signal.h>

#include <syspes.h>  

#include <sys/stat.h>  

#include <linux/input.h>  

#include <linux/joystick.h>

#include <errno.h>

#include <pthread.h>

 

 

 

#define AXES0 0x00 //Left_Axis from right to left        

#define AXES1 0x01 //Left_Axis from up to down             

#define AXES2 0x02 //Right_Axis from right to left

#define AXES3 0x03 //Right_Axis from down to up

#define AXES4 0x04 //R&L_Key from Right_Key to Left_Key  

#define AXES5 0x05 //D&U_Key from Down_key to Up_key

 

#define BUTTON0 0x00         //X_Botton           

#define BUTTON1 0x01         //A_Botton                   

#define BUTTON2 0x02            //B_Botton       

#define BUTTON3 0x03            //Y_Botton       

#define BUTTON4 0x04            //LB_Botton

#define BUTTON5 0x05            //RB_Botton  

#define BUTTON6 0x06 //LT_Botton

#define BUTTON7 0x07 //RT_Botton

#define BUTTON8 0x08 //BACK_Botton

#define BUTTON9 0x09 //START_Botton

#define BUTTON10 0x10     //Left_Axis__Botton  

#define B

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值