Skip to main content
Version: Next

C++

Configure the Environment

  • Linux:
  1. Execute the following commands in the terminal(Download the serial library):
git clone     https://github.com/wjwwood/serial.git
cd serial
mkdir build
cd build
cmake ..
make
sudo make install
  1. In the terminal under the TA_CAN\C++\Linux\build path, enter cmake .. to generate the build file, then entermake to generate the executable
  • Windows:
  1. Download Visual Studio and install "Desktop Development with C++" (Case: Visual Studio 2022)

  2. Install CMake https://cmake.org/download/

  3. Development tools (choose one):

  • Visual Studio Code:
  1. Compile serial in Developer Command Prompt for VS 2022
cd <Project Path>\TA_CAN\C++\Windows\serial\build
cmake -G "Visual Studio 17 2022" ..
cmake --build . --config Release
  1. Change the serial path in the CMakeLists.txt file under the TA_CAN\C++\Windows\vs_code path to the local path

  2. Compiling an executable in the Developer Command Prompt for VS 2022

cd <Project Path>\TA_CAN\C++\Windows\vs_code\build
cmake -G "Visual Studio 17 2022" ..
cmake --build . --config Release
  • Visual Studio 2022:
  1. Compile serial in Developer Command Prompt for VS 2022
cd <Project Path>\TA_CAN\C++\Windows\serial\build
cmake -G "Visual Studio 17 2022" ..
cmake --build . --config Release
  1. Change the serial path in the CMakeLists.txt file under the TA_CAN\C++\Windows\vs\project path to the local path The configuration must be Release. If Debug is selected, the serial version needs to be recompiled

Creating Class Objects

  • Single Actuator

demo:

#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)
  • Multiple Actuators

demo:

#include <multi_motor_control.h>
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)

Modify Class Object ID

  • Single Actuator

motor.set_obhect_id(new_id);

demo: Change ID to 0x00

#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.set_obhect_id(0x00);
}
  • Multiple Actuators

motors.set_obhect_id(vector<uint8_t> new_id);

demo: Change ID to 0x00 and 0x01

#include <multi_motor_control.h>
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.set_obhect_id({0x00, 0x01});
}

Reset

  • Single Actuator

vector<int> result = motor.reset();

Phenomenon: The actuator LED turns red first and then blue

Returns the serial number and update date

demo:

#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.reset();
}
  • Multiple Actuators

vector<vector<int>> result = motors.reset();

Phenomenon: The actuator LED turns red first and then blue

Returns the serial number and update date

demo:

#include <multi_motor_control.h>
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.reset();
}

Mode Selection

  • Single Actuator
motor.mode_selection(Mode::<b>Control mode</b>, Feedback cycle 1, Feedback cycle 2, Feedback cycle 3);

For control mode selection, please refer to Control Mode

demo: Enter Profile Velocity Mode

#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::PROFILE_VELOCITY_MODE, 10, 10, 10); // Params: Mode::operation mode, feedback cycle 1, 2, 3
}
  • Multiple Actuators
motors.mode_selection(Mode::<b>Control mode</b>, Feedback cycle 1, Feedback cycle 2, Feedback cycle 3);

For control mode selection, please refer to Control Mode

demo: Enter Profile Velocity Mode

#include <multi_motor_control.h>
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::PROFILE_VELOCITY_MODE, 10, 10, 10); // Params: Mode::operation mode, feedback cycle 1, 2, 3
}
  • Control mode

ASYNC Mode

  • Single Actuator
motor.mode_selection(Mode::ASYNC_MODE, xx, xx, xx)
motor.write_async(Duty value)

(Try not to use it if there is no abnormality in the actuator)

demo: Set Duty Value to 500

#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::ASYNC_MODE, 10, 10, 10); // Params: Mode::operation mode, feedback cycle 1, 2, 3
motor.write_async(500); // Params: duty values
}
  • Multiple Actuators
motors.mode_selection(Mode::ASYNC_MODE, xx, xx, xx)
motors.write_async(vector<int16_t>Duty value)

(Try not to use it if there is no abnormality in the actuator)

demo: Set Duty Value to 500

#include <multi_motor_control.h>
vector<int16_t>duty_values = { 500, 500};
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::ASYNC_MODE, 10, 10, 10); // Params: Mode::operation mode, feedback cycle 1, 2, 3
motors.write_async(duty_values); // Params: vector of duty values
}

Open Loop Mode

  • Single Actuator
motor.mode_selection(Mode::OPEN_LOOP_MODE, xx, xx, xx)
motor.write_open_loop(Duty value)

(Try not to use it if there is no abnormality in the actuator)

demo: Set Duty Value to 500

#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::OPEN_LOOP_MODE, 10, 10, 10); // Params: Mode::operation mode, feedback cycle 1, 2, 3
motor.write_open_loop(500); // Params: duty values
}
  • Multiple Actuators
motors.mode_selection(Mode::OPEN_LOOP_MODE, xx, xx, xx)
motors.write_open_loop(vector<int16_t>Duty value)

