VescDriver: support commanding motor duty cycle

This commit is contained in:
Matthias Grob 2021-03-13 10:24:09 +01:00
parent 883661fc51
commit 0f5e3f788f
3 changed files with 10 additions and 1 deletions

View File

@ -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};

View File

@ -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);

View File

@ -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};