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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • PM3激活成功教程加密IC卡

    PM3激活成功教程加密IC卡IC卡已经在我们的生活中无处不在了,门禁,电梯,吃饭,洗车,可以说与我们的生活息息相关了。(为了把加密的校园一卡通复制到我的小米手环上,我也是煞费苦心,看网上各种大佬教程)但是如果有一天,你的门禁卡丢了,怎么配呢?跟配钥匙一样的,必须现有原钥匙才可以。那我们今天就看看,如何用PM3来配门禁卡钥匙。准备好门禁母卡和复制的空白卡,复制的全过程是这样的。放原卡-》读卡-》激活成功教程密码-》读出数据-》放新卡-》写入数据-》完成复制!1、连接好PM3硬件设备,运行我们的杀手锏软件PM3的gui版本很多,我们

    2022年6月25日
    59
  • yui compressor php,通过yuicompressor-2.4.7压缩css或js的php应用文件

    yui compressor php,通过yuicompressor-2.4.7压缩css或js的php应用文件yuicompressor这是个很好的工具,通过java库编译css或js文件进行压缩。压缩css或者js文件的好处是很多的,减少数据请求量,可以更快的进行数据传输,防止其他人进行窥探或整体直接挪用等等。。。首先你要去下载一个yuicompressor现在最新版本是2.4.7下载地址:yuicompressor使用方法怎么工作在这里都有详细的说明,就不一一介绍了。最常用的yuicompre…

    2022年7月18日
    14
  • activity跳转activity不销毁

    activity跳转activity不销毁最近在做菜单,有三个界面分别用activity来显示,如ActivityA -> ActivityB -> ActivityC,返回键ActivityC -> ActivityB -> ActivityA,当从A进入到B时按返回键无法退到A,是因为在A进入B时用了finish()方法,把A给销毁了,如下:finish();IntentaToB=newI

    2022年5月22日
    43
  • SQL基础语句大全

    SQL基础语句大全SQL基础语句大全此文章基本涵盖SQL的基础应用语句你好!这是本人在大学自学Java时记录的SQL基础语句,希望可以对自学的小白们给与一定帮助,有错误也欢迎大家可以帮助纠正。数据类型1.整数:int和bigintbigint等效Java中的long2.浮点数:double(m,d)m总长度d小数长度eg:double(5,3)26.789decimal是一个超高…

    2022年5月1日
    41
  • XGBoost原理介绍

    XGBoost原理介绍 1.Introduction在这篇文章中,我将介绍XGBoost(eXtremeGradientBoosting),一种treeboosting的可扩展机器学习系统。这个系统可以作为开源的软件包使用。该系统的影响已经在大量的机器学习和数据挖掘挑战中被广泛地认可。这些获胜解决方案包括:商店销售预测;高能物理事件分类;网络文本分类;顾客行为预测;运动检测;广告点击率预测;…

    2022年6月7日
    41
  • C# 哈希_java哈希码

    C# 哈希_java哈希码文件哈希码比较,用于更新文件publicstaticboolCompareFile(stringstr1,stringstr2)    {      stringp_1=str1;      stringp_2=str2;      //计算第一个文件的哈希值      varha

    2025年6月26日
    0

发表回复

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

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