(Try not to use it if there is no abnormality in the actuator)

demo: Set Duty Value to 500

#include <multi_motor_control.h>
vector<int16_t>duty_values = { 300, 300 };
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::OPEN_LOOP_MODE, 10, 10, 10); // Params: Mode::operation mode, feedback cycle 1, 2, 3
motors.write_open_loop(duty_values); // Params: vector of duty values
}

Current Mode

  • Single Actuator
motor.mode_selection(Mode::CURRENT_MODE, xx, xx, xx);
motor.write_current(Target current);

demo: Set Target Current to 500mA

#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::CURRENT_MODE, 10, 10, 10); // Params: Mode::operation mode, feedback cycle 1, 2, 3
motor.write_current(500); // Params: target current
}
  • Multiple Actuators
motors.mode_selection(Mode::CURRENT_MODE, xx, xx, xx);
motors.write_current(vector<int16_t> Target current);

demo: Set Target Current to 500mA

#include <multi_motor_control.h>
vector<int16_t>cur = { 500, 500 };
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::CURRENT_MODE, 10, 10, 10); // Params: Mode::operation mode, feedback cycle 1, 2, 3
motors.write_current(cur); // Params: vector of target current
}

Profile Velocity Mode

  • Single Actuator
motor.mode_selection(Mode::PROFILE_VELOCITY_MODE, xx, xx, xx)
motor.write_profile_velocity(Current limit, Target velocity)

demo: Set Target Velocity to 500rpm

#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::PROFILE_VELOCITY_MODE, 10, 10, 10); // Params: Mode::operation mode, feedback cycle 1, 2, 3
motor.write_profile_velocity(2000, 500); // Params: current limit, target velocity
}
  • Multiple Actuators
motors.mode_selection(Mode::PROFILE_VELOCITY_MODE, xx, xx, xx)
motors.write_profile_velocity(vector<int16_t>Current limit, vector<int16_t>Target velocity)

demo: Set Target Velocity to 500rpm

#include <multi_motor_control.h>
vector<int16_t>cur = { 3000, 3000 };
vector<int16_t>vel = { 500, 500 };
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::PROFILE_VELOCITY_MODE, 10, 10, 10); // Params: Mode::operation mode, feedback cycle 1, 2, 3
motors.write_profile_velocity(cur, vel); // Params: vector of current limit, vector of target velocity
}

Profile Position Mode

  • Single Actuator
motor.mode_selection(Mode::PROFILE_POSITION_MODE, xx, xx, xx);
motor.write_profile_position(Current limit, Velocity limit, Target position);

demo: Set Target Position to 360°

#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::PROFILE_POSITION_MODE, 10, 10, 10); // Params: Mode::operation mode, feedback cycle 1, 2, 3
Sleep(10); // Windows: Sleep(ms) Linux: sleep(s)
motor.write_profile_position(3000, 1000, 65535); // Params: current limit, velocity limit, target position
}

The value for one full rotation of the reducer end is 16 bits = 65536

  • Multiple Actuators
motors.mode_selection(Mode::PROFILE_POSITION_MODE, xx, xx, xx)
motors.write_profile_position(vector<int16_t>Current limit, vector<int16_t>Velocity limit, vector<int32_t>Target position)

demo: Set Target Position to 360°

#include <multi_motor_control.h>
vector<int16_t>cur = { 3000, 3000 };
vector<int16_t>vel = { 1000, 1000 };
vector<int32_t>pos = { 65535, 65535 };
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::PROFILE_POSITION_MODE, 10, 10, 10); // Params: Mode::operation mode, feedback cycle 1, 2, 3
Sleep(10); // Windows: Sleep(ms) Linux: sleep(s)
motors.write_profile_position(cur, vel, pos); // Params: vector of current limit, vector of velocity limit, vector of target position
}

The value for one full rotation of the reducer end is 16 bits = 65536

Position Mode

  • Single Actuator
motor.mode_selection(Mode::POSITION_MODE, xx, xx, xx)
motor.write_position(Current limit, Velocity limit, Target position)

demo: Set Target Position to 360°

#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::POSITION_MODE, 10, 10, 10); // Params: Mode::operation mode, feedback cycle 1, 2, 3
Sleep(10) ; // Windows: Sleep(ms) Linux: sleep(s)
motor.write_position(3000, 1000, 65535); // Params: current limit, velocity limit, target position
}

The value for one full rotation of the reducer end is 16 bits = 65536

  • Multiple Actuators
motors.mode_selection(Mode::POSITION_MODE, xx, xx, xx)
motors.write_position(vector<int16_t>Current limit, vector<int16_t>Velocity limit, vector<int32_t>Target position)

demo: Set Target Position to 360°

#include <multi_motor_control.h>
vector<int16_t>cur = { 3000, 3000 };
vector<int16_t>vel = { 1000, 1000 };
vector<int32_t>pos = { 65535, 65535 };
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::POSITION_MODE, 10, 10, 10); // Params: Mode::operation mode, feedback cycle 1, 2, 3
Sleep(10); // Windows: Sleep(ms) Linux: sleep(s)
motors.write_position(cur, vel, pos); // Params: vector of current limit, vector of velocity limit, vector of target position
}

