odrive入门教程(securecrt使用教程串口)

ODrive官方入门指南中,采用的是USB连接控制模式(中文翻译版本链接)使用的是NativeProtocol。当我们需要尝试串口通信实现时,需要专程ASCII协议来进行串口通信实现相关的命令,结合着入门指南以及ODrive中的相关属性方法参数,将流程中用到的相关方法整理如下:importserialimporttimeted=serial.Serial(port=’/dev/tty.wchusbserial1470′,baudrate=115200)ted.writ

大家好,又见面了,我是你们的朋友全栈君。

ODrive 官方入门指南中,采用的是 USB 连接控制模式(中文翻译版本链接)使用的是 Native Protocol。当我们需要尝试串口通信实现时,需要专程 ASCII 协议来进行串口通信实现相关的命令,结合着入门指南以及 ODrive 中的相关属性方法参数,将流程中用到的相关方法整理如下:

import serial
import time

ted = serial.Serial(port='/dev/tty.wchusbserial1470', baudrate=115200)

ted.write("r vbus_voltage;ted's words\n".encode('ascii'))
vbus_voltage = float(ted.readline().decode('ascii'))
print("vbus_voltage:",vbus_voltage,type(vbus_voltage))

# Current limit
ted.write("r axis0.motor.config.current_lim\n".encode('ascii'))
axis0_motor_config_current_lim = float(ted.readline().decode('ascii'))
print("axis0.motor.config.current_lim:",axis0_motor_config_current_lim,type(axis0_motor_config_current_lim))

# Velocity limit
ted.write("r axis0.controller.config.vel_limit\n".encode('ascii'))
axis0_controller_config_vel_limit = float(ted.readline().decode('ascii'))
print("axis0.controller.config.vel_limit:",axis0_controller_config_vel_limit,type(axis0_controller_config_vel_limit))

# Calibration current
ted.write("r axis0.motor.config.calibration_current\n".encode('ascii'))
axis0_motor_config_calibration_current = float(ted.readline().decode('ascii'))
print("axis0.motor.config.calibration_current:",axis0_motor_config_calibration_current,type(axis0_motor_config_calibration_current))

# brake_resistance
ted.write("r config.brake_resistance\n".encode('ascii'))
config_brake_resistance = float(ted.readline().decode('ascii'))
print("config.brake_resistance:",config_brake_resistance,type(config_brake_resistance))

# pole_pairs
ted.write("r axis0.motor.config.pole_pairs\n".encode('ascii'))
axis0_motor_config_pole_pairs = int(ted.readline().decode('ascii'))
print("axis0.motor.config.pole_pairs:",axis0_motor_config_pole_pairs,type(axis0_motor_config_pole_pairs))

# motor_type
ted.write("r axis0.motor.config.motor_type\n".encode('ascii'))
axis0_motor_config_motor_type = int(ted.readline().decode('ascii'))
print("axis0.motor.config.motor_type:",axis0_motor_config_motor_type,type(axis0_motor_config_motor_type))

print("~"*20)
# cpr
ted.write("r axis0.encoder.config.cpr\n".encode('ascii'))
axis0_encoder_config_cpr = int(ted.readline().decode('ascii'))
print("axis0.encoder.config.cpr:",axis0_encoder_config_cpr,type(axis0_encoder_config_cpr))

ted.write("w axis0.encoder.config.cpr 4096\n".encode('ascii'))

ted.write("r axis0.encoder.config.cpr\n".encode('ascii'))
axis0_encoder_config_cpr2 = int(ted.readline().decode('ascii'))
print("axis0.encoder.config.cpr modified:",axis0_encoder_config_cpr2,type(axis0_encoder_config_cpr2))

print("~"*20)

# Save configuration
ted.write("ss\n".encode('ascii'))

