Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

problem with Float32MultiArray in rosserial

I'm working on my arduino mega 2560 trying to alocate a float values that a flex sensor gives to arduino, but when i try lo read the topic it don't runs, nothing happens:

code in arduino:

#include <ros.h>
    #include <indice.h>
    #include <std_msgs/Float32.h>
    #include <std_msgs/Float32MultiArray.h>



    ros::NodeHandle nh;

   std_msgs::Float32MultiArray angulos;
   ros::Publisher angulos_pub("angulos", &angulos);

    int findice=1;
    int fcorazon=2;
    int fanular=3;
    int fmenique=4;
    int fpulgar=0;
    int vind = 0;//valor que sensa el flex sensor valor en bits
    int vcor = 0;//valor que sensa el flex sensor valor en bits
    int vanu = 0;//valor que sensa el flex sensor valor en bits
    int vmen = 0;//valor que sensa el flex sensor valor en bits
    int vpul = 0;//valor que sensa el flex sensor valor en bits
    float radind;
    float radcor;
    float radanu;
    float radmen;

    char dim0_label[] = "angulos";

    void setup(){
      nh.initNode();

      angulos.layout.dim = (std_msgs::MultiArrayDimension *)
      malloc(sizeof(std_msgs::MultiArrayDimension) * 1);
      angulos.layout.dim[0].label = dim0_label;
      angulos.layout.dim[0].size = 5;
      angulos.layout.dim[0].stride = 1*5;
      angulos.layout.dim_length = 1;
      angulos.layout.data_offset = 0;

      angulos.data = (float *)malloc(sizeof(float)*5);
      nh.advertise(angulos_pub);

      angulos.data_length = 5;

    }

    void loop(){

       vind =analogRead(findice);
       vcor =analogRead(fcorazon);
       vanu =analogRead(fanular);
       vmen =analogRead(fmenique);

       radind = ((445-(vind))/(50.7));
       radcor = ((449.85-(vcor))/(55.41));
       radanu = ((479.1-(vanu))/(56.56));
       radmen = ((414.95-(vmen))/(95.76));
       angulos_pub.publish(&angulos);
       nh.spinOnce();
       delay(500);

    }

problem with Float32MultiArray in rosserial

I'm working on my arduino mega 2560 trying to alocate a float values that a flex sensor gives to arduino, but when i try lo read the topic it don't runs, nothing happens:

code in arduino:

#include <ros.h>
    #include <indice.h>
    #include <std_msgs/Float32.h>
    #include <std_msgs/Float32MultiArray.h>



    ros::NodeHandle nh;

   std_msgs::Float32MultiArray angulos;
   ros::Publisher angulos_pub("angulos", &angulos);

    int findice=1;
    int fcorazon=2;
    int fanular=3;
    int fmenique=4;
    int fpulgar=0;
    int vind = 0;//valor que sensa el flex sensor valor en bits
    int vcor = 0;//valor que sensa el flex sensor valor en bits
    int vanu = 0;//valor que sensa el flex sensor valor en bits
    int vmen = 0;//valor que sensa el flex sensor valor en bits
    int vpul = 0;//valor que sensa el flex sensor valor en bits
    float radind;
    float radcor;
    float radanu;
    float radmen;

    char dim0_label[] = "angulos";

    void setup(){
      nh.initNode();

      angulos.layout.dim = (std_msgs::MultiArrayDimension *)
      malloc(sizeof(std_msgs::MultiArrayDimension) * 1);
      angulos.layout.dim[0].label = dim0_label;
      angulos.layout.dim[0].size = 5;
4;
      angulos.layout.dim[0].stride = 1*5;
1*4;
      angulos.layout.dim_length = 1;
      angulos.layout.data_offset = 0;

      angulos.data = (float *)malloc(sizeof(float)*5);
*)malloc(sizeof(float)*4);
      angulos.data_length = 4;
      nh.advertise(angulos_pub);

      angulos.data_length = 5;
 
    }

    void loop(){

       vind =analogRead(findice);
       vcor =analogRead(fcorazon);
       vanu =analogRead(fanular);
       vmen =analogRead(fmenique);

       radind = ((445-(vind))/(50.7));
       radcor = ((449.85-(vcor))/(55.41));
       radanu = ((479.1-(vanu))/(56.56));
       radmen = ((414.95-(vmen))/(95.76));
       angulos_pub.publish(&angulos);
       nh.spinOnce();
       delay(500);

    }

