[ros-users] OccupancyGrid message: expected unqualified-id b…

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: User discussions
Date:  
To: ros-users@code.ros.org
Subject: [ros-users] OccupancyGrid message: expected unqualified-id before numeric constant
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


PhD Student
Queensland University of Technology
Gardens Point, S1107