transport.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 from rospy import logdebug
4 from httplib import HTTPConnection
5 
6 
7 class Transport(object):
8 
9  def __init__(self, hostname='192.168.4.1', port='1234'):
10  self.hostname = hostname
11  self.port = port
12 
13  def send_command(self, params):
14  request = "/" + "/".join(map(str, params))
15 
16  try:
17  self.conn = HTTPConnection(self.hostname,
18  port=self.port,
19  timeout=0.5)
20  self.conn.request("GET", request)
21  response = self.conn.getresponse().read()
22  self.conn.close()
23  if len(response) == 0:
24  return None
25  return response
26  except Exception as e:
27  logdebug("the HTTP request " + request + " failed: " + str(e))
28  return None
29 
30  def move_forward(self):
31  self.send_command([3, 100, 100])
32 
33  def move_reverse(self):
34  self.send_command([3, -100, -100])
35 
36  def move_left(self):
37  self.send_command([3, -100, 100])
38 
39  def move_right(self):
40  self.send_command([3, 100, -100])
41 
42  def stop(self):
43  self.send_command([3, 0, 0])
44 
45  def see(self):
46  return self.send_command([5])
def send_command(self, params)
Definition: transport.py:13
def __init__(self, hostname='192.168.4.1', port='1234')
Definition: transport.py:9


rodi_robot
Author(s): Javier Martinez Canillas
autogenerated on Mon Jun 10 2019 14:36:49