i am Robert from Germany and i need some help. I am a newbie with vesc, so please apologize my stupid questions. I am trying to control a servo (https://www.zappenduster-rc.de/ele test and checkktronik-und-zubehoer/servos/standard-groesse/standard-48-60-volt/traxxas-digital- test and checkservo-waterproof-2075-trx2075.html), via the ppm signal of the vesc. This should happen via a python script. I am using the library pyvesc by LiamBindle. The packages from the pyVesc library, should be send with the library pySerial. Im already able to control the “Main” Motor (https://www.amazon.de/Traxxas-Brushless-Velineon-3500-Motor-Kfz-Teile/dp/B00XWTXOCC), via the python script. But actually i am failing to control the servo. I tried at first, to control the servo from the vesc tool but i did not found any possibility to do this. So i tried to create a new message in pyvesc, but when i execute the script to control the servo, nothing happens. So how am i able to control a servo with a vesc? I really appreciate your help and some information.
The source code for the python script is the following:
import serial import pyvesc #creating the new messsage class SetServoPos(metaclass=pyvesc.VESCMessage): id = 12 fields = [ ('servo', 'i') ] def setrpm(): # function to set the rpm of the motor: This function works properly ser = serial.Serial('/dev/ttyACM0') my_msg = pyvesc.SetRPM(5000) my_packet = pyvesc.encode(my_msg) ser.write(my_packet) print("Hello") ser.close() def steering(): # function to control the servo: In this function is the issue. ser = serial.Serial('/dev/ttyACM0') my_msg = SetServoPos(180) print(my_msg.servo) my_packet = pyvesc.encode(my_msg) ser.write(my_packet) ser.close() #MainFunction if __name__ == '__main__': steering()
Attached you find a picture of the servo and the vesc.