Skip to content

Commit ad2efcf

Browse files
author
Leonid Fedorenchik
committed
fix(mycobotpro630): Fix set get digital analog pin with wrong types
1 parent 264ccea commit ad2efcf

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

pymycobot/elephantrobot.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ def get_digital_in(self, pin_number):
746746
Returns:
747747
int: State of the pin (0 or 1).
748748
"""
749-
command = "get_digital_in(" + str(pin_number) + ")\n"
749+
command = "get_digital_in(" + str(int(pin_number)) + ")\n"
750750
res = self.send_command(command)
751751
return self.string_to_int(res)
752752

@@ -759,7 +759,7 @@ def get_digital_out(self, pin_number):
759759
Returns:
760760
int: State of the pin (0 or 1).
761761
"""
762-
command = "get_digital_out(" + str(pin_number) + ")\n"
762+
command = "get_digital_out(" + str(int(pin_number)) + ")\n"
763763
print(command)
764764
res = self.send_command(command)
765765
return self.string_to_int(res)
@@ -771,7 +771,13 @@ def set_digital_out(self, pin_number, pin_signal):
771771
pin_number (int): Pin number (0-63).
772772
pin_signal (int): Signal to set (0 or 1).
773773
"""
774-
command = "set_digital_out(" + str(pin_number) + "," + str(pin_signal) + ")\n"
774+
command = (
775+
"set_digital_out("
776+
+ str(int(pin_number))
777+
+ ","
778+
+ str(int(pin_signal))
779+
+ ")\n"
780+
)
775781
self.send_command(command)
776782

777783
def get_analog_in(self, pin_number):
@@ -783,7 +789,7 @@ def get_analog_in(self, pin_number):
783789
Returns:
784790
float: pin value
785791
"""
786-
command = "get_analog_in(" + str(pin_number) + ")\n"
792+
command = "get_analog_in(" + str(int(pin_number)) + ")\n"
787793
res = self.send_command(command)
788794
return self.string_to_double(res)
789795

@@ -796,7 +802,7 @@ def get_analog_out(self, pin_number):
796802
Returns:
797803
float: pin value
798804
"""
799-
command = "get_analog_out(" + str(pin_number) + ")\n"
805+
command = "get_analog_out(" + str(int(pin_number)) + ")\n"
800806
res = self.send_command(command)
801807
return self.string_to_double(res)
802808

@@ -807,7 +813,9 @@ def set_analog_out(self, pin_number, pin_value):
807813
pin_number (int): pin number (0~63).
808814
pin_value (float): pin value
809815
"""
810-
command = "set_analog_out(" + str(pin_number) + "," + str(pin_value) + ")\n"
816+
command = (
817+
"set_analog_out(" + str(int(pin_number)) + "," + str(int(pin_value)) + ")\n"
818+
)
811819
self.send_command(command)
812820

813821
def get_joint_current(self, joint_number):
@@ -918,7 +926,7 @@ def enable_manual_brake_control(self, enable=True):
918926
enable (bool, optional): enable (True) or disable (False) manual
919927
brake control. Defaults to True.
920928
"""
921-
self.set_digital_out(DO.BRAKE_MANUAL_MODE_ENABLE, enable)
929+
self.set_digital_out(DO.BRAKE_MANUAL_MODE_ENABLE.value, enable)
922930
time.sleep(0.05)
923931
for joint in Joint:
924932
self.release_joint_brake(joint, False)
@@ -930,15 +938,15 @@ def release_joint_brake(self, joint, release=True):
930938
joint (Joint): joint Joint.J1 ~ Joint.J6
931939
release (bool): True to release, False to enable brake. Defaults to True.
932940
"""
933-
self.set_digital_out(DO(joint.value + DO.J1_BRAKE_RELEASE.value), release)
941+
self.set_digital_out(DO(joint.value + DO.J1_BRAKE_RELEASE.value).value, release)
934942

935943
def is_collision_detected(self):
936944
"""Checks if collision is detected.
937945
938946
Returns:
939947
bool: True if collision is detected, False otherwise.
940948
"""
941-
return self.get_digital_in(DI.COLLISION_DETECTED) == 1
949+
return self.get_digital_in(DI.COLLISION_DETECTED.value) == 1
942950

943951
def set_gripper_state(self, state, speed):
944952
"""Sets gripper state.

0 commit comments

Comments
 (0)