The value for one full rotation of the reducer end is 16 bits = 65536

MIT Mode

  • Single Actuator
motor.mode_selection(Mode::MIT_MODE, xx, xx, xx)
motor.write_mit(Target current, Target velocity, Target position, KP, KD)

demo Point to point (The magnitude of the current should depend on the situation)

Target velocity is 0, others are not 0 (Current is feed-forward torque compensation)

#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
}

Fixed velocity (The magnitude of the current should depend on the situation)

Target position and KP are 0, others are not 0 (Current is feed-forward torque compensation)

#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
}

Fixed torque

Target current is not 0, others are 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
}
  • Multiple Actuators
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: Point to point (The magnitude of the current should depend on the situation)

Target velocity is 0, others are not 0 (Current is feed-forward torque compensation)

#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
}

Fixed velocity (The magnitude of the current should depend on the situation)

Target position and KP are 0, others are not 0 (Current is feed-forward torque compensation)

#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
}

Fixed torque

Target current is not 0, others are 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
}

Read Parameters

  • Single Actuator
MotorStatus status = motor.get_motor_status(header_types);

header_types: 0xB1, 0xB2, 0xB3

MotorStatus is a structure used to store actuator parameters

Read all parameters

Read voltage, PWM, current and velocity

Read motor position and actuator position

Read MOS tube temperature, motor temperature, G431 chip temperature, warning type and error type

  • Multiple Actuators
vector<MultiMotorStatus> all_motor_status = motors.get_motor_status(vector<uint8_t>header_types);

header_types: 0xB1, 0xB2, 0xB3

MultiMotorStatus is a structure used to store actuator parameters

Read all parameters

Read voltage, PWM, current and velocity

Read motor position and actuator position

Read MOS tube temperature, motor temperature, G431 chip temperature, warning type and error type

Other functions

  • Single Actuator

brake, modify the acceleration and deceleration of the open-loop mode, modify the acceleration and deceleration of the profile speed, modify the current pid, modify the speed pid, modify the position pid

#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.brake_control(-2000, 500); // Params: pwm, durations
motor.write_openloop_acc_dec(2000, 2000); // Params: acceleration, deceleration
motor.write_velocity_acc_dec(2000, 2000); // Params: acceleration, deceleration
motor.write_current_pid(0.001, 0.001); // Params: KP, KI
motor.write_velocity_pid(0.001, 0.001); // Params: KP, KI
motor.write_position_pid(0.001, 0.001); // Params: KP, KD
}

Modify the acceleration and deceleration of the contour speed in real time

#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::PROFILE_VELOCITY_MODE, 10, 10, 10);
while (1)
{
static int16_t i = 0;
i += 100;
motor.write_velocity_acc_dec(i, i);
cout << i << endl;
if (i >= 1000)
{
break;
}
motor.write_profile_velocity(3000, 1000);
Sleep(4000);
motor.write_profile_velocity(3000, 0);
Sleep(3000);
}
}
  • Multiple Actuators

brake, modify the acceleration and deceleration of the open-loop mode, modify the acceleration and deceleration of the profile speed, modify the current pid, modify the speed pid, modify the position pid

#include <multi_motor_control.h>
vector<int16_t>pwm = { 2000, 2000 };
vector<uint16_t>dur = { 500, 500 };
vector<int16_t>acc_ = { 2000, 2000 };
vector<int16_t>dec_ = { 2000, 2000 };
vector<float>kps = { 0.001, 0.001 };
vector<float>kis = { 0.001, 0.001 };
vector<float>kds = { 0.001, 0.001 };
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.brake_control(pwm, dur); // Params: vector of pwm, vector of durations
motors.write_openloop_acc_dec(acc_, dec_); // Params: vector of acceleration, vector of deceleration
motors.write_velocity_acc_dec(acc_, dec_); // Params: vector of acceleration, vector of deceleration
motors.write_current_pid(kps, kis); // Params: vector of KP, vector of KI
motors.write_velocity_pid(kps, kis); // Params: vector of KP, vector of KI
motors.write_position_pid(kps, kds); // Params: vector of KP, vector of KD
}

Modify the acceleration and deceleration of the contour speed in real time

#include <multi_motor_control.h>
vector<int16_t>cur = { 3000, 3000 };
vector<int16_t>vel = { 1000, 1000 };
vector<int16_t>vel_0 = { 0, 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::PROFILE_VELOCITY_MODE, 10, 10, 10);
Sleep(100);
while (1)
{
static int16_t i = 0;
i += 100;
vector<int16_t> acc_dec = { i, i };
motors.write_velocity_acc_dec(acc_dec, acc_dec);
cout << i << endl;
if (i >= 1000)
{
break;
}
motors.write_profile_velocity(cur, vel);
Sleep(4000);
motors.write_profile_velocity(cur, vel_0);
Sleep(3000);
}
}