23 #include <geometry_msgs/Twist.h> 25 #define ESC_ASCII_VALUE 0x1b 34 struct termios oldt, newt;
37 tcgetattr( STDIN_FILENO, &oldt );
39 newt.c_lflag &= ~(ICANON | ECHO);
42 tcsetattr( STDIN_FILENO, TCSANOW, &newt );
44 tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
51 struct termios oldt, newt;
55 tcgetattr(STDIN_FILENO, &oldt);
57 newt.c_lflag &= ~(ICANON | ECHO);
58 tcsetattr(STDIN_FILENO, TCSANOW, &newt);
59 oldf = fcntl(STDIN_FILENO, F_GETFL, 0);
60 fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK);
64 tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
65 fcntl(STDIN_FILENO, F_SETFL, oldf);
75 int main(
int argc,
char **argv)
81 double lin_vel_step = 0.01;
82 double ang_vel_step = 0.1;
84 ROS_INFO(
"You can set '-lin_vel_step' and '-ang_vel_step' arguments (default is 0.01 and 0.1)");
88 lin_vel_step = atof(argv[1]);
89 ang_vel_step = atof(argv[2]);
93 geometry_msgs::Twist twist_msg;
97 Control Your Mobile Robot! \n\ 98 --------------------------- \n\ 104 w/x : increase/decrease linear velocity\n\ 105 a/d : increase/decrease angular velocity\n\ 124 twist_msg.linear.x += lin_vel_step;
128 twist_msg.linear.x -= lin_vel_step;
132 twist_msg.angular.z += ang_vel_step;
136 twist_msg.angular.z -= ang_vel_step;
140 twist_msg.linear.x = 0.0f;
141 twist_msg.angular.z = 0.0f;
145 twist_msg.linear.x = twist_msg.linear.x;
146 twist_msg.angular.z = twist_msg.angular.z;
150 cmd_vel_pub.
publish(twist_msg);
void publish(const boost::shared_ptr< M > &message) const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int main(int argc, char **argv)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ROSCPP_DECL void spinOnce()