ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org
Ask Your Question

Revision history [back]

you don't seem to have any keyboard callback function. linear_vel = KeyboardInput() will not take your keyboard input. If you check the cpp implementation of Kobuki teleop you can see that there is a function dedicated to detecting the user's input. For simplicity you could use cv2.WaitKey function from openCV in your code instead.

Here is the keyboard input detection function from cpp

void KeyOpCore::keyboardInputLoop()
{
struct termios raw;
memcpy(&raw, &original_terminal_state, sizeof(struct termios));
raw.c_lflag &= ~(ICANON | ECHO);
// Setting a new line, then end of file
raw.c_cc[VEOL] = 1;
raw.c_cc[VEOF] = 2;
tcsetattr(key_file_descriptor, TCSANOW, &raw);
puts("Reading from keyboard");
puts("---------------------------");
puts("Forward/back arrows : linear velocity incr/decr.");
puts("Right/left arrows : angular velocity incr/decr.");
puts("Spacebar : reset linear/angular velocities.");
puts("d : disable motors.");
puts("e : enable motors.");
puts("q : quit.");
char c;
while (!quit_requested)
{
if (read(key_file_descriptor, &c, 1) < 0)
{
perror("read char failed():");
exit(-1);
}
processKeyboardInput(c);
}
}