#include <vesc_interface.h>
Classes | |
class | Impl |
Public Types | |
typedef std::function< void(const std::string &)> | ErrorHandlerFunction |
typedef std::function< void(const VescPacketConstPtr &)> | PacketHandlerFunction |
Public Member Functions | |
void | connect (const std::string &port) |
void | disconnect () |
bool | isConnected () const |
VescInterface & | operator= (const VescInterface &)=delete |
void | requestFWVersion () |
void | requestState () |
void | send (const VescPacket &packet) |
void | setBrake (double brake) |
void | setCurrent (double current) |
void | setDutyCycle (double duty_cycle) |
void | setErrorHandler (const ErrorHandlerFunction &handler) |
void | setPacketHandler (const PacketHandlerFunction &handler) |
void | setPosition (double position) |
void | setServo (double servo) |
void | setSpeed (double speed) |
VescInterface (const std::string &port=std::string(), const PacketHandlerFunction &packet_handler=PacketHandlerFunction(), const ErrorHandlerFunction &error_handler=ErrorHandlerFunction()) | |
VescInterface (const VescInterface &)=delete | |
~VescInterface () | |
Private Attributes | |
std::unique_ptr< Impl > | impl_ |
Class providing an interface to the Vedder VESC motor controller via a serial port interface.
Definition at line 46 of file vesc_interface.h.
typedef std::function<void (const std::string&)> vesc_driver::VescInterface::ErrorHandlerFunction |
Definition at line 50 of file vesc_interface.h.
typedef std::function<void (const VescPacketConstPtr&)> vesc_driver::VescInterface::PacketHandlerFunction |
Definition at line 49 of file vesc_interface.h.
vesc_driver::VescInterface::VescInterface | ( | const std::string & | port = std::string() , |
const PacketHandlerFunction & | packet_handler = PacketHandlerFunction() , |
||
const ErrorHandlerFunction & | error_handler = ErrorHandlerFunction() |
||
) |
Creates a VescInterface object. Opens the serial port interface to the VESC if port
is not empty, otherwise the serial port remains closed until connect() is called.
port | Address of the serial port, e.g. '/dev/ttyUSB0'. |
packet_handler | Function this class calls when a VESC packet is received. |
error_handler | Function this class calls when an error is detected, such as a bad checksum. |
SerialException |
Definition at line 151 of file vesc_interface.cpp.
|
delete |
Delete copy constructor and equals operator.
vesc_driver::VescInterface::~VescInterface | ( | ) |
VescInterface destructor.
Definition at line 163 of file vesc_interface.cpp.
void vesc_driver::VescInterface::connect | ( | const std::string & | port | ) |
Opens the serial port interface to the VESC.
SerialException |
Definition at line 180 of file vesc_interface.cpp.
void vesc_driver::VescInterface::disconnect | ( | ) |
Closes the serial port interface to the VESC.
Definition at line 207 of file vesc_interface.cpp.
bool vesc_driver::VescInterface::isConnected | ( | ) | const |
Gets the status of the serial interface to the VESC.
Definition at line 220 of file vesc_interface.cpp.
|
delete |
void vesc_driver::VescInterface::requestFWVersion | ( | ) |
Definition at line 236 of file vesc_interface.cpp.
void vesc_driver::VescInterface::requestState | ( | ) |
Definition at line 241 of file vesc_interface.cpp.
void vesc_driver::VescInterface::send | ( | const VescPacket & | packet | ) |
Send a VESC packet.
Definition at line 225 of file vesc_interface.cpp.
void vesc_driver::VescInterface::setBrake | ( | double | brake | ) |
Definition at line 256 of file vesc_interface.cpp.
void vesc_driver::VescInterface::setCurrent | ( | double | current | ) |
Definition at line 251 of file vesc_interface.cpp.
void vesc_driver::VescInterface::setDutyCycle | ( | double | duty_cycle | ) |
Definition at line 246 of file vesc_interface.cpp.
void vesc_driver::VescInterface::setErrorHandler | ( | const ErrorHandlerFunction & | handler | ) |
Sets / updates the function that this class calls when an error is detected, such as a bad checksum.
Definition at line 174 of file vesc_interface.cpp.
void vesc_driver::VescInterface::setPacketHandler | ( | const PacketHandlerFunction & | handler | ) |
Sets / updates the function that this class calls when a VESC packet is received.
Definition at line 168 of file vesc_interface.cpp.
void vesc_driver::VescInterface::setPosition | ( | double | position | ) |
Definition at line 266 of file vesc_interface.cpp.
void vesc_driver::VescInterface::setServo | ( | double | servo | ) |
Definition at line 271 of file vesc_interface.cpp.
void vesc_driver::VescInterface::setSpeed | ( | double | speed | ) |
Definition at line 261 of file vesc_interface.cpp.
|
private |
Definition at line 124 of file vesc_interface.h.