Skip to content

Commit

Permalink
Joint slide fix (#45)
Browse files Browse the repository at this point in the history
* Fixed rounding for Tgt values

* Clean up

* fix

* Updating copyright year and shebang
  • Loading branch information
maxzieba authored Jul 4, 2022
1 parent 77eea45 commit 0984f37
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions sr_gui_joint_slider/src/sr_gui_joint_slider/sliders.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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):
"""
Expand Down Expand Up @@ -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:
Expand All @@ -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):
"""
Expand Down Expand Up @@ -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):
Expand All @@ -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:
Expand All @@ -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}%")

0 comments on commit 0984f37

Please sign in to comment.