The raeros_servo
package is based on ROS and consists of several ROS-services to access the functionalities of the Lynsmotion LSS Smartservo.
More information about the servomotor you get here.
Install it from source with:
cd ~/catkin_ws/src &&
git clone -b melodic https://github.com/romzn/raeros_servo.git &&
cd ../../ &&
catkin_make
First of all create a ros-package and open a new python file inside the scripts
folder.
from raerspy_servo_client.ServoClient import ServocClient()
import rospy
if __name__ == "__main__":
rospy.init_node()
servo = ServoClient()
# User code
Jogging let drives the servomotor with an specified velocity. The following command drives the Motor with 100 °/sec and stops if there is an resistance which leads to more than 900 mAmps. After stopping it holds the Position with 400 mAmps.
servo.jog(speed=100, current=900)
Without specified parameters servo.jog()
the default value for the current is 700. The Speed also determines the direction. For example if you specify -100 as speed parameter servo.jog(-100)
the servo drives in the opposite direction.
The Servomotor holds the current position with a maximum of 400 mA which is about 3 Nm stall torque.
servo.hold()
The servomotor turns the current off so that rotating the shaft by hand is possible
servo.limp()
Sets the current position to zero. This is important for absolute position commands.
servo.zero()
servo.moveAbsolute(position=2000, current=900)
Resets the motor. This is necessary to recover the motor when it is in error state.
servo.reset()
Change the color of the servo LED to your preffered color.
servo.led_to(color)
avaliable-colors : [black, red, green, blue, yellow, cyan, magenta, white]
Returns the motor mode as string.
servo.motorMode()
Can be Unknown, Limp, Free Moving, Accelerating, Traveling, Decelerating, Holding, Outside limits, Stuck, Blocked, Safe Mode