本文整理汇总了Python中PyMata.pymata.PyMata.get_firmata_firmware_version方法的典型用法代码示例。如果您正苦于以下问题:Python PyMata.get_firmata_firmware_version方法的具体用法?Python PyMata.get_firmata_firmware_version怎么用?Python PyMata.get_firmata_firmware_version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyMata.pymata.PyMata
的用法示例。
在下文中一共展示了PyMata.get_firmata_firmware_version方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: servo_callback
# 需要导入模块: from PyMata.pymata import PyMata [as 别名]
# 或者: from PyMata.pymata.PyMata import get_firmata_firmware_version [as 别名]
def servo_callback(data):
if DEBUG:
print("SUB:DATA:"+str(data.data))
'''write to servo port'''
pos=int(data.data)
''' fake map adc values 0-1024 to 0-180 for servo '''
pos=int(pos/6)
if DEBUG:
print("Set servo to: "+str(pos))
board.analog_write(SERVO_PIN, pos)
if __name__ == '__main__':
try:
''' init ros node '''
pub_adc = rospy.Publisher("pymata/adc", String, queue_size=10)
rospy.init_node("pymata")
rospy.Subscriber("pymata/adc", String, servo_callback)
''' init pymata and ports '''
board = PyMata(USB_PORT)
if DEBUG:
board.refresh_report_firmware()
print(board.get_firmata_firmware_version())
board.servo_config(SERVO_PIN)
board.set_pin_mode(ADC_PIN,board.INPUT,board.ANALOG,adc_callback)
''' ros loop '''
rospy.spin()
except rospy.ROSInterruptException: pass