Main Page
Namespaces
Classes
Files
File List
src
rodi_robot
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])
rodi_robot.transport.Transport.stop
def stop(self)
Definition:
transport.py:42
rodi_robot.transport.Transport.send_command
def send_command(self, params)
Definition:
transport.py:13
rodi_robot.transport.Transport.conn
conn
Definition:
transport.py:17
rodi_robot.transport.Transport.move_right
def move_right(self)
Definition:
transport.py:39
rodi_robot.transport.Transport.move_forward
def move_forward(self)
Definition:
transport.py:30
rodi_robot.transport.Transport
Definition:
transport.py:7
rodi_robot.transport.Transport.port
port
Definition:
transport.py:11
rodi_robot.transport.Transport.move_left
def move_left(self)
Definition:
transport.py:36
rodi_robot.transport.Transport.__init__
def __init__(self, hostname='192.168.4.1', port='1234')
Definition:
transport.py:9
rodi_robot.transport.Transport.move_reverse
def move_reverse(self)
Definition:
transport.py:33
rodi_robot.transport.Transport.hostname
hostname
Definition:
transport.py:10
rodi_robot.transport.Transport.see
def see(self)
Definition:
transport.py:45
rodi_robot
Author(s): Javier Martinez Canillas
autogenerated on Mon Jun 10 2019 14:36:49