3 #include <sensor_msgs/Joy.h> 4 #include <geometry_msgs/Twist.h> 19 void joyCallback(
const sensor_msgs::Joy::ConstPtr& msg);
20 void twistCallback(
const geometry_msgs::Twist::ConstPtr& msg);
35 std::ostringstream strs;
36 strs << std::endl <<
"axes: [";
37 for(
size_t i=0; i < msg->axes.size(); i++)
38 strs << msg->axes[i] <<
",";
39 strs <<
"]" << std::endl;
41 for(
size_t i=0; i < msg->buttons.size(); i++)
42 strs << msg->buttons[i] <<
",";
43 strs <<
"]" << std::endl;
55 if (msg->buttons[4] || msg->buttons[5])
60 geometry_msgs::Twist out_cmd_vel;
64 out_cmd_vel.angular.z = msg->axes[3];
65 out_cmd_vel.linear.x = msg->axes[4];
77 geometry_msgs::Twist out_cmd_vel;
83 int main(
int argc,
char **argv)
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
void joyCallback(const sensor_msgs::Joy::ConstPtr &msg)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
Joy2twist(int argc, char **argv)
int main(int argc, char **argv)
ROSCPP_DECL void spin(Spinner &spinner)
ros::Subscriber subTwist_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
geometry_msgs::Twist in_cmd_vel_
void twistCallback(const geometry_msgs::Twist::ConstPtr &msg)