Tetrapod Project
SingleMotorController Class Reference

#include <single_motor_controller.h>

Public Member Functions

 SingleMotorController (double _publish_frequency, bool _use_position_control)
 
 SingleMotorController (double _publish_frequency)
 
virtual ~SingleMotorController ()
 
void initROS ()
 
void calculateSingleAxisTrajectory (const double &_percentage, const double &_period, const double &_max_travel, double &_x, double &_x_d, double &_x_dd)
 
void updateTrajectory ()
 
void sendJointPositionCommand ()
 
void sendJointTorqueCommand ()
 
void increaseIterator ()
 
void moveToZero ()
 
void setPositionDirectly (double _joint_pos)
 
void setVelocityDirectly (double _joint_vel)
 
void setTorqueDirectly (double _torque)
 
void initializeMotor (double _k_p_pos, double _k_d_pos, double _k_p_vel, double _k_i_vel, double _k_p_torque, double _k_i_torque)
 
void initializeMotor ()
 
bool readyToProceed ()
 
bool initialStateReceived ()
 
void checkForNewMessages ()
 
void printAll ()
 
void writeToLog ()
 
bool keepLogging ()
 
double getPosition ()
 

Private Member Functions

void motorStateCallback (const sensor_msgs::JointStatePtr &_msg)
 
void readyToProceedCallback (const std_msgs::Bool &_msg)
 
void setGoalCallback (const std_msgs::Float32 &_msg)
 
void motorConfirmationCallback (const std_msgs::Bool &_msg)
 
void keepLoggingCallback (const std_msgs::Bool &_msg)
 

Private Attributes

const double UNINITIALIZED_STATE = 1000.0
 
const double IDLE_COMMAND = 1000.0
 
double angle_offset = 0.0
 
double angle_pos = UNINITIALIZED_STATE
 
double angle_vel = 0
 
double angle_pos_ref = 0
 
double angle_vel_ref = 0
 
double angle_acc_ref = 0
 
double torque = 0
 
double torque_ref = 0
 
bool ready_to_proceed = false
 
bool motor_initialized = false
 
double current_iteration = 0.0
 
bool keep_logging = true
 
bool gains_set = false
 
double publish_frequency = 100.0
 
double period = 2.0
 
double max_iterations
 
double max_travel = 0.0
 
double inertia = 0.1
 
double k_p_controller = 50.0
 
double k_i_controller = 10.0
 
double k_d_controller = 5.0
 
double k_p_pos = 1.0
 
double k_i_pos = 1.0
 
double k_d_pos = 5.0
 
double k_p_vel = 50.0
 
double k_i_vel = 50.0
 
double k_d_vel = 0.0
 
double k_p_torque = 100.0
 
double k_i_torque = 100.0
 
double k_d_torque = 0.0
 
std::unique_ptr< ros::NodeHandle > node_handle
 
ros::Subscriber motor_state_subscriber
 
ros::Subscriber ready_to_proceed_subscriber
 
ros::Subscriber set_goal_subscriber
 
ros::Subscriber motor_confirmation_subscriber
 
ros::Subscriber keep_logging_subscriber
 
ros::Publisher joint_command_publisher
 
ros::Publisher motor_gain_publisher
 
ros::Publisher log_motor_state_publisher
 
ros::Publisher log_motor_reference_publisher
 

Detailed Description

Definition at line 14 of file single_motor_controller.h.

Constructor & Destructor Documentation

◆ SingleMotorController() [1/2]

SingleMotorController::SingleMotorController ( double  _publish_frequency,
bool  _use_position_control 
)

Definition at line 3 of file single_motor_controller.cpp.

◆ SingleMotorController() [2/2]

SingleMotorController::SingleMotorController ( double  _publish_frequency)

Definition at line 10 of file single_motor_controller.cpp.

◆ ~SingleMotorController()

virtual SingleMotorController::~SingleMotorController ( )
inlinevirtual

Definition at line 26 of file single_motor_controller.h.

Member Function Documentation

◆ initROS()

void SingleMotorController::initROS ( )

Definition at line 17 of file single_motor_controller.cpp.

◆ motorStateCallback()

void SingleMotorController::motorStateCallback ( const sensor_msgs::JointStatePtr &  _msg)
private

Definition at line 85 of file single_motor_controller.cpp.

◆ readyToProceedCallback()

void SingleMotorController::readyToProceedCallback ( const std_msgs::Bool &  _msg)
private

Definition at line 93 of file single_motor_controller.cpp.

◆ setGoalCallback()

void SingleMotorController::setGoalCallback ( const std_msgs::Float32 &  _msg)
private

