ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

catkin_make error : 'float32' does not name a type

asked 2017-06-30 09:46:47 -0500

أسامة الادريسي gravatar image

Hi, when i do the catkin_make command I get the following error :

[ 93%] Built target mastering_ros_demo_pkg_generate_messages
[ 93%] Built target irobot_generate_messages
[ 94%] Building CXX object irobot/CMakeFiles/range_to_laserscan.dir/src/range_to_laserscan.cpp.o
[ 96%] Built target add_two_ints_client
[ 98%] Built target add_two_ints_server
/home/osaka/catkin_ws/src/irobot/src/range_to_laserscan.cpp:6:1: error: ‘float32’ does not name a type
 float32 data[3];
 ^
/home/osaka/catkin_ws/src/irobot/src/range_to_laserscan.cpp: In function ‘void u1Callback(const ConstPtr&)’:
/home/osaka/catkin_ws/src/irobot/src/range_to_laserscan.cpp:10:3: error: ‘data’ was not declared in this scope
   data[0]=r1->range;
   ^
/home/osaka/catkin_ws/src/irobot/src/range_to_laserscan.cpp: In function ‘void u2Callback(const ConstPtr&)’:
/home/osaka/catkin_ws/src/irobot/src/range_to_laserscan.cpp:15:3: error: ‘data’ was not declared in this scope
   data[1]=r1->range;
   ^
/home/osaka/catkin_ws/src/irobot/src/range_to_laserscan.cpp:15:11: error: ‘r1’ was not declared in this scope
   data[1]=r1->range;
           ^
/home/osaka/catkin_ws/src/irobot/src/range_to_laserscan.cpp: In function ‘void u3Callback(const ConstPtr&)’:
/home/osaka/catkin_ws/src/irobot/src/range_to_laserscan.cpp:20:3: error: ‘data’ was not declared in this scope
   data[2]=r1->range;
   ^
/home/osaka/catkin_ws/src/irobot/src/range_to_laserscan.cpp:20:11: error: ‘r1’ was not declared in this scope
   data[2]=r1->range;
           ^
/home/osaka/catkin_ws/src/irobot/src/range_to_laserscan.cpp: In function ‘int main(int, char**)’:
/home/osaka/catkin_ws/src/irobot/src/range_to_laserscan.cpp:40:2: error: ‘msg’ was not declared in this scope
  msg.rages[i]  = data[i];
  ^
/home/osaka/catkin_ws/src/irobot/src/range_to_laserscan.cpp:40:18: error: ‘data’ was not declared in this scope
  msg.rages[i]  = data[i];
                  ^
irobot/CMakeFiles/range_to_laserscan.dir/build.make:62: recipe for target 'irobot/CMakeFiles/range_to_laserscan.dir/src/range_to_laserscan.cpp.o' failed
make[2]: *** [irobot/CMakeFiles/range_to_laserscan.dir/src/range_to_laserscan.cpp.o] Error 1
CMakeFiles/Makefile2:4362: recipe for target 'irobot/CMakeFiles/range_to_laserscan.dir/all' failed
make[1]: *** [irobot/CMakeFiles/range_to_laserscan.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

roscpp code :

#include "ros/ros.h"
#include "sensor_msgs/Range.h"
#include "sensor_msgs/LaserScan.h"
#include "std_msgs/Float32.h"

float32 data[3];

void u1Callback(const sensor_msgs::Range::ConstPtr& r1)
{
  data[0]=r1->range;
}

void u2Callback(const sensor_msgs::Range::ConstPtr& r2)
{
  data[1]=r1->range;
}

void u3Callback(const sensor_msgs::Range::ConstPtr& r3)
{
  data[2]=r1->range;
}

int main(int argc, char** argv){
   ros::init(argc, argv, "rang_to_laserscan");
   ros::NodeHandle n;

   ros::Subscriber sub_u1 = n.subscribe("/ultrasound1", 1000, u1Callback);
   ros::Subscriber sub_u2 = n.subscribe("/ultrasound2", 1000, u2Callback);
   ros::Subscriber sub_u3 = n.subscribe("/ultrasound3", 1000, u3Callback);

   ros::Publisher pub1 = n.advertise<sensor_msgs::LaserScan>("/pub1", 100);

   ros::Rate loop_rate(10);

   while (ros::ok())
   {
      sensor_msgs::LaserScan msg1;

      for(int i=0;i<3;i++){
           msg.rages[i]  = data[i];
      }   

      pub1.publish(msg1);

      ros::spinOnce();

      loop_rate.sleep();
   }

   return 0;
}
edit retag flag offensive close merge delete

Comments

1
ROSkinect gravatar image ROSkinect  ( 2017-06-30 10:17:19 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2017-06-30 10:43:26 -0500

vacky11 gravatar image

Since you have included #include "std_msgs/Float32.h", you should use std_msgs::Float32 data[3] instead of float32 data[3]

edit flag offensive delete link more

Comments

thank you, it work

أسامة الادريسي gravatar image أسامة الادريسي  ( 2017-06-30 13:19:45 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-06-30 09:46:47 -0500

Seen: 3,873 times

Last updated: Jun 30 '17