Class VescInterface
Defined in File vesc_interface.hpp
Class Documentation
-
class VescInterface
Class providing an interface to the Vedder VESC motor controller via a serial port interface.
Public Types
-
typedef std::function<void(const VescPacketConstPtr&)> PacketHandlerFunction
-
typedef std::function<void(const std::string&)> ErrorHandlerFunction
Public Functions
-
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.- Parameters:
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.
- Throws:
-
VescInterface(const VescInterface&) = delete
Delete copy constructor and equals operator.
-
VescInterface &operator=(const VescInterface&) = delete
-
~VescInterface()
VescInterface destructor.
-
void setPacketHandler(const PacketHandlerFunction &handler)
Sets / updates the function that this class calls when a VESC packet is received.
-
void setErrorHandler(const ErrorHandlerFunction &handler)
Sets / updates the function that this class calls when an error is detected, such as a bad checksum.
-
void connect(const std::string &port)
Opens the serial port interface to the VESC.
- Throws:
-
void disconnect()
Closes the serial port interface to the VESC.
-
bool isConnected() const
Gets the status of the serial interface to the VESC.
- Returns:
Returns true if the serial port is open, false otherwise.
-
void send(const VescPacket &packet)
Send a VESC packet.
-
void requestFWVersion()
-
void requestState()
-
void requestImuData()
-
void setDutyCycle(double duty_cycle)
-
void setCurrent(double current)
-
void setBrake(double brake)
-
void setSpeed(double speed)
-
void setPosition(double position)
-
void setServo(double servo)
-
typedef std::function<void(const VescPacketConstPtr&)> PacketHandlerFunction