Definition at line 99 of file single_motor_controller.cpp.

◆ motorConfirmationCallback()

void SingleMotorController::motorConfirmationCallback ( const std_msgs::Bool &  _msg)
private

Definition at line 108 of file single_motor_controller.cpp.

◆ keepLoggingCallback()

void SingleMotorController::keepLoggingCallback ( const std_msgs::Bool &  _msg)
private

Definition at line 116 of file single_motor_controller.cpp.

◆ calculateSingleAxisTrajectory()

void SingleMotorController::calculateSingleAxisTrajectory ( const double &  _percentage,
const double &  _period,
const double &  _max_travel,
double &  _x,
double &  _x_d,
double &  _x_dd 
)

Definition at line 121 of file single_motor_controller.cpp.

◆ updateTrajectory()

void SingleMotorController::updateTrajectory ( )

Definition at line 141 of file single_motor_controller.cpp.

◆ sendJointPositionCommand()

void SingleMotorController::sendJointPositionCommand ( )

Definition at line 150 of file single_motor_controller.cpp.

◆ sendJointTorqueCommand()

void SingleMotorController::sendJointTorqueCommand ( )

Definition at line 163 of file single_motor_controller.cpp.

◆ increaseIterator()

void SingleMotorController::increaseIterator ( )

Definition at line 178 of file single_motor_controller.cpp.

◆ moveToZero()

void SingleMotorController::moveToZero ( )

Definition at line 193 of file single_motor_controller.cpp.

◆ setPositionDirectly()

void SingleMotorController::setPositionDirectly ( double  _joint_pos)

Definition at line 215 of file single_motor_controller.cpp.

◆ setVelocityDirectly()

void SingleMotorController::setVelocityDirectly ( double  _joint_vel)

Definition at line 230 of file single_motor_controller.cpp.

◆ setTorqueDirectly()

void SingleMotorController::setTorqueDirectly ( double  _torque)

Definition at line 245 of file single_motor_controller.cpp.

◆ initializeMotor() [1/2]

void SingleMotorController::initializeMotor ( double  _k_p_pos,
double  _k_d_pos,
double  _k_p_vel,
double  _k_i_vel,
double  _k_p_torque,
double  _k_i_torque 
)

Definition at line 260 of file single_motor_controller.cpp.

◆ initializeMotor() [2/2]

void SingleMotorController::initializeMotor ( )

Definition at line 291 of file single_motor_controller.cpp.

◆ readyToProceed()

bool SingleMotorController::readyToProceed ( )

Definition at line 296 of file single_motor_controller.cpp.

◆ initialStateReceived()

bool SingleMotorController::initialStateReceived ( )

Definition at line 308 of file single_motor_controller.cpp.

◆ checkForNewMessages()

void SingleMotorController::checkForNewMessages ( )

Definition at line 320 of file single_motor_controller.cpp.

◆ printAll()

void SingleMotorController::printAll ( )

Definition at line 325 of file single_motor_controller.cpp.

◆ writeToLog()

void SingleMotorController::writeToLog ( )

Definition at line 331 of file single_motor_controller.cpp.

◆ keepLogging()

bool SingleMotorController::keepLogging ( )
inline

Definition at line 96 of file single_motor_controller.h.

◆ getPosition()

double SingleMotorController::getPosition ( )
inline

Definition at line 98 of file single_motor_controller.h.

Member Data Documentation

◆ UNINITIALIZED_STATE

const double SingleMotorController::UNINITIALIZED_STATE = 1000.0
private

Definition at line 16 of file single_motor_controller.h.

◆ IDLE_COMMAND

const double SingleMotorController::IDLE_COMMAND = 1000.0
private

Definition at line 18 of file single_motor_controller.h.

◆ angle_offset

double SingleMotorController::angle_offset = 0.0
private

Definition at line 102 of file single_motor_controller.h.

◆ angle_pos

double SingleMotorController::angle_pos = UNINITIALIZED_STATE
private

Definition at line 104 of file single_motor_controller.h.

◆ angle_vel

double SingleMotorController::angle_vel = 0
private

Definition at line 106 of file single_motor_controller.h.

◆ angle_pos_ref

double SingleMotorController::angle_pos_ref = 0
private

Definition at line 108 of file single_motor_controller.h.

◆ angle_vel_ref

double SingleMotorController::angle_vel_ref = 0
private

Definition at line 110 of file single_motor_controller.h.

◆ angle_acc_ref

double SingleMotorController::angle_acc_ref = 0
private

Definition at line 112 of file single_motor_controller.h.

◆ torque

double SingleMotorController::torque = 0
private

Definition at line 114 of file single_motor_controller.h.

