[ros-users] OccupancyGrid message: expected unqualified-id before numeric constant

Ivan Dryanovski ivan.dryanovski at gmail.com
Thu Jul 14 13:28:04 UTC 2011


This is mostly a shot in the dark, but have you tried removing the
#defines and using const doubles?

Ivan

On Thu, Jul 14, 2011 at 4:49 AM, Steven Martin <steven.martin at qut.edu.au> wrote:
> Hi Guys,
>
> I am just trying to set the resolution in my Occupancy Grid message.
>
>    nav_msgs::OccupancyGrid costmap;
>    costmap.info.resolution = 1.0;
>
> but I get this compile error
>
>  /src/costmap.cpp: In function ‘void chatterCallback(const sensor_msgs::LaserScan_<std::allocator<void> >::ConstPtr&)’:
>  /src/costmap.cpp:19:18: error: expected unqualified-id before numeric constant
>  /src/costmap.cpp:19:18: error: expected ‘;’ before numeric constant
>
>
> Any ideas? One of the other students in the lab had a similar issue with setting "g" in a rgb colour message. "r" and "b" could set but "g" threw the same error. Interestingly both were Float32 message variables.
>
>
> Steve
>
> -----------------------------------
>
> #include "ros/ros.h"
> #include "sensor_msgs/LaserScan.h"
> #include "nav_msgs/OccupancyGrid.h"
> #include "nav_msgs/MapMetaData.h"
>
> #include <math.h>
> #include <iostream>
>
> #define resolution 0.5
> #define size 30  //+10m , -10m
> const int length = size/resolution;
> ros::Publisher costmap_pub;
>
>
> void chatterCallback(const sensor_msgs::LaserScan::ConstPtr& msg)
> {
>    nav_msgs::OccupancyGrid costmap;
>    costmap.data.resize(length*length,0);
>    costmap.info.resolution = 1.0;
>    costmap.info.width = length;
>    costmap.info.height = length;
>    costmap.header.stamp = ros::Time::now();
>
>    float angle = msg->angle_min;
>    int points = (int)(msg->angle_max - msg->angle_min)/msg->angle_increment;
>
>
> ....
>
>
>
>
> Steven Martin
> steven.martin at qut.edu.au
>
> PhD Student
> Queensland University of Technology
> Gardens Point, S1107
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users
>



More information about the ros-users mailing list