[Solved] Ensure Torque/Speed/Position command is executed by Solo Mini v2
Hi, I noticed that sometimes, when I send a command to a solo mini v2 using the SoloPy api, the motor doesn't react accordingly.
def test_speed(self, speed_rpm=800, accel_limit_rev_sec2=5, decel_limit_rev_sec2=5) -> None: self._solo.set_control_mode(solo.CONTROL_MODE.SPEED_MODE) self._solo.set_speed_acceleration_value(accel_limit_rev_sec2) self._solo.set_speed_deceleration_value(decel_limit_rev_sec2) self._solo.set_speed_reference(speed_rpm) sleep(3.0) actualMotorSpeed, error = self._solo.get_speed_feedback() sleep(0.5) self._solo.set_speed_reference(speed_reference=0.0)
I noticed that sometimes, the last statement to stop the motor wouldn't execute. I ran a similar test with similar logic in torque mode (last statement being
and something similar happened.
How can I make sure that the command I sent was executed properly?
we try this loop example without have error in the execution of the program:
import SoloPy as solo import time def test_speed(mySolo, speed_rpm=1000, accel_limit_rev_sec2=5, decel_limit_rev_sec2=5) -> None: print("TEST_SPEED") isSuccessful, errorType = mySolo.set_control_mode(solo.CONTROL_MODE.SPEED_MODE) print("set_control_mode is sucessfull: "+ str(isSuccessful) + " error type: " + errorType.name) isSuccessful, errorType =mySolo.set_speed_acceleration_value(accel_limit_rev_sec2) print("set_speed_acceleration_value is sucessfull: "+ str(isSuccessful) + " error type: " + errorType.name) isSuccessful, errorType =mySolo.set_speed_deceleration_value(decel_limit_rev_sec2) print("set_speed_deceleration_value is sucessfull: "+ str(isSuccessful) + " error type: " + errorType.name) isSuccessful, errorType = mySolo.set_speed_reference(speed_rpm) print("set_speed_reference is sucessfull: "+ str(isSuccessful) + " error type: " + errorType.name) time.sleep(4.0) actualMotorSpeed, errorType = mySolo.get_speed_feedback() print("get_speed_feedback is sucessfull: "+ str(actualMotorSpeed) + " error type: " + errorType.name) time.sleep(0.5) isSuccessful, errorType = mySolo.set_speed_reference(0.0) print("get_speed_feedback is sucessfull: "+ str(isSuccessful) + " error type: " + errorType.name + "\n") # instanciate a SOLO object: mySolo = solo.SoloMotorControllerUart("COM3", 0, solo.UART_BAUD_RATE.RATE_937500) while True: test_speed(mySolo) time.sleep(5)
The code is very similar we add a couple of print to check the functions return value.
Try it and let us know if you have error happening your side, we can investigate more about the reason of this problems too.
About the question "How can I make sure that the command I sent was executed properly?" you have several options, but all start by checking the return of the functions.
For example the set function return a boolean (true = Success, false= failure) and ERROR, we release a code documentation that can help you to drive a bit inside the library too.
A practical idea about the implementation can be for example if "isSuccessful" is false after the command you can repeat the command one more time, or you can loop a couple of time the command in a for-loop. All depends on your application and how you want to handle specific cases.
Hi Francesco, thanks for the feedback!
I wasn't checking the boolean returned by the set function. I will add that as you suggested and add a mechanism to resend the command. Hopefully it was just bad luck.
Out of curiosity, what can cause a function like a set function to fail execution? What causes a call to a function to return a false boolean?
There are a lot of possibilities for error to happen, but we try our best to reduce them leaving the user with minimum pressure. I think one of the most tricky error is related with the noise in the communication inside the data line, for example the cable is extremely long or pack together with other cable or the connector not well connected or using cheap cable, in this cases the communication is more hard and same information can be not accepted. In general is better to don't accept a data rather then accept a wrong one.
If you like to know more about the error type I can write a few example as:
command is not valid, setting is out of range, trial attempt overflow (we internally try to send the message if error happen), receive time error, ect. You can find a list in the SoloPy documentation here
Thanks for the detailed reply.