42 : DiagnosticTask(name +
"_status")
43 , joint_state_handle(name, &position, &velocity, &effort)
44 , joint_handle(joint_state_handle, &
command)
86 bool tmp_pos = load_from_board & ((
_control_mode == 2) || (_control_mode == 3) || (_control_mode == 4));
87 bool tmp_vel = load_from_board & ((_control_mode == 1) || (_control_mode == 6));
88 bool tmp_tor = load_from_board & (_control_mode == 5);
111 double reduction = 0;
119 return x * (reduction) / (2 * M_PI);
130 double reduction = 0;
137 return x * (2 * M_PI) / (reduction);
167 if(urdf_soft_limits_ok) {
176 if(rosparam_limits_ok) {
220 control =
"Open loop";
223 control =
"Closed loop speed";
226 control =
"Closed loop position relative";
229 control =
"Closed loop count position";
232 control =
"Closed loop position tracking";
235 control =
"Closed loop torque";
238 control =
"Closed loop speed position";
244 stat.
add(
"Control", control);
260 stat.
summary(diagnostic_msgs::DiagnosticStatus::OK,
"Motor Ready!");
269 stat.
mergeSummary(diagnostic_msgs::DiagnosticStatus::WARN,
"Amps trigger active");
274 stat.
mergeSummary(diagnostic_msgs::DiagnosticStatus::WARN,
"Forward limit triggered");
279 stat.
mergeSummary(diagnostic_msgs::DiagnosticStatus::WARN,
"Reverse limit triggered");
284 stat.
mergeSummary(diagnostic_msgs::DiagnosticStatus::ERROR,
"Loop error detection");
289 stat.
mergeSummary(diagnostic_msgs::DiagnosticStatus::ERROR,
"Motor stalled");
294 stat.
mergeSummary(diagnostic_msgs::DiagnosticStatus::WARN,
"Safety stop active");
308 if(type.compare(
"diff_drive_controller/DiffDriveController") == 0)
343 long long int roboteq_velocity =
static_cast<long long int>(
to_rpm(
command) / max_rpm * 1000.0);
351 std::vector<std::string> fields;
352 boost::split(fields, data, boost::algorithm::is_any_of(
":"));
358 double ratio, max_rpm;
375 unsigned char status = boost::lexical_cast<
unsigned int>(fields[0]);
376 memcpy(&
_status, &status,
sizeof(status));
379 double cmd = boost::lexical_cast<
double>(fields[1]) * max_rpm / 1000.0;
383 double vel = boost::lexical_cast<
double>(fields[2]) * max_rpm / 1000.0;
389 double loop_error = boost::lexical_cast<
double>(fields[3]) * max_rpm / 1000.0;
393 msg_control.pwm = boost::lexical_cast<
double>(fields[4]);
396 msg_status.volts = boost::lexical_cast<
double>(fields[5]) / 10;
399 msg_status.amps_motor = boost::lexical_cast<
double>(fields[6]) / 10;
406 msg_status.amps_motor = boost::lexical_cast<
double>(fields[7]) / 10;
414 msg_status.track = boost::lexical_cast<
long>(fields[9]);
420 catch (std::bad_cast& e)
422 ROS_WARN(
"Failure parsing feedback data. Dropping message.");
uint8_t loop_error_detect
double to_encoder_ticks(double x)
ros::Publisher pub_status
roboteq_control::ControlStatus msg_control
void publish(const boost::shared_ptr< M > &message) const
void summary(unsigned char lvl, const std::string s)
virtual double getConversion(double reduction)=0
double from_encoder_ticks(double x)
uint8_t reverse_limit_triggered
void run(diagnostic_updater::DiagnosticStatusWrapper &stat)
run Run the diagnostic updater
void setOperativeMode(int type)
setOperativeMode Reference in page 321 - MMOD
hardware_interface::JointHandle joint_handle
bool getSoftJointLimits(const std::string &joint_name, const ros::NodeHandle &nh, SoftJointLimits &soft_limits)
void connectionCallback(const ros::SingleSubscriberPublisher &pub)
uint8_t safety_stop_active
joint_limits_interface::VelocityJointSoftLimitsInterface vel_limits_interface
ROS joint limits interface.
void enforceLimits(const ros::Duration &period)
void initConfigurator(bool load_from_board)
initConfigurator Initialize all parameter and syncronize parameters between ros and roboteq board ...
std::string getTopic() const
void writeCommandsToHardware(ros::Duration period)
writeCommandsToHardware Write a command to the hardware interface
bool getJointLimits(const std::string &joint_name, const ros::NodeHandle &nh, JointLimits &limits)
ROSLIB_DECL std::string command(const std::string &cmd)
void stopMotor()
stopMotor Stop the motor
uint8_t amps_triggered_active
std::string getSubscriberName() const
Motor(const ros::NodeHandle &nh, serial_controller *serial, string name, unsigned int number)
Motor The motor definition and all ros controller initializations are collected in this place...
MotorPIDConfigurator * pid_position
void resetPosition(double position)
resetPosition Reset the motor in a new initial position
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
static double to_rpm(double x)
#define ROS_DEBUG_STREAM(args)
ros::Publisher pub_control
MotorParamConfigurator * parameter
void mergeSummary(unsigned char lvl, const std::string s)
void setupLimits(urdf::Model model)
setupLimits setup the maximum velocity, positio and effort
MotorPIDConfigurator * pid_velocity
MotorPIDConfigurator * pid_torque
void readVector(std::vector< std::string > fields)
readVector Decode vector data list
bool command(string msg, string params="", string type="!")
bool getParam(const std::string &key, std::string &s) const
uint8_t forward_limit_triggered
void mergeSummaryf(unsigned char lvl, const char *format,...)
void add(const std::string &key, const T &val)
void switchController(string type)
switchController Switch the controller from different type of ros controller
void initializeMotor(bool load_from_board)
initializeMotor Initialization oh motor, this routine load parameter from ros server or load from rob...
roboteq_control::MotorStatus msg_status
void initConfigurator(bool load_from_board)
serial_controller * mSerial