problem with Float32MultiArray in rosserial

I'm working on my arduino mega 2560 trying to alocate a float values that a flex sensor gives to arduino, but when i try lo read the topic it don't runs, nothing happens:

code in arduino:

 #include <ros.h>
    #include <indice.h>
    #include <std_msgs/Float32.h>
    #include <std_msgs/Float32MultiArray.h>



    ros::NodeHandle nh;

   std_msgs::Float32MultiArray angulos;
   ros::Publisher angulos_pub("angulos", &angulos);

    int findice=1;
    int fcorazon=2;
    int fanular=3;
    int fmenique=4;
    int fpulgar=0;
    int vind = 0;//valor que sensa el flex sensor valor en bits
    int vcor = 0;//valor que sensa el flex sensor valor en bits
    int vanu = 0;//valor que sensa el flex sensor valor en bits
    int vmen = 0;//valor que sensa el flex sensor valor en bits
    int vpul = 0;//valor que sensa el flex sensor valor en bits
    float radind;
    float radcor;
    float radanu;
    float radmen;

    char dim0_label[] = "angulos";

    void setup(){
      nh.initNode();

      angulos.layout.dim = (std_msgs::MultiArrayDimension *)
      malloc(sizeof(std_msgs::MultiArrayDimension) * 1);
      angulos.layout.dim[0].label = dim0_label;
      angulos.layout.dim[0].size = 4;
      angulos.layout.dim[0].stride = 1*4;
      angulos.layout.dim_length = 1;
      angulos.layout.data_offset = 0;

      angulos.data = (float *)malloc(sizeof(float)*4);
      angulos.data_length = 4;
      nh.advertise(angulos_pub);



    }

    void loop(){

       vind =analogRead(findice);
       vcor =analogRead(fcorazon);
       vanu =analogRead(fanular);
       vmen =analogRead(fmenique);

       radind = ((445-(vind))/(50.7));
       radcor = ((449.85-(vcor))/(55.41));
       radanu = ((479.1-(vanu))/(56.56));
       radmen = ((414.95-(vmen))/(95.76));
       angulos_pub.publish(&angulos);
       nh.spinOnce();
       delay(500);

    }

problem with Float32MultiArray in rosserial

I'm working on my arduino mega 2560 trying to alocate a float values that a flex sensor gives to arduino, but when i try lo read the topic it don't runs, nothing happens:only gives to me this message when i run:

jose@ubuntu:~$ rosrun rosserial_python serial_node.py /dev/ttyACM1
[INFO] [WallTime: 1353426930.914839] ROS Serial Python Node
[INFO] [WallTime: 1353426930.917873] Connected on /dev/ttyACM1 at 57600 baud
[INFO] [WallTime: 1353426933.336893] Setup Publisher on angulos [std_msgs/Float32MultiArray]
[ERROR] [WallTime: 1353426945.920335] Lost sync with device, restarting...
[INFO] [WallTime: 1353426946.190745] Setup Publisher on angulos [std_msgs/Float32MultiArray]
[ERROR] [WallTime: 1353426960.920971] Lost sync with device, restarting...
[INFO] [WallTime: 1353426961.049990] Setup Publisher on angulos [std_msgs/Float32MultiArray]
[ERROR] [WallTime: 1353426975.923001] Lost sync with device, restarting...
[INFO] [WallTime: 1353426976.409013] Setup Publisher on angulos [std_msgs/Float32MultiArray]
[ERROR] [WallTime: 1353426990.927987] Lost sync with device, restarting...
[INFO] [WallTime: 1353426991.268148] Setup Publisher on angulos [std_msgs/Float32MultiArray]
[ERROR] [WallTime: 1353427005.932885] Lost sync with device, restarting...
[INFO] [WallTime: 1353427006.127405] Setup Publisher on angulos [std_msgs/Float32MultiArray]

