一个python库,它有助于用复杂的马达排列来控制机器人传动系统。
simpledrivetrain的Python项目详细描述
简单的rivetrain
版本:v1.0.1
一个python库,它有助于用复杂的马达排列来控制机器人传动系统。
目录
概述
simpledrivetrain提供了一种简单的方法,可以通过电动机的位置和方向来定义传动系,并在给定传动系的总体所需平动速度和旋转速度的情况下计算每个电动机的所需速度。
当前功能
- 面向局部和面向领域的三轴平移和旋转
- 来自用户定义的脉宽调制范围或自定义缩放功能的电机级脉宽调制缩放
- 支持从XML文件加载传动系统
路线图
- 运动轮廓
- 控制回路
要求
- Python2.7+/3.x
- 努比
- lxml
安装
通过打开终端并键入以下命令,从pypi安装simpledrivetrain:
$ pip install simpledrivetrain
如何使用
导入simpledrivetrain
fromsimpledrivetrain.simple_drivetrainimportSimpleDrivetrain
创建SimpleDriveTrain对象
drivetrain=SimpleDrivetrain()
添加、删除和访问驱动电机
- 可以通过调用
add_new_motor
将电机添加到传动系中。 方法和供应:- 马达的
name
,唯一的字符串标识符 - 电动机相对于传动系的
position
以三维坐标列表的形式居中,例如[x,y,z] - 马达以三维笛卡尔方向矢量的形式正驱动
direction
例如[x,y,z] - (可选)布尔值
inverted
,用于设置电机是否反转 - 可选地,一个3元组
pwm_bounds
,形式为(full_reverse,full stop,full_forward) 调整电机速度的范围 - 可选地,一个函数
pwm_scaling_func
,它接受在[-1,1]和 将其缩放到所需的脉宽调制范围
drivetrain.add_new_motor(name,position,direction,inverted=False,pwm_bounds=(0,512,1024),pwm_scaling_func=None)
- 马达的
- 可以通过调用
remove_motor_by_name
将电机从传动系上拆下。 方法并提供要移除的电机的name
drivetrain.remove_motor_by_name(name)
或者,也可以通过调用remove_motor_by_index
方法并提供马达的index
加成drivetrain.remove_motor_by_index(index)
- 通过调用
get_motor_by_name
方法并提供 要检索的马达的name
motor=drivetrain.get_motor_by_name(name)
或者,也可以通过调用get_motor_by_index
来访问马达。 方法和提供电动机的index
加法motor=drivetrain.get_motor_by_index(index)
- 也可以通过motors实例变量访问motors,该变量存储
按添加顺序排列的电动机
motorlist=drivetrain.motors
- 或者,可以通过调用
方法并提供
load_drivetrain_from_file
字符串 指向XML文件:drivetrain.load_drivetrain_from_file(filepath)
有关示例文件,请参见Example SimpleDrivetrain xml FIle。
更新传动系方向
drivetrain.orientation=(pitch,roll,yaw)
获取运动速度
- 电机速度按[-1,1]缩放,按电机顺序存储在列表中
可以通过调用
get_motor_vels
方法和提供:translation
,表示传动系所需的三维矢量 总速度,例如[x,y,z]rotation
,表示传动系所需的三维矢量 旋转速度,例如[俯仰、滚动、偏航]force_local_oriented
,一个布尔值,如果设置为true, 忽略当前传动系方向并计算局部方向 电机值。默认设置为false。
drivetrain.get_motor_vels(translation,rotation,force_local_oriented=False)
- 根据用户定义的电机级脉宽调制范围缩放电机速度
或按电机添加顺序存储在列表中的缩放函数可以是
通过调用
get_motor_vels_scaled
方法并提供 相同的translation
,rotation
,和force_local_oriented
参数作为get_motor_vels
方法:drivetrain.get_motor_vels_scaled(translation,rotation,force_local_oriented=False)
许可证
simpledrivetrain在MIT License的条件下分布。