diff --git a/pycrocart/ParameterWindow.py b/pycrocart/ParameterWindow.py index 30a1db4070f49b5af16b35e1c78abfc5ed95c3d8..36356fae9d7d3b8d4d9075caf7b4600e580b9e13 100644 --- a/pycrocart/ParameterWindow.py +++ b/pycrocart/ParameterWindow.py @@ -215,12 +215,15 @@ class ParameterWindow(QWidget): def on_send(self): if not self.sending: - self.sending = True - self.complete_label.setEnabled(False) try: with open('./mp4params.json', 'r') as f: contents = json.load(f) + + self.sending = True + self.complete_label.setEnabled(False) + self.complete_label.setText("Complete ✓") + for key in contents: for sub_key in contents[key]: self.num_to_send += 1 @@ -229,9 +232,11 @@ class ParameterWindow(QWidget): 'value': contents[key][sub_key]}) self.timer.timeout.connect(self.send_callback) - self.timer.start(100) + self.timer.start(300) except json.decoder.JSONDecodeError: - print("File open") + error_text = "Malformed Json" + self.complete_label.setText( + "<span style='color: red;'>" + error_text + "</span>") def send_callback(self): diff --git a/pycrocart/SetpointHandler.py b/pycrocart/SetpointHandler.py index 71150418945be48e57fb2eff1f52e7e55f8874d1..a16c450feaa5ff15ec8e7b18ff837d11c389021f 100644 --- a/pycrocart/SetpointHandler.py +++ b/pycrocart/SetpointHandler.py @@ -94,11 +94,11 @@ class SetpointHandler: thrust = self.setpoint.thrust * 65000 / 100 print(f"Set attitude: {self.setpoint.yaw}, {self.setpoint.pitch}, " - f"{self.setpoint.roll}, {self.setpoint.thrust}") + f"{self.setpoint.roll}, {thrust}") self.commander.send_attitude_setpoint( self.setpoint.yaw, self.setpoint.pitch, self.setpoint.roll, - int(thrust)) + thrust) elif self._flight_mode == FlightMode.ATTITUDE_RATE_TYPE: @@ -109,7 +109,7 @@ class SetpointHandler: self.commander.send_attitude_rate_setpoint( self.setpoint.yaw, self.setpoint.pitch, self.setpoint.roll, - int(thrust)) + thrust) self.setpoint_semaphore.release() @@ -134,4 +134,4 @@ class SetpointHandler: self.commander.send_attitude_rate_setpoint( self.setpoint.yaw, self.setpoint.pitch, self.setpoint.roll, - int(thrust)) \ No newline at end of file + thrust) diff --git a/pycrocart/SetpointMenu.py b/pycrocart/SetpointMenu.py index 15a815746070dcc0e471c25ef803e87b574bf655..1d36456da037f85b94b94d8ac3e34d3acc63d17f 100644 --- a/pycrocart/SetpointMenu.py +++ b/pycrocart/SetpointMenu.py @@ -209,5 +209,6 @@ class SetpointMenu(QWidget): self.roll_box.setText(str(round(self.setpoint.roll, 2))) self.pitch_box.setText(str(round(self.setpoint.pitch, 2))) self.thrust_slider.setValue(int(round(self.setpoint.thrust, 2))) + self.send_setpoint() self.setpoint_semaphore.release() diff --git a/pycrocart/logging_variables.json b/pycrocart/logging_variables.json index 2f108231a96c3b172ad81531cd7c777e93059d9a..031cfdfbd1381950b7883d9cfeb9ae57e19b1cd8 100644 --- a/pycrocart/logging_variables.json +++ b/pycrocart/logging_variables.json @@ -1,12 +1,7 @@ { "group1": { - "update_frequency_ms": 21, - "vars": ["stateEstimate.pitch", "stateEstimate.roll", "stateEstimate.yaw"] - }, - "group2": - { - "update_frequency_ms": 100, - "vars": ["health.motorVarXM1"] + "update_frequency_ms": 50, + "vars": ["ctrlStdnt.r_roll", "ctrlStdnt.rollRate", "stateEstimate.roll", "ctrlStdnt.roll"] } } \ No newline at end of file diff --git a/pycrocart/mp4params.json b/pycrocart/mp4params.json index 5a470795bab40d7cb18246254ae083650830fcba..0baf5fd962d54f56e3bec007276bf0387e8e4f1c 100644 --- a/pycrocart/mp4params.json +++ b/pycrocart/mp4params.json @@ -5,26 +5,26 @@ }, "s_pid_rate": { - "roll_kp" : 0, - "roll_ki" : 0, + "roll_kp" : 300, + "roll_ki" : 40, "roll_kd" : 0, - "pitch_kp": 0, - "pitch_ki": 0, + "pitch_kp": 200, + "pitch_ki": 40, "pitch_kd": 0, - "yaw_kp" : 0, + "yaw_kp" : 2000, "yaw_ki" : 0, "yaw_kd" : 0 }, "s_pid_attitude": { - "roll_kp" : 0, - "roll_ki" : 0, - "roll_kd" : 0, - "pitch_kp": 0, - "pitch_ki": 0, - "pitch_kd": 0, - "yaw_kp" : 0, + "roll_kp" : 15, + "roll_ki" : 10, + "roll_kd" : 3, + "pitch_kp": 15, + "pitch_ki": 10, + "pitch_kd": 3, + "yaw_kp" : 10, "yaw_ki" : 0, - "yaw_kd" : 0, + "yaw_kd" : 0 } } \ No newline at end of file diff --git a/pycrocart/uCartCommander.py b/pycrocart/uCartCommander.py index a5b91ef56c7507947c88306e0cd63b67e6c413c1..a2f13a078d7fcd2b92db495725b40a0354f564c6 100644 --- a/pycrocart/uCartCommander.py +++ b/pycrocart/uCartCommander.py @@ -208,9 +208,9 @@ class Commander: pk = CRTPPacket() pk.port = CRTPPort.COMMANDER_GENERIC pk.channel = SET_SETPOINT_CHANNEL - pk.data = struct.pack('<Bffff', ATTITUDE_RATE_TYPE, yawRate, + pk.data = struct.pack('<Bffff', ATTITUDE_RATE_TYPE, rollRate, pitchRate, - rollRate, thrust) # todo confirm struct is + yawRate, thrust) # todo confirm struct is # right, I tried to format it using H for the int of thrust and f for # floats otherwise. Kinda looks like what is above self._cf.send_packet(pk) @@ -230,7 +230,7 @@ class Commander: pk = CRTPPacket() pk.port = CRTPPort.COMMANDER_GENERIC pk.channel = SET_SETPOINT_CHANNEL - pk.data = struct.pack('<Bffff', ATTITUDE_TYPE, yaw, pitch, roll, + pk.data = struct.pack('<Bffff', ATTITUDE_TYPE, roll, pitch, yaw, thrust) self._cf.send_packet(pk) # todo confirm struct is right , I tried to # format it using H for the int of thrust and f for