Teleop Twist Keyboard Node

Subscribes to:

/scan

Publishes to:

/cmd_vel

it can implement two behaviours on robot:

1: moving without obstacle avoidance:

user can move the robot using keys it publishes the desired movements to cmd_vel topic

2: moveing with obstacle avoidance:

subscribes scan topic and uses it to detect obstacles. user can move the robot using keys and it also avoids the robot from colliding the obstacles

Here is the instruction for controlling the robot with keyboard:

Moving around

u

i

o

j

k

l

m

,

.

Holonomic mode(strafing)

U

I

O

J

K

L

M

<

>

t : up (+z)

b : down (-z)

anything else : stop

q/z : increase/decrease max speeds by 10%

w/x : increase/decrease only linear speed by 10%

e/c : increase/decrease only angular speed by 10%

CTRL-C to change robot behaviour

class scripts.teleop_twist_keyboard.PublishThread(rate)[source]

A class which is used for synchronization and publishing robot’s twist into cmd_vel topic

Attributes:

x, y, z, th, speed, turnfloat

Robot’s Position Information

donebool

Robot State

Methods:

run()[source]

Detects if user has chosen the obstacle avoidance option and moves the robot by publishing the twist to cmd_vel topic

stop()[source]

Stops the robot

update(x, y, z, th, speed, turn)[source]

Updates robots position information

wait_for_subscribers()[source]

Waits for subscribers to connect to the topic

scripts.teleop_twist_keyboard.clbk_laser(msg)[source]

Callback function for subscring laser scan topic

Parameters

msg (float) – rangefinder sensor data

scripts.teleop_twist_keyboard.getKey(key_timeout)[source]

Gets commands from user

Parameters

key_timeout (float) – timeout for input key

Returns

user input key

Return type

key(str)

scripts.teleop_twist_keyboard.teleop()[source]

Provides the interface and publishes user command to cmd_vel topic

scripts.teleop_twist_keyboard.vels(speed, turn)[source]

Puts the current speed of robot in a message string

Parameters
  • speed (float) – robot’s linear speed

  • turn (float) – robot’s angular speed

Returns

a message string that shows robot’s twist

Return type

msg(str)