code in arduino:

    #include <ros.h>
    #include <std_msgs/Float32MultiArray.h>



    ros::NodeHandle nh;

   std_msgs::Float32MultiArray angulos;
   ros::Publisher angulos_pub("angulos", &angulos);

    int findice=1;
    int fcorazon=2;
    int fanular=3;
    int fmenique=4;
    int fpulgar=0;
    int vind = 0;//valor que sensa el flex sensor valor en bits
    int vcor = 0;//valor que sensa el flex sensor valor en bits
    int vanu = 0;//valor que sensa el flex sensor valor en bits
    int vmen = 0;//valor que sensa el flex sensor valor en bits
    int vpul = 0;//valor que sensa el flex sensor valor en bits
    float radind;
    float radcor;
    float radanu;
    float radmen;

    char dim0_label[] = "angulos";

    void setup(){
      nh.initNode();

      angulos.layout.dim = (std_msgs::MultiArrayDimension *)
      malloc(sizeof(std_msgs::MultiArrayDimension) * 1);
      angulos.layout.dim[0].label = dim0_label;
      angulos.layout.dim[0].size = 4;
      angulos.layout.dim[0].stride = 1*4;
      angulos.layout.dim_length = 1;
      angulos.layout.data_offset = 0;

      angulos.data = (float *)malloc(sizeof(float)*4);
      angulos.data_length = 4;
      nh.advertise(angulos_pub);



    }

    void loop(){

       vind =analogRead(findice);
       vcor =analogRead(fcorazon);
       vanu =analogRead(fanular);
       vmen =analogRead(fmenique);

       radind = ((445-(vind))/(50.7));
       radcor = ((449.85-(vcor))/(55.41));
       radanu = ((479.1-(vanu))/(56.56));
       radmen = ((414.95-(vmen))/(95.76));
       angulos.data[0]= radind;
       angulos.data[1]= radcor;
       angulos.data[2]= radanu;
       angulos.data[3]= radmen;

       angulos_pub.publish(&angulos);
       nh.spinOnce();
       delay(500);

    }

problem with Float32MultiArray in rosserial

I'm working on my arduino mega 2560 trying to alocate a float values that a flex sensor gives to arduino, but when i try lo read the topic it don't runs, only gives to me this message when i run:

jose@ubuntu:~$ rosrun rosserial_python serial_node.py /dev/ttyACM1
[INFO] [WallTime: 1353426930.914839] ROS Serial Python Node
[INFO] [WallTime: 1353426930.917873] Connected on /dev/ttyACM1 at 57600 baud
[INFO] [WallTime: 1353426933.336893] Setup Publisher on angulos [std_msgs/Float32MultiArray]
[ERROR] [WallTime: 1353426945.920335] Lost sync with device, restarting...
[INFO] [WallTime: 1353426946.190745] Setup Publisher on angulos [std_msgs/Float32MultiArray]
[ERROR] [WallTime: 1353426960.920971] Lost sync with device, restarting...
[INFO] [WallTime: 1353426961.049990] Setup Publisher on angulos [std_msgs/Float32MultiArray]
[ERROR] [WallTime: 1353426975.923001] Lost sync with device, restarting...
[INFO] [WallTime: 1353426976.409013] Setup Publisher on angulos [std_msgs/Float32MultiArray]
[ERROR] [WallTime: 1353426990.927987] Lost sync with device, restarting...
[INFO] [WallTime: 1353426991.268148] Setup Publisher on angulos [std_msgs/Float32MultiArray]
[ERROR] [WallTime: 1353427005.932885] Lost sync with device, restarting...
[INFO] [WallTime: 1353427006.127405] Setup Publisher on angulos [std_msgs/Float32MultiArray]

