33 #include <boost/assign/list_of.hpp> 39 const uint8_t LEFT = 0, RIGHT = 1;
50 private_nh_(private_nh),
51 system_status_task_(roch_status_msg_),
52 power_status_task_(roch_status_msg_),
53 safety_status_task_(roch_status_msg_),
54 software_status_task_(roch_status_msg_, target_control_freq)
85 for (
int i = 0; i < 2; i++)
93 ROS_ERROR(
"Could not get encoder data to calibrate travel offset");
101 ROS_DEBUG_STREAM(
"Received imu rate data information (Angle:" << imuRateData->getAngle() <<
" Angle rate:" << imuRateData->getAngleRate() <<
")");
102 ROS_DEBUG_STREAM(
"Received imu rate data information, angle_offset:"<<imuRateData->getAngle()<<
" .");
106 ROS_ERROR(
"Could not get imu data to calibrate rate offset");
111 if(getPlatformAccData){
113 ROS_DEBUG_STREAM(
"Received acc_x:"<<getPlatformAccData->getX()<<
", acc_y:"<<getPlatformAccData->getY()<<
", acc_z:"<<getPlatformAccData->getZ()<<
".");
124 ROS_ERROR(
"Could not get Gyro data to calibrate Acceleration offset");
134 ROS_DEBUG_STREAM(
"Received rangefinder Data, counts:"<<(
int)rangefinderData->getRangefinderCount()<<
", data[0]:"<<rangefinderData->getDistance(0)<<
" , data[1]:"<<rangefinderData->getDistance(1)<<
", data[2]:"<<rangefinderData->getDistance(2)<<
" , data[3]:"<<rangefinderData->getDistance(3)<<
", data[4]:"<<rangefinderData->getDistance(4)<<
".");
136 publishCliffEvent(rangefinderData->getDistance(6),rangefinderData->getDistance(7));
137 publishUltEvent(rangefinderData->getDistance(0),rangefinderData->getDistance(1),rangefinderData->getDistance(2));
138 publishPSDEvent(rangefinderData->getDistance(3),rangefinderData->getDistance(4),rangefinderData->getDistance(5));
144 if(rangefinderDataAndTime){
145 ROS_DEBUG_STREAM(
"Received rangefinder Data and time, counts:"<<(
int)rangefinderDataAndTime->getRangefinderCount()<<
146 ", data[0]:"<<rangefinderDataAndTime->getDistance(0)<<
", time[0]:"<<rangefinderDataAndTime->getAcquisitionTime(0)<<
147 ", data[1]:"<<rangefinderDataAndTime->getDistance(0)<<
", time[1]:"<<rangefinderDataAndTime->getAcquisitionTime(0)<<
148 ", data[2]:"<<rangefinderDataAndTime->getDistance(0)<<
", time[2]:"<<rangefinderDataAndTime->getAcquisitionTime(0)<<
149 ", data[3]:"<<rangefinderDataAndTime->getDistance(0)<<
", time[3]:"<<rangefinderDataAndTime->getAcquisitionTime(0)<<
150 ", data[4]:"<<rangefinderDataAndTime->getDistance(0)<<
", time[4]:"<<rangefinderDataAndTime->getAcquisitionTime(0)<<
".");
160 if(getPlatformAccData){
162 ROS_DEBUG_STREAM(
"Received acc_x:"<<getPlatformAccData->getX()<<
", acc_y:"<<getPlatformAccData->getY()<<
", acc_z:"<<getPlatformAccData->getZ()<<
".");
194 if(getDifferentControlConstantData){
195 ROS_DEBUG_STREAM(
"Received Data of Differential Control Data, Left_P:"<<getDifferentControlConstantData->getLeftP()<<
", Left_I:"<<getDifferentControlConstantData->getLeftI()<<
", Left_D:"<<getDifferentControlConstantData->getLeftD()<<
196 ",right_P:"<<getDifferentControlConstantData->getRightP()<<
", right_I:"<<getDifferentControlConstantData->getRightI()<<
", right_D:"<<getDifferentControlConstantData->getRightD()<<
".");
211 std::ostringstream hardware_id_stream;
212 hardware_id_stream <<
"roch " << info->getModel() <<
"-" << info->getSerial();
235 ros::V_string joint_names = boost::assign::list_of(
"front_left_wheel")
236 (
"front_right_wheel");
289 for (
unsigned int i = 0; i < joint_names.size(); i++)
297 joint_state_handle, &
joints_[i].velocity_command);
299 std::cout<<
"Received joint_names["<<i<<
"]:"<<joint_names[i]<<std::endl;
327 for(
int i=0;i<2;i++){
337 ROS_DEBUG_STREAM(
"Received travel information (L:" << enc->getTravel(LEFT) <<
" R:" << enc->getTravel(RIGHT) <<
")");
338 for (
int i = 0; i < 2; i++)
342 if (std::abs(delta) < 2.0)
361 ROS_DEBUG_STREAM(
"Received linear speed information (L:" << speed->getLeftSpeed() <<
" R:" << speed->getRightSpeed() <<
")");
362 for (
int i = 0; i < 2; i++)
381 ROS_DEBUG_STREAM(
"Received speed information (speed:" << overallspeed->getTranslational() <<
" Rotational:" << overallspeed->getRotational()<<
" Acceleration:"<<overallspeed->getTransAccel() <<
")");
388 ROS_DEBUG_STREAM(
"Received imu rate data information (Angle:" << imuRateData->getAngle() <<
" Angle rate:" << imuRateData->getAngleRate() <<
")");
419 ROS_DEBUG_STREAM(
"diff_speed_left:"<<diff_speed_left<<
",joints_[LEFT].velocity_command:"<<
joints_[LEFT].velocity_command<<
".");
420 ROS_DEBUG_STREAM(
"diff_speed_right:"<<diff_speed_left<<
",joints_[RIGHT].velocity_command:"<<
joints_[RIGHT].velocity_command<<
".");
445 std::ostringstream ostream;
448 ostream << std::setfill(
'0') << std::uppercase;
449 for (
unsigned int i=0; i < data.
length; i++)
450 ostream << std::hex << std::setw(2) <<
static_cast<unsigned int>(data.
data[i]) <<
" " << std::dec;
452 std_msgs::StringPtr
msg(
new std_msgs::String);
453 msg->data = ostream.str();
479 roch_msgs::CliffEventPtr
msg(
new roch_msgs::CliffEvent);
481 case(
CliffEvent::Floor) : { msg->leftState = roch_msgs::CliffEvent::FLOOR;
break; }
482 case(
CliffEvent::Cliff) : { msg->leftState = roch_msgs::CliffEvent::CLIFF;
break; }
486 case(
CliffEvent::Floor) : { msg->rightState = roch_msgs::CliffEvent::FLOOR;
break; }
487 case(
CliffEvent::Cliff) : { msg->rightState = roch_msgs::CliffEvent::CLIFF;
break; }
490 msg->leftSensor = roch_msgs::CliffEvent::LEFT;
491 msg->rightSensor = roch_msgs::CliffEvent::RIGHT;
523 roch_msgs::UltEventPtr
msg(
new roch_msgs::UltEvent);
525 case(
UltEvent::Normal) : { msg->leftState = roch_msgs::UltEvent::NORMAL;
break; }
526 case(
UltEvent::Near) : { msg->leftState = roch_msgs::UltEvent::NEAR;
break; }
530 case(
UltEvent::Normal) : { msg->centerState = roch_msgs::UltEvent::NORMAL;
break; }
531 case(
UltEvent::Near) : { msg->centerState = roch_msgs::UltEvent::NEAR;
break; }
535 case(
UltEvent::Normal) : { msg->rightState = roch_msgs::UltEvent::NORMAL;
break; }
536 case(
UltEvent::Near) : { msg->rightState = roch_msgs::UltEvent::NEAR;
break; }
539 msg->leftSensor = roch_msgs::UltEvent::LEFT;
540 msg->centerSensor = roch_msgs::UltEvent::CENTER;
541 msg->rightSensor = roch_msgs::UltEvent::RIGHT;
559 roch_msgs::SensorState statecore;
613 roch_msgs::PSDEventPtr
msg(
new roch_msgs::PSDEvent);
615 case(
PSDEvent::Normal) : { msg->leftState = roch_msgs::PSDEvent::NORMAL;
break; }
616 case(
PSDEvent::Near) : { msg->leftState = roch_msgs::PSDEvent::NEAR;
break; }
620 case(
PSDEvent::Normal) : { msg->centerState = roch_msgs::PSDEvent::NORMAL;
break; }
621 case(
PSDEvent::Near) : { msg->centerState = roch_msgs::PSDEvent::NEAR;
break; }
625 case(
PSDEvent::Normal) : { msg->rightState = roch_msgs::PSDEvent::NORMAL;
break; }
626 case(
PSDEvent::Near) : { msg->rightState = roch_msgs::PSDEvent::NEAR;
break; }
629 msg->leftSensor = roch_msgs::PSDEvent::LEFT;
630 msg->centerSensor = roch_msgs::PSDEvent::CENTER;
631 msg->rightSensor = roch_msgs::PSDEvent::RIGHT;
652 double large_speed = std::max(std::abs(diff_speed_left), std::abs(diff_speed_right));
void registerInterface(T *iface)
void publishPSDEvent(const double &left, const double ¢er, const double &right)
hardware_interface::JointStateInterface joint_state_interface_
ros::Publisher raw_data_command_publisher_
rochSoftwareDiagnosticTask software_status_task_
ros::Publisher diagnostic_publisher_
void reportLoopDuration(const ros::Duration &duration)
void publishUltEvent(const double &left, const double ¢er, const double &right)
void getRangefinderData()
void publish(const boost::shared_ptr< M > &message) const
double linearToAngular(const double &travel) const
ros::Publisher ult_event_publisher_
double * angular_velocity_covariance
void limitDifferentialSpeed(double &travel_speed_left, double &travel_speed_right)
hardware_interface::VelocityJointInterface velocity_joint_interface_
void publishSensorState()
roch_driver::RawData getdata()
void setHardwareID(const std::string &hwid)
void registerControlInterfaces()
static Transport & instance()
void updateControlFrequency(double frequency)
void updateJointsFromHardware()
ros::Publisher cliff_event_publisher_
void add(const std::string &name, TaskFunction f)
std::vector< double > psdbottom
double angularToLinear(const double &angle) const
double angular_velocity_covariance[9]
ros::Publisher psd_event_publisher_
struct roch_base::rochHardware::SixAxisGyro sixGyro
double linear_acceleration_covariance[9]
roch_msgs::RochStatus roch_status_msg_
std::string gyro_link_frame_
enum roch_base::rochHardware::PSDEvent::State state
rochHardwareDiagnosticTask< sawyer::DataPowerSystem > power_status_task_
std::vector< std::string > V_string
double * linear_acceleration
void writeOverallSpeedCommandsToHardware()
diagnostic_updater::Updater diagnostic_updater_
std::vector< double > ultbottom
rochHardwareDiagnosticTask< sawyer::DataSystemStatus > system_status_task_
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
double orientation_covariance[9]
CliffEvent leftcliffevent
void connect(std::string port)
void publishCliffEvent(const double &left, const double &right)
void controloverallSpeed(double speed_left, double speed_right, double accel_left, double accel_right)
void controlSpeed(double speed_left, double speed_right, double accel_left, double accel_right)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void writeCommandsToHardware()
ros::Publisher sensor_state_publisher_
enum roch_base::rochHardware::CliffEvent::Sensor sensor
#define ROS_DEBUG_STREAM(args)
void registerHandle(const JointStateHandle &handle)
double * angular_velocity
hardware_interface::ImuSensorHandle::Data imuMsgData
ros::NodeHandle private_nh_
void getDifferentControlConstantData()
hardware_interface::ImuSensorInterface imu_sensor_interface_
double * linear_acceleration_covariance
uint32_t getNumSubscribers() const
unsigned char data[MAX_MSG_LENGTH]
rochHardwareDiagnosticTask< sawyer::DataSafetySystemStatus > safety_status_task_
enum roch_base::rochHardware::PSDEvent::Sensor sensor
void configureLimits(double max_speed, double max_accel)
enum roch_base::rochHardware::UltEvent::State state
enum roch_base::rochHardware::UltEvent::Sensor sensor
static geometry_msgs::Quaternion createQuaternionMsgFromRollPitchYaw(double roll, double pitch, double yaw)
double linear_acceleration[3]
std::vector< double > cliffbottom
CliffEvent rightcliffevent
static Ptr requestData(double timeout)
double * orientation_covariance
struct roch_base::rochHardware::Joint joints_[2]
rochHardware(ros::NodeHandle nh, ros::NodeHandle private_nh, double target_control_freq)
void initializeDiagnostics()
double angular_velocity[3]
enum roch_base::rochHardware::CliffEvent::State state