16 from __future__
import print_function
19 import sys, select, termios, tty
22 from std_msgs.msg
import Bool
23 from geometry_msgs.msg
import Twist, Accel, Vector3
32 self.
l = Vector3(0, 0, 0)
33 self.
a = Vector3(0, 0, 0)
41 --------------------------- 58 if rospy.has_param(
'~type'):
60 if self.
_msg_type not in [
'twist',
'accel']:
61 raise rospy.ROSException(
'Teleoperation output must be either ' 65 self.
_output_pub = rospy.Publisher(
'output', Twist, queue_size=1)
67 self.
_output_pub = rospy.Publisher(
'output', Accel, queue_size=1)
73 while not rospy.is_shutdown():
80 tty.setraw(sys.stdin.fileno())
81 rlist, _, _ = select.select([sys.stdin], [], [], 0.1)
83 key = sys.stdin.read(1)
86 termios.tcsetattr(sys.stdin, termios.TCSADRAIN, self.
settings)
94 speed -= increment * self.
speed 95 if speed < -limit * self.
speed:
96 speed = -limit * self.
speed 98 speed += increment * self.
speed 99 if speed > limit * self.
speed:
100 speed = limit * self.
speed 164 self.
l = Vector3(0, 0, 0)
165 self.
a = Vector3(0, 0, 0)
172 if (key_press ==
'\x03'):
173 rospy.loginfo(
'Keyboard Interrupt Pressed')
174 rospy.loginfo(
'Shutting down [%s] node' % node_name)
177 cmd.angular = Vector3(0, 0, 0)
178 cmd.linear = Vector3(0, 0, 0)
179 self._output_pub.publish(cmd)
184 self._output_pub.publish(cmd)
186 if __name__ ==
'__main__':
191 node_name = os.path.splitext(os.path.basename(__file__))[0]
192 rospy.init_node(node_name)
193 rospy.loginfo(
'Starting [%s] node' % node_name)
197 termios.tcsetattr(sys.stdin, termios.TCSADRAIN, settings)
198 rospy.loginfo(
'Shutting down [%s] node' % node_name)
def _parse_keyboard(self)
def _speed_windup(self, speed, increment, limit, reverse)