code in arduino:

    #include <ros.h>
    #include <std_msgs/Float32MultiArray.h>



    ros::NodeHandle nh;

   std_msgs::Float32MultiArray angulos;
   ros::Publisher angulos_pub("angulos", &angulos);

    int findice=1;
    int fcorazon=2;
    int fanular=3;
    int fmenique=4;
    int fpulgar=0;
    int vind = 0;//valor que sensa el flex sensor valor en bits
    int vcor = 0;//valor que sensa el flex sensor valor en bits
    int vanu = 0;//valor que sensa el flex sensor valor en bits
    int vmen = 0;//valor que sensa el flex sensor valor en bits
    int vpul = 0;//valor que sensa el flex sensor valor en bits
    float radind;
    float radcor;
    float radanu;
    float radmen;

    char dim0_label[] = "angulos";

    void setup(){
      nh.initNode();

      angulos.layout.dim = (std_msgs::MultiArrayDimension *)
      malloc(sizeof(std_msgs::MultiArrayDimension) * 1);
      angulos.layout.dim[0].label = dim0_label;
"angulos";
      angulos.layout.dim[0].size = 4;
      angulos.layout.dim[0].stride = 1*4;
      angulos.layout.dim_length = 1;
      angulos.layout.data_offset = 0;

      angulos.data = (float *)malloc(sizeof(float)*4);
      angulos.data_length = 4;
      nh.advertise(angulos_pub);



    }

    void loop(){

       vind =analogRead(findice);
       vcor =analogRead(fcorazon);
       vanu =analogRead(fanular);
       vmen =analogRead(fmenique);

       radind = ((445-(vind))/(50.7));
       radcor = ((449.85-(vcor))/(55.41));
       radanu = ((479.1-(vanu))/(56.56));
       radmen = ((414.95-(vmen))/(95.76));
       angulos.data[0]= radind;
       angulos.data[1]= radcor;
       angulos.data[2]= radanu;
       angulos.data[3]= radmen;

       angulos_pub.publish(&angulos);
       nh.spinOnce();
       delay(500);

    }

problem with Float32MultiArray in rosserial

I'm working on my arduino mega 2560 trying to alocate a float values that a flex sensor gives to arduino, but when i try lo read the topic it don't runs, only gives to me this message when i run:

jose@ubuntu:~$ rosrun rosserial_python serial_node.py /dev/ttyACM1
[INFO] [WallTime: 1353426930.914839] ROS Serial Python Node
[INFO] [WallTime: 1353426930.917873] Connected on /dev/ttyACM1 at 57600 baud
[INFO] [WallTime: 1353426933.336893] Setup Publisher on angulos [std_msgs/Float32MultiArray]
[ERROR] [WallTime: 1353426945.920335] Lost sync with device, restarting...
[INFO] [WallTime: 1353426946.190745] Setup Publisher on angulos [std_msgs/Float32MultiArray]
[ERROR] [WallTime: 1353426960.920971] Lost sync with device, restarting...
[INFO] [WallTime: 1353426961.049990] Setup Publisher on angulos [std_msgs/Float32MultiArray]
[ERROR] [WallTime: 1353426975.923001] Lost sync with device, restarting...
[INFO] [WallTime: 1353426976.409013] Setup Publisher on angulos [std_msgs/Float32MultiArray]
[ERROR] [WallTime: 1353426990.927987] Lost sync with device, restarting...
[INFO] [WallTime: 1353426991.268148] Setup Publisher on angulos [std_msgs/Float32MultiArray]
[ERROR] [WallTime: 1353427005.932885] Lost sync with device, restarting...
[INFO] [WallTime: 1353427006.127405] Setup Publisher on angulos [std_msgs/Float32MultiArray]

code in arduino:

    #include <ros.h>
    #include <std_msgs/Float32MultiArray.h>



    ros::NodeHandle nh;

   std_msgs::Float32MultiArray angulos;
   ros::Publisher angulos_pub("angulos", &angulos);

    int findice=1;
    int fcorazon=2;
    int fanular=3;
    int fmenique=4;
    int fpulgar=0;
    int vind = 0;//valor que sensa el flex sensor valor en bits
    int vcor = 0;//valor que sensa el flex sensor valor en bits
    int vanu = 0;//valor que sensa el flex sensor valor en bits
    int vmen = 0;//valor que sensa el flex sensor valor en bits
    int vpul = 0;//valor que sensa el flex sensor valor en bits
    float radind;
    float radcor;
    float radanu;
    float radmen;

      void setup(){
      nh.initNode();

      angulos.layout.dim = (std_msgs::MultiArrayDimension *)
      malloc(sizeof(std_msgs::MultiArrayDimension) * 1);
      angulos.layout.dim[0].label = "angulos";
      angulos.layout.dim[0].size = 4;
      angulos.layout.dim[0].stride = 1*4;
      angulos.layout.dim_length = 1;
      angulos.layout.data_offset = 0;

      angulos.data = (float *)malloc(sizeof(float)*4);
      angulos.data_length = 4;
      nh.advertise(angulos_pub);



    }

    void loop(){

       vind =analogRead(findice);
       vcor =analogRead(fcorazon);
       vanu =analogRead(fanular);
       vmen =analogRead(fmenique);

       radind = ((445-(vind))/(50.7));
       radcor = ((449.85-(vcor))/(55.41));
       radanu = ((479.1-(vanu))/(56.56));
       radmen = ((414.95-(vmen))/(95.76));
       angulos.data[0]= radind;
       angulos.data[1]= radcor;
       angulos.data[2]= radanu;
       angulos.data[3]= radmen;

       angulos_pub.publish(&angulos);
       nh.spinOnce();
       delay(500);

    }

