Problem with twist message: unqualified-id before numeric constant
Hi folks!
I'm having a bit of trouble assigning values to a Twist type message, my code below runs into an error:
/home/parcon/ros_workspace/arl_ardrone/arl_ardrone_control/src/pid_to_point.cpp:183:22: error: expected unqualified-id before numeric constant
/home/parcon/ros_workspace/arl_ardrone/arl_ardrone_control/src/pid_to_point.cpp:183:22: error: expected ‘;’ before numeric constant
/home/parcon/ros_workspace/arl_ardrone/arl_ardrone_control/src/pid_to_point.cpp:184:22: error: expected unqualified-id before numeric constant
/home/parcon/ros_workspace/arl_ardrone/arl_ardrone_control/src/pid_to_point.cpp:184:22: error: expected ‘;’ before numeric constant
/home/parcon/ros_workspace/arl_ardrone/arl_ardrone_control/src/pid_to_point.cpp:185:22: error: expected unqualified-id before numeric constant
/home/parcon/ros_workspace/arl_ardrone/arl_ardrone_control/src/pid_to_point.cpp:185:22: error: expected ‘;’ before numeric constant
/home/parcon/ros_workspace/arl_ardrone/arl_ardrone_control/src/pid_to_point.cpp:186:23: error: expected unqualified-id before numeric constant
/home/parcon/ros_workspace/arl_ardrone/arl_ardrone_control/src/pid_to_point.cpp:186:23: error: expected ‘;’ before numeric constant
The error comes from the last few lines of the code where the Twist message values are assigned. I've looked at the types, the definition of Twist, with no success. Can anyone see where I'm going wrong? I expect to be able to assign a float to this value: twist_msg.linear.x
Thanks for the help!
/*
* Copyright (c) 2012, Parker Conroy
* ARLab @ University of Utah
* All rights reserved.
*
*
*
*
*
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include "ros/ros.h"
#include <math.h>
#include <tf/transform_broadcaster.h>
#include "tf/transform_listener.h"
#include "geometry_msgs/TransformStamped.h"
#include "ros/time.h"
#include <geometry_msgs/Twist.h>
#define yaw 0
#define pitch 1
#define roll 2
#define thrust 3
#define x 0
#define y 1
#define z 2
#define t 3
// Variables!!!
tf::Transformer transformer;
tf::TransformListener tf_listener;
tf::TransformBroadcaster br;
tf::StampedTransform desired_pos;
tf::StampedTransform ardrone;
tf::StampedTransform trackee;
tf::StampedTransform desired_in_ardrone_coords;
ros::Publisher pub_twist;
geometry_msgs::Twist twist_msg;
//btQuaternion ardrone_yawed;
double new_data[4];
double old_data[4];
double integration[4];
double derivative[4];
float controls[4];
float min_control[4];
float max_control[4];
double pid[4];
float min_pid;
float max_pid;
float map(float value, float in_min, float in_max, float out_min, float out_max) {
return (float)((value - in_min) * (out_max - out_min) / (in_max - in_min) + out_min);
}
int main(int argc, char **argv)
{
int rate= 200;
float inv_rate=1/rate;
ros::init(argc, argv, "Tracker");
ros::NodeHandle n;
ros::Rate r(200); //update @ 200hz
memset(controls, 0, sizeof(int64_t)*4);
memset(old_data, 0, sizeof(double)*4);
memset(new_data, 0, sizeof(double)*4);
memset(integration, 0, sizeof(double)*4);
memset(derivative, 0, sizeof(double)*4);
memset(pid, 0, sizeof(double)*4);
//PID params
min_control[yaw] =-1.0;
min_control[roll] =-1.0;
min_control[pitch]=-1.0;
min_control[thrust]=-1.0;
max_control[yaw]=1.0;
max_control[roll]=1.0;
max_control[pitch]=1.0;
max_control[thrust]=1.0;
min_pid =-5.0;
max_pid =5.0;
float K_p[] = {1, 1, 1};
float K_d[] = {0,0,0};
float K_i ...