mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-02 05:04:08 +08:00
VescDriver: support commanding motor duty cycle
This commit is contained in:
parent
883661fc51
commit
0f5e3f788f
@ -39,6 +39,14 @@
|
||||
#include "VescDriver.hpp"
|
||||
#include <memory.h>
|
||||
|
||||
void VescDriver::commandDutyCycle(float duty_cycle)
|
||||
{
|
||||
uint8_t command[5] {VescCommand::SET_DUTY};
|
||||
uint16_t index{1};
|
||||
insertInt32(command, index, static_cast<int32_t>(duty_cycle * 100000.f));
|
||||
sendPacket(command, 5);
|
||||
}
|
||||
|
||||
void VescDriver::commandCurrent(float current)
|
||||
{
|
||||
uint8_t command[5] {VescCommand::SET_CURRENT};
|
||||
|
||||
@ -51,6 +51,7 @@ public:
|
||||
VescDriver(VescWritable *vesc_writable) : _vesc_writable(vesc_writable) {};
|
||||
~VescDriver() = default;
|
||||
|
||||
void commandDutyCycle(float duty_cycle);
|
||||
void commandCurrent(float current);
|
||||
void commandBrakeCurrent(float current);
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@ void VescDevice::Run()
|
||||
}
|
||||
|
||||
_vesc_driver.requestFirmwareVersion();
|
||||
_vesc_driver.commandCurrent(.5f);
|
||||
_vesc_driver.commandDutyCycle(.05f);
|
||||
|
||||
// Check the number of bytes available in the buffer
|
||||
int bytes_available{0};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user