Classes | Public Types | Public Member Functions | Private Attributes | List of all members
vesc_driver::VescInterface Class Reference

#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
 
VescInterfaceoperator= (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< Implimpl_
 

Detailed Description

Class providing an interface to the Vedder VESC motor controller via a serial port interface.

Definition at line 46 of file vesc_interface.h.

Member Typedef Documentation

typedef std::function<void (const std::string&)> vesc_driver::VescInterface::ErrorHandlerFunction

Definition at line 50 of file vesc_interface.h.

Definition at line 49 of file vesc_interface.h.

Constructor & Destructor Documentation

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.

Parameters
portAddress of the serial port, e.g. '/dev/ttyUSB0'.
packet_handlerFunction this class calls when a VESC packet is received.
error_handlerFunction this class calls when an error is detected, such as a bad checksum.
Exceptions
SerialException

Definition at line 151 of file vesc_interface.cpp.

vesc_driver::VescInterface::VescInterface ( const VescInterface )
delete

Delete copy constructor and equals operator.

vesc_driver::VescInterface::~VescInterface ( )

VescInterface destructor.

Definition at line 163 of file vesc_interface.cpp.

Member Function Documentation

void vesc_driver::VescInterface::connect ( const std::string &  port)

Opens the serial port interface to the VESC.

Exceptions
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.

Returns
Returns true if the serial port is open, false otherwise.

Definition at line 220 of file vesc_interface.cpp.

VescInterface& vesc_driver::VescInterface::operator= ( const VescInterface )
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.

Member Data Documentation

std::unique_ptr<Impl> vesc_driver::VescInterface::impl_
private

Definition at line 124 of file vesc_interface.h.


The documentation for this class was generated from the following files:


vesc_driver
Author(s): Michael T. Boulet , Joshua Whitley
autogenerated on Sun Apr 18 2021 02:48:01