7 #include <geometry_msgs/Twist.h> 28 std::cout <<
"Reading from keyboard and publishing on cmd_vel..." << std::endl;
29 std::cout <<
"--------------------------------------------------" << std::endl;
31 std::cout <<
"To move around use:" << std::endl;
32 std::cout <<
" w " << std::endl;
33 std::cout <<
" a s d" << std::endl;
34 std::cout <<
" x " << std::endl;
36 std::cout <<
"To rotate the bot use:" << std::endl;
37 std::cout <<
"q/e for anti-clockwise/clockwise rotation" << std::endl;
39 std::cout <<
"\nPress the key again to increase the velocity..." << std::endl;
51 tcgetattr(STDIN_FILENO, &oldt);
55 newt.c_lflag &= ~(ICANON | ECHO);
56 newt.c_iflag |= IGNBRK;
57 newt.c_iflag &= ~(INLCR | ICRNL | IXON | IXOFF);
58 newt.c_lflag &= ~(ICANON | ECHO | ECHOK | ECHOE | ECHONL | ISIG | IEXTEN);
61 tcsetattr(fileno(stdin), TCSANOW, &newt);
67 tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
74 std::cout <<
"Currently: lin_x is " << vel.linear.x <<
" lin_y is " << vel.linear.y <<
" and ang_z is " << vel.angular.z << std::endl;
77 int main(
int argc,
char** argv)
86 geometry_msgs::Twist vel;
91 float x(0), y(0), ang_z(0);
102 y = y + moveBindings[key][1];
103 ang_z = ang_z + moveBindings[key][2];
110 std::cout <<
"\n\n" << std::endl;
125 vel.angular.z = ang_z;
int main(int argc, char **argv)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void publish(const boost::shared_ptr< M > &message) const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void print_vel(const geometry_msgs::Twist &vel)
std::map< char, std::vector< float > > moveBindings
ROSCPP_DECL void spinOnce()