From 27403dd2371e0dabc982861f770db491229d3fc0 Mon Sep 17 00:00:00 2001 From: Artem30801 Date: Wed, 20 Mar 2019 12:31:16 +0300 Subject: [PATCH] Config COPTER_ID to /hostname to make client use system hostname Closes #7 --- Drone/client.py | 2 ++ Drone/client_config.ini | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Drone/client.py b/Drone/client.py index ed98723..16b6023 100644 --- a/Drone/client.py +++ b/Drone/client.py @@ -208,6 +208,8 @@ COPTER_ID = config.get('PRIVATE', 'id') if COPTER_ID == 'default': COPTER_ID = 'copter' + str(random.randrange(9999)).zfill(4) write_to_config('PRIVATE', 'id', COPTER_ID) +elif COPTER_ID == '/hostname': + COPTER_ID = socket.gethostname() rospy.init_node('Swarm_client', anonymous=True) if USE_LEDS: diff --git a/Drone/client_config.ini b/Drone/client_config.ini index 4134ffe..52b35be 100644 --- a/Drone/client_config.ini +++ b/Drone/client_config.ini @@ -20,7 +20,7 @@ x0_common = 0 y0_common = 0 [PRIVATE] -id = copter2 +id = /hostname use_leds = True x0 = 0 y0 = 0 \ No newline at end of file