int main(int argc, char **argv) {
  Tserial* p;
  
  p = new Tserial();
  p->connect(UART_COMM_PORT, UART_BAUD_RATE, spNONE);
  
  ros::init(argc, argv, "yaw_publisher");
  
  ros::NodeHandle n;
  ros::Publisher yaw_pub = n.advertise<std_msgs::Float32>("yaw", 10);

  std_msgs::Float32 msg;

  while(ros::ok()) {
    char data_in[10];

    while(p->getChar() != '!');
    p->getArray(data_in, 8);
    
    msg.data = convertDataToVal2(data_in);
    yaw_pub.publish(msg);
  }
  
  p->disconnect();
  return 0;
}
int main()
{   char a;
   Tserial *com;
   com = new Tserial();
   com->connect("COM11", 9600, spNONE);                            //check com port
   cvWaitKey(5000);
   while(1)
   {       
           a=com->getChar();
           cout<<a<<endl;
           //cvWaitKey(1000);
          // cout<<"i";
   }
}
Esempio n. 3
0
double ReadIR(Tserial& serial)
{
    int nbytes = serial.getNbrOfBytes();
    std::stringstream ss; 
    for(int i = 0; i < nbytes; i++)
    {
        ss << serial.getChar();
    }
    double distance;
    while(ss.good())
    {
        std::string str;
        std::getline(ss,str);
        if(!str.empty())
        {
            std::stringstream test(str);
            test >> distance;
        }
    }