00001 #include <ros/ros.h>
00002 #include "roch_base/roch_hardware.h"
00003
00004 #include <boost/assign/list_of.hpp>
00005 #include <float.h>
00006 #define polling_timeout_ 20
00007 using namespace std;
00008 void publishRawData()
00009 {
00010 #if 0
00011 std::ostringstream ostream;
00012 sawyer::base_data::RawData data =sawyer::Transport::instance().getdata();
00013
00014 ostream << "command: { " ;
00015 ostream << std::setfill('0') << std::uppercase;
00016 for (unsigned int i=0; i < data.length; i++)
00017 ostream << std::hex << std::setw(2) << static_cast<unsigned int>(data.data[i]) << " " << std::dec;
00018 ostream << "}";
00019 std_msgs::StringPtr msg(new std_msgs::String);
00020 msg->data = ostream.str();
00021 ROS_INFO("reveive command:%s",msg->data.c_str());
00022 #endif
00023 }
00024
00025 namespace
00026 {
00027 const uint8_t LEFT = 0, RIGHT = 1;
00028 };
00029 int main(int argc, char** argv){
00030
00031 std::string port = "/dev/roch";
00032 core::connect(port);
00033 while(1){
00034
00035 core::Channel<sawyer::DataRangefinders>::Ptr rangefinderData =
00036 core::Channel<sawyer::DataRangefinders>::requestData(polling_timeout_);
00037 publishRawData();
00038 if(rangefinderData){
00039 ROS_INFO("Received rangefinder Data, counts:%d, data[0]:%.2lf , data[1]:%.2lf, data[2]:%.2lf , data[3]:%.2lf, data[4]:%.2lf, data[5]:%.2lf, data[6]:%.2lf, data[7]:%.2lf.",
00040 (int)rangefinderData->getRangefinderCount(),rangefinderData->getDistance(0),
00041 rangefinderData->getDistance(1),
00042 rangefinderData->getDistance(2),
00043 rangefinderData->getDistance(3),
00044 rangefinderData->getDistance(4),
00045 rangefinderData->getDistance(5),
00046 rangefinderData->getDistance(6),
00047 rangefinderData->getDistance(7));
00048 }
00049 #if 0
00050 core::Channel<sawyer::DataRangefinderTimings>::Ptr rangefinderDataAndTime =
00051 core::Channel<sawyer::DataRangefinderTimings>::requestData(polling_timeout_);
00052 publishRawData();
00053
00054 if(rangefinderDataAndTime){
00055 ROS_INFO("Received rangefinder Data and time, counts:%d, data[0]:%.2lf, time[0]:%d, "
00056 " data[1]:%.2lf, time[1]:%d, "
00057 " data[2]:%.2lf, time[2]:%d, "
00058 " data[3]:%.2lf, time[3]:%d, "
00059 " data[4]:%.2lf, time[4]:%d, "
00060 " data[5]:%.2lf, time[5]:%d, "
00061 " data[6]:%.2lf, time[6]:%d, "
00062 " data[7]:%.2lf, time[7]:%d. ",
00063 (int)rangefinderDataAndTime->getRangefinderCount(),rangefinderDataAndTime->getDistance(0),rangefinderDataAndTime->getAcquisitionTime(0),
00064 rangefinderDataAndTime->getDistance(1),rangefinderDataAndTime->getAcquisitionTime(1),
00065 rangefinderDataAndTime->getDistance(2),rangefinderDataAndTime->getAcquisitionTime(2),
00066 rangefinderDataAndTime->getDistance(3),rangefinderDataAndTime->getAcquisitionTime(3),
00067 rangefinderDataAndTime->getDistance(4),rangefinderDataAndTime->getAcquisitionTime(4),
00068 rangefinderDataAndTime->getDistance(5),rangefinderDataAndTime->getAcquisitionTime(5),
00069 rangefinderDataAndTime->getDistance(6),rangefinderDataAndTime->getAcquisitionTime(6),
00070 rangefinderDataAndTime->getDistance(7),rangefinderDataAndTime->getAcquisitionTime(7));
00071 }
00072 #endif
00073 }
00074 return 0;
00075 }