problem with Float32MultiArray in rosserial

I'm working on my arduino mega 2560 trying to alocate a float values that a flex sensor gives to arduino, but when i try lo read the topic it don't runs, only gives to me this message when i run:

jose@ubuntu:~$ rosrun rosserial_python serial_node.py /dev/ttyACM1
[INFO] [WallTime: 1353426930.914839] ROS Serial Python Node
[INFO] [WallTime: 1353426930.917873] Connected on /dev/ttyACM1 at 57600 baud
[INFO] [WallTime: 1353426933.336893] Setup Publisher on angulos [std_msgs/Float32MultiArray]
[ERROR] [WallTime: 1353426945.920335] Lost sync with device, restarting...
[INFO] [WallTime: 1353426946.190745] Setup Publisher on angulos [std_msgs/Float32MultiArray]
[ERROR] [WallTime: 1353426960.920971] Lost sync with device, restarting...
[INFO] [WallTime: 1353426961.049990] Setup Publisher on angulos [std_msgs/Float32MultiArray]
[ERROR] [WallTime: 1353426975.923001] Lost sync with device, restarting...
[INFO] [WallTime: 1353426976.409013] Setup Publisher on angulos [std_msgs/Float32MultiArray]
[ERROR] [WallTime: 1353426990.927987] Lost sync with device, restarting...
[INFO] [WallTime: 1353426991.268148] Setup Publisher on angulos [std_msgs/Float32MultiArray]
[ERROR] [WallTime: 1353427005.932885] Lost sync with device, restarting...
[INFO] [WallTime: 1353427006.127405] Setup Publisher on angulos [std_msgs/Float32MultiArray]

code in arduino:

    #include <ros.h>
    #include <std_msgs/Float32MultiArray.h>



    ros::NodeHandle nh;

   std_msgs::Float32MultiArray angulos;
   ros::Publisher angulos_pub("angulos", &angulos);

    int findice=1;
    int fcorazon=2;
    int fanular=3;
    int fmenique=4;
    int fpulgar=0;
    int vind = 0;//valor que sensa el flex sensor valor en bits
    int vcor = 0;//valor que sensa el flex sensor valor en bits
    int vanu = 0;//valor que sensa el flex sensor valor en bits
    int vmen = 0;//valor que sensa el flex sensor valor en bits
    int vpul = 0;//valor que sensa el flex sensor valor en bits
    float radind;
    float radcor;
    float radanu;
    float radmen;

      void setup(){
      nh.initNode();

      angulos.layout.dim = (std_msgs::MultiArrayDimension *)
      malloc(sizeof(std_msgs::MultiArrayDimension) * 1);
      angulos.layout.dim[0].label = "angulos";
      angulos.layout.dim[0].size = 4;
      angulos.layout.dim[0].stride = 1*4;
      angulos.layout.dim_length = 1;
      angulos.layout.data_offset = 0;

      angulos.data = (float *)malloc(sizeof(float)*4);
      angulos.data_length = 4;
      nh.advertise(angulos_pub);



    }

    void loop(){

       vind =analogRead(findice);
       vcor =analogRead(fcorazon);
       vanu =analogRead(fanular);
       vmen =analogRead(fmenique);

       radind = ((445-(vind))/(50.7));
       radcor = ((449.85-(vcor))/(55.41));
       radanu = ((479.1-(vanu))/(56.56));
       radmen = ((414.95-(vmen))/(95.76));
       angulos.data[0]= radind;
       angulos.data[1]= radcor;
       angulos.data[2]= radanu;
       angulos.data[3]= radmen;

       angulos_pub.publish(&angulos);
       nh.spinOnce();
       delay(500);

    }