From c64c2b2fb23f7f3e956f3e5e0c6d99960e681269 Mon Sep 17 00:00:00 2001 From: Zhengyu Peng Date: Mon, 7 Mar 2022 22:49:16 -0500 Subject: [PATCH] Update hexapod.py --- software/raspberry pi/hexapod.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/software/raspberry pi/hexapod.py b/software/raspberry pi/hexapod.py index 401d5db..140abff 100644 --- a/software/raspberry pi/hexapod.py +++ b/software/raspberry pi/hexapod.py @@ -329,7 +329,13 @@ class Hexapod(Thread): if len(data_array) == 4: op = data_array[0].lstrip() leg_idx = int(data_array[1]) + if leg_idx <0 or leg_idx >5: + return + joint_idx = int(data_array[2]) + if joint_idx <0 or joint_idx >2: + return + angle = float(data_array[3]) if op == 'angle': self.legs[leg_idx].set_angle(joint_idx, angle)