◆ torque_ref

double SingleMotorController::torque_ref = 0
private

Definition at line 116 of file single_motor_controller.h.

◆ ready_to_proceed

bool SingleMotorController::ready_to_proceed = false
private

Definition at line 118 of file single_motor_controller.h.

◆ motor_initialized

bool SingleMotorController::motor_initialized = false
private

Definition at line 120 of file single_motor_controller.h.

◆ current_iteration

double SingleMotorController::current_iteration = 0.0
private

Definition at line 122 of file single_motor_controller.h.

◆ keep_logging

bool SingleMotorController::keep_logging = true
private

Definition at line 124 of file single_motor_controller.h.

◆ gains_set

bool SingleMotorController::gains_set = false
private

Definition at line 126 of file single_motor_controller.h.

◆ publish_frequency

double SingleMotorController::publish_frequency = 100.0
private

Definition at line 130 of file single_motor_controller.h.

◆ period

double SingleMotorController::period = 2.0
private

Definition at line 132 of file single_motor_controller.h.

◆ max_iterations

double SingleMotorController::max_iterations
private

Definition at line 134 of file single_motor_controller.h.

◆ max_travel

double SingleMotorController::max_travel = 0.0
private

Definition at line 136 of file single_motor_controller.h.

◆ inertia

double SingleMotorController::inertia = 0.1
private

Definition at line 138 of file single_motor_controller.h.

◆ k_p_controller

double SingleMotorController::k_p_controller = 50.0
private

Definition at line 140 of file single_motor_controller.h.

◆ k_i_controller

double SingleMotorController::k_i_controller = 10.0
private

Definition at line 142 of file single_motor_controller.h.

◆ k_d_controller

double SingleMotorController::k_d_controller = 5.0
private

Definition at line 144 of file single_motor_controller.h.

◆ k_p_pos

double SingleMotorController::k_p_pos = 1.0
private

Definition at line 146 of file single_motor_controller.h.

◆ k_i_pos

double SingleMotorController::k_i_pos = 1.0
private

Definition at line 148 of file single_motor_controller.h.

◆ k_d_pos

double SingleMotorController::k_d_pos = 5.0
private

Definition at line 150 of file single_motor_controller.h.

◆ k_p_vel

double SingleMotorController::k_p_vel = 50.0
private

Definition at line 152 of file single_motor_controller.h.

◆ k_i_vel

double SingleMotorController::k_i_vel = 50.0
private

Definition at line 154 of file single_motor_controller.h.

◆ k_d_vel

double SingleMotorController::k_d_vel = 0.0
private

Definition at line 156 of file single_motor_controller.h.

◆ k_p_torque

double SingleMotorController::k_p_torque = 100.0
private

Definition at line 158 of file single_motor_controller.h.

◆ k_i_torque

double SingleMotorController::k_i_torque = 100.0
private

Definition at line 160 of file single_motor_controller.h.

◆ k_d_torque

double SingleMotorController::k_d_torque = 0.0
private

Definition at line 162 of file single_motor_controller.h.

◆ node_handle

std::unique_ptr<ros::NodeHandle> SingleMotorController::node_handle
private

Definition at line 166 of file single_motor_controller.h.

◆ motor_state_subscriber

ros::Subscriber SingleMotorController::motor_state_subscriber
private

Definition at line 168 of file single_motor_controller.h.

◆ ready_to_proceed_subscriber

ros::Subscriber SingleMotorController::ready_to_proceed_subscriber
private

Definition at line 170 of file single_motor_controller.h.

◆ set_goal_subscriber

ros::Subscriber SingleMotorController::set_goal_subscriber
private

Definition at line 172 of file single_motor_controller.h.

◆ motor_confirmation_subscriber

ros::Subscriber SingleMotorController::motor_confirmation_subscriber
private

Definition at line 174 of file single_motor_controller.h.

◆ keep_logging_subscriber

ros::Subscriber SingleMotorController::keep_logging_subscriber
private

Definition at line 176 of file single_motor_controller.h.

◆ joint_command_publisher

ros::Publisher SingleMotorController::joint_command_publisher
private

Definition at line 178 of file single_motor_controller.h.

◆ motor_gain_publisher

ros::Publisher SingleMotorController::motor_gain_publisher
private

Definition at line 180 of file single_motor_controller.h.

◆ log_motor_state_publisher

ros::Publisher SingleMotorController::log_motor_state_publisher
private

Definition at line 182 of file single_motor_controller.h.

◆ log_motor_reference_publisher

ros::Publisher SingleMotorController::log_motor_reference_publisher
private

Definition at line 184 of file single_motor_controller.h.


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