# Position control
""" AXIS_STATE_UNDEFINED = 0 AXIS_STATE_IDLE = 1 AXIS_STATE_STARTUP_SEQUENCE = 2 AXIS_STATE_FULL_CALIBRATION_SEQUENCE = 3 AXIS_STATE_MOTOR_CALIBRATION = 4 AXIS_STATE_SENSORLESS_CONTROL = 5 AXIS_STATE_ENCODER_INDEX_SEARCH = 6 AXIS_STATE_ENCODER_OFFSET_CALIBRATION = 7 AXIS_STATE_CLOSED_LOOP_CONTROL = 8 AXIS_STATE_LOCKIN_SPIN = 9 AXIS_STATE_ENCODER_DIR_FIND = 10 """
ted.write("r axis0.current_state\n".encode('ascii'))
axis0_current_state = int(ted.readline().decode('ascii'))
print("axis0.current_state:",axis0_current_state,type(axis0_current_state))

# AXIS_STATE_FULL_CALIBRATION_SEQUENCE
ted.write("w axis0.requested_state 3\n".encode('ascii'))
print("校准电机...")
time.sleep(15)
ted.write("r axis0.current_state\n".encode('ascii'))
axis0_current_state2 = int(ted.readline().decode('ascii'))
print("axis0.current_state modified:",axis0_current_state2,type(axis0_current_state2))

# AXIS_STATE_CLOSED_LOOP_CONTROL
ted.write("w axis0.requested_state 8\n".encode('ascii'))

ted.write("r axis0.current_state\n".encode('ascii'))
axis0_current_state3 = int(ted.readline().decode('ascii'))
print("axis0.current_state modified again:",axis0_current_state3,type(axis0_current_state3))

ted.write("w axis0.controller.pos_setpoint 10000\n".encode('ascii'))




版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/127520.html原文链接:https://javaforall.net

赞 (0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • BP神经网络预测matlab代码讲解与实现步骤

    BP神经网络预测matlab代码讲解与实现步骤文章目录1.BP神经网络的简介和结构参数1.1BP神经网络的结构组成1.2BP神经网络训练界面的参数解读2.实现BP网络的步骤3.matlab代码编写4.BP代码运行结果4.1预测值和真实值的误差计算(MAE、MSE、MRSE)4.2BP网络训练的性能分析图像5.结语6.MATLAB代码1.BP神经网络的简介和结构参数神经网络是机器学习中一种常见的数学模型,通过构建类似于大脑神经突触联接的结构,来进行信息处理。在应用神经网络的过程中,处理信息的单元一般分为三类:输入单元、输出单元和

    2022年6月20日
  • 读完了csapp(中文名:深入理解计算机系统)

    读完了csapp(中文名:深入理解计算机系统)

    2021年11月30日
  • java 什么是实例化[通俗易懂]

    创建对象的过程就叫实例化,因此有时候我们也将对象叫做一个类的实例。例如:“Demo demo = new Demo();”。

    2022年1月16日
  • 如何在excel2019指定的单元格中插入图片

    如何在excel2019指定的单元格中插入图片最近,要完成一些论文的调研及整理工作,针对各个论文中提到的方法,系统模型等。原想在单元格中插入图片,发现单元格右键插入,压根就没插入图片这一项功能,如图所示故在菜单栏中,找到插入-》图片-》此设备,插入完成后,图片能在整个界面上移动。完全不是我想要的结果。问题解决办法如下:1、选中一个想要放入的单元格,尽量拉的大一点。2、把已插入的图拖到这个单元格内,大致调整一下大小,使其和单元格大小差不多。3、选中图片右键“大小和属性”。4、作如图设置,将属性选为“随单元格改变位置和大

    2022年10月29日
  • soapui的菜鸟教程

    soapui的菜鸟教程soapui的菜鸟教程

    2022年6月22日
  • JavaScript 引擎性能比较之一SpiderMonkey[通俗易懂]

    JavaScript 引擎性能比较之一SpiderMonkey[通俗易懂]1.下载https://people.mozilla.org/~sstangl/mozjs-31.2.0.rc0.tar.bz2bunzip2mozjs-31.2.0.rc0.tar.bz2tarxvfmozjs-31.2.0.rc0.tar2.构建https://developer.mozilla.org/en-US/docs/Mozilla/Projects/

    2022年10月8日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号