-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathcontroller_client.py
36 lines (28 loc) · 1000 Bytes
/
controller_client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Author: Jimmy Wu
# Date: February 2023
import argparse
from multiprocessing.connection import Client
from constants import CONN_AUTHKEY
class ControllerClient:
def __init__(self, robot_idx):
self.conn = Client(('localhost', 6004 + robot_idx), authkey=CONN_AUTHKEY)
def get_controller_data(self):
self.conn.send('controller_data')
return self.conn.recv()
def execute_command(self, command):
self.conn.send(command)
def stop(self):
self.conn.send('stop')
def reset_visualizer(self):
self.conn.send('reset_visualizer')
def main(args):
robot_idx = args.robot_num - 1
client = ControllerClient(robot_idx)
client.execute_command({
'primitive_name': 'move',
'waypoints': [(-0.5, 0.5), (0.5, 0.5), (0.5, -0.5), (-0.5, -0.5), (-0.5, 0.5)],
})
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--robot-num', type=int, default=1)
main(parser.parse_args())