From 0984f3796ddf50686a2dbf2806e7710b948b2b54 Mon Sep 17 00:00:00 2001 From: maxzieba <77073326+maxzieba@users.noreply.github.com> Date: Mon, 4 Jul 2022 11:55:50 +0100 Subject: [PATCH] Joint slide fix (#45) * Fixed rounding for Tgt values * Clean up * fix * Updating copyright year and shebang --- .../src/sr_gui_joint_slider/sliders.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sr_gui_joint_slider/src/sr_gui_joint_slider/sliders.py b/sr_gui_joint_slider/src/sr_gui_joint_slider/sliders.py index fead157..8257986 100644 --- a/sr_gui_joint_slider/src/sr_gui_joint_slider/sliders.py +++ b/sr_gui_joint_slider/src/sr_gui_joint_slider/sliders.py @@ -1,6 +1,6 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -# Copyright 2012 Shadow Robot Company Ltd. +# Copyright 2012, 2022 Shadow Robot Company Ltd. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free @@ -114,7 +114,7 @@ def __init__(self, joint, uiFile, plugin_parent, parent=None): self.timer.start(200) def changeValue(self, value): - self.target.setText("Tgt: " + str(value)) + self.target.setText(f"Tgt: {value:.1f}") self.sendupdate(value) def sendupdate(self, value): @@ -191,7 +191,7 @@ def update(self): if (self.joint.controller.controller_category == "position"): self.slider.setSliderPosition(self.current_value) self.slider.setValue(self.current_value) - self.target.setText("Tgt: " + str(self.current_value)) + self.target.setText(f"Tgt: {self.current_value:.1f}") else: self.target.setText("Tgt: 0.0") self.first_update_done = True @@ -205,7 +205,7 @@ def refresh(self): if (self.joint.controller.controller_category == "position"): self.slider.setSliderPosition(self.current_value) self.slider.setValue(self.current_value) - self.target.setText("Tgt: " + str(self.current_value)) + self.target.setText(f"Tgt: {self.current_value:.1f}") def set_slider_behaviour(self): """ @@ -271,7 +271,7 @@ def update(self): if not self.first_update_done: self.slider.setSliderPosition(self.current_value) self.slider.setValue(self.current_value) - self.target.setText("Tgt: " + str(self.current_value)) + self.target.setText(f"Tgt: {self.current_value:.1f}") self.first_update_done = True except Exception: @@ -283,7 +283,7 @@ def refresh(self): """ self.slider.setSliderPosition(self.current_value) self.slider.setValue(self.current_value) - self.target.setText("Tgt: " + str(self.current_value)) + self.target.setText(f"Tgt: {self.current_value:.1f}") def set_slider_behaviour(self): """ @@ -362,9 +362,9 @@ def set_slider_behaviour(self): if (slider.joint.controller.controller_category == "effort")\ or (slider.joint.controller.controller_category == "velocity"): self.slider.sliderReleased.connect(self.on_slider_released) - self.slider.setSliderPosition(50) self.current_value = 50 - self.target.setText("Tgt: " + str(50) + "%") + self.slider.setSliderPosition(self.current_value) + self.target.setText(f"Tgt: {self.current_value:.1f}%") break def changeValue(self, value): @@ -379,7 +379,7 @@ def changeValue(self, value): slider.changeValue(temp_value) self.current_value = value - self.target.setText("Tgt: " + str(value) + "%") + self.target.setText(f"Tgt: {self.current_value:.1f}") def on_slider_released(self): for slider in self.plugin_parent.sliders: @@ -388,6 +388,6 @@ def on_slider_released(self): or (slider.joint.controller.controller_category == "velocity"): slider.slider.setSliderPosition(0) slider.changeValue(0) - self.slider.setSliderPosition(50) self.current_value = 50 - self.target.setText("Tgt: " + str(50) + "%") + self.slider.setSliderPosition(self.current_value) + self.target.setText(f"Tgt: {self.current_value:.1f}%")