MIT模式的使用方法
SDK:
C++
- 单执行器
motor.mode_selection(Mode::MIT_MODE, xx, xx, xx)
motor.write_mit(Target current, Target velocity, Target position, KP, KD)
demo 固定电流
❗
目标电流不为0,其他都为0
#include <motor_control.h>
string port_name = "COM27" // Windows: "COM*" Linux: "/dev/ttyUSB*"
MotorControl motor(port_name, 921600, 0x01); // Params: serial port path (string), baud rate (uint32_t), actuator id (0x05060100)
int main()
{
motor.mode_selection(Mode::MIT_MODE, 10, 10, 10); // Params: Mode::operation mode, feedback cycle 1, 2, 3
Sleep(10); // Windows: Sleep(ms) Linux: sleep(s)
motor.write_mit(500, 0, 0, 0.0, 0.0); // Params: target current, target velocity, target position, kp, kd
}
固定速度(电流的大小应视情况而定)
❗
目标位置和KP为0,其他不为0
#include <motor_control.h>
string port_name = "COM27"; // Windows: "COM*" Linux: "/dev/ttyUSB*"
MotorControl motor(port_name, 921600, 0x01); // Params: serial port path (string), baud rate (uint32_t), actuator id (0x05060100)
int main()
{
motor.mode_selection(Mode::MIT_MODE, 10, 10, 10); // Params: Mode::operation mode, feedback cycle 1, 2, 3
Sleep(10); // Windows: Sleep(ms) Linux: sleep(s)
motor.write_mit(300, 500, 0, 0.0, 10.0); // Params: target current, target velocity, target position, kp, kd
}
点到点(电流的大小应视情况而定)
❗
目标速度为0,其他不为0
#include <motor_control.h>
string port_name = "COM27"; // Windows: "COM*" Linux: "/dev/ttyUSB*"
MotorControl motor(port_name, 921600, 0x01); // Params: serial port path (string), baud rate (uint32_t), actuator id (0x05060100)
int main()
{
motor.mode_selection(Mode::MIT_MODE, 10, 10, 10); // Params: Mode::operation mode, feedback cycle 1, 2, 3
Sleep(10); // Windows: Sleep(ms) Linux: sleep(s)
motor.write_mit(300, 0, 65535, 13.1, 10.0); // Params: target current, target velocity, target position, kp, kd
}
- 多执行器
motors.mode_selection(Mode::MIT_MODE, xx, xx, xx)
motors.write_mit(vector<int16_t>target current, vector<int16_t>target velocity, vector<int16_t>target position, vector<float>KP, vector<float>KD)
demo: 固定电流
❗
目标电流不为0,其他都为0
#include <multi_motor_control.h>
vector<int16_t>cur = { 500, 500 };
vector<int16_t>vel = { 0, 0 };
vector<int32_t>pos = { 0, 0 };
vector<float>kp = { 0.0, 0.0 };
//vector<float>kd = { 0.0, 0.0 };
string port_name = "COM27"; // Windows: "COM*" Linux: "/dev/ttyUSB*"
MultiMotorControl motors(port_name, 921600, ids); // Params: serial port path (string), baud rate (uint32_t), actuator ids (0x05060100, 0x05061700)
int main()
{
motors.mode_selection(Mode::MIT_MODE, 10, 10, 10); // Params: Mode::operation mode, feedback cycle 1, 2, 3
Sleep(10); // Windows: Sleep(ms) Linux: sleep(s)
motors.write_mit(cur, vel, pos, kp, kd); // Params: vector of target current, vector of target velocity, vector of target position,
// vector of kp, vector of kd
}
固定速度(电流的大小应视情况而定)
❗
目标位置和KP为0,其他不为0
#include <multi_motor_control.h>
vector<int16_t>cur = { 300, 300 };
vector<int16_t>vel = { 500, 500 };
vector<int32_t>pos = { 0, 0 };
vector<float>kp = { 0.0, 0.0 };
vector<float>kd = { 10.0, 10.0 };
vector<uint8_t>ids = { 0x01, 0x17 };
string port_name = "COM27"; // Windows: "COM*" Linux: "/dev/ttyUSB*"
MultiMotorControl motors(port_name, 921600, ids); // Params: serial port path (string), baud rate (uint32_t), actuator ids (0x05060100, 0x05061700)
int main()
{
motors.mode_selection(Mode::MIT_MODE, 10, 10, 10); // Params: Mode::operation mode, feedback cycle 1, 2, 3
Sleep(10); // Windows: Sleep(ms) Linux: sleep(s)
motors.write_mit(cur, vel, pos, kp, kd); // Params: vector of target current, vector of target velocity, vector of target position,
// vector of kp, vector of kd
}
点到点(电流的大小应视情况而定)
❗
目标速度为0,其他不为0
#include <multi_motor_control.h>
vector<int16_t>cur = { 300, 300 };
vector<int16_t>vel = { 0, 0 };
vector<int32_t>pos = { 65535, 65535 };
vector<float>kp = { 13.1, 13.1 };
vector<float>kd = { 10.0, 10.0 };
vector<uint8_t>ids = { 0x01, 0x17 };
string port_name = "COM27"; // Windows: "COM*" Linux: "/dev/ttyUSB*"
MultiMotorControl motors(port_name, 921600, ids); // Params: serial port path (string), baud rate (uint32_t), actuator ids (0x05060100, 0x05061700)
int main()
{
motors.mode_selection(Mode::MIT_MODE, 10, 10, 10); // Params: Mode::operation mode, feedback cycle 1, 2, 3
Sleep(10); // Windows: Sleep(ms) Linux: sleep(s)
motors.write_mit(cur, vel, pos, kp, kd); // Params: vector of target current, vector of target velocity, vector of target position,
// vector of kp, vector of kd
}
Python
mode_selection(MotorControl object, MIT_MODE, xx, xx, xx)
write_mit(MotorControl object, [Target current], [Target velocity], [Target position], [KP], [KD])
demo: 点到点
❗
目标速度为0,其他不为0
from motor_control import *
id = [0x01, 0x17] # list of int
cur = [300, 300] # list of int
vel = [0, 0] # list of int
pos = [65535, 65535] # list of int
kp = [13.1, 13.1] # list of float
kd = [10.0, 10.0] # list of float
port_name = "COM27" # Windows: "COM*" Linux: "/dev/ttyUSB*"
motor = MotorControl(port_name, id, 921600) # Params: serial port (str), list of actuator ID (0x05060100, 0x05061700)
mode_selection(motor, MIT_MODE, 10, 10, 10) # Params: MotorControl object, operation mode, feedback cycle 1, 2, 3
time.sleep(0.01)
write_mit(motor, cur, vel, pos, kp, kd) # Params: MotorControl object, list of target current, list of target velocity, list of target position, list of KP, list of KD
固定速度(电流的大小应视情况而定)
❗
目标位置和KP为0,其他不为0
from motor_control import *
id = [0x01, 0x17] # list of int
cur = [300, 300] # list of int
vel = [500, 500] # list of int
pos = [0, 0] # list of int
kp = [0.0, 0.0] # list of float
kd = [10.0, 10.0] # list of float
port_name = "COM27" # Windows: "COM*" Linux: "/dev/ttyUSB*"
motor = MotorControl(port_name, id, 921600) # Params: serial port (str), list of actuator ID (0x05060100, 0x05061700)
mode_selection(motor, MIT_MODE, 10, 10, 10) # Params: MotorControl object, operation mode, feedback cycle 1, 2, 3
time.sleep(0.01)
write_mit(motor, cur, vel, pos, kp, kd) # Params: MotorControl object, list of target current, list of target velocity, list of target position, list of KP, list of KD
固定扭矩(电流的大小应视情况而定)
❗
目标电流不为0,其他都为0
from motor_control import *
id = [0x01, 0x17] # list of int
cur = [500, 500] # list of int
vel = [0, 0] # list of int
pos = [0, 0] # list of int
kp = [0.0, 0.0] # list of float
kd = [0.0, 0.0] # list of float
port_name = "COM27" # Windows: "COM*" Linux: "/dev/ttyUSB*"
motor = MotorControl(port_name, id, 921600) # Params: serial port (str), list of actuator ID (0x05060100, 0x05061700)
mode_selection(motor, MIT_MODE, 10, 10, 10) # Params: MotorControl object, operation mode, feedback cycle 1, 2, 3
time.sleep(0.01)
write_mit(motor, cur, vel, pos, kp, kd) # Params: MotorControl object, list of target current, list of target velocity, list of target position, list of KP, list of KD