Your PI definition shouldn't have the assignment operator:<div><br></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "> #define PI = 3.</span><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "></span><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">141592653589793238462643383279</span><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "></span><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">50288419716</span></div>
<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">should be</span></div>
<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "> #define PI 3.14159265358979323846264338327950288419716<br>
</span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><br></span>-Tucker<br>
<br><br><div class="gmail_quote">On Thu, Jul 29, 2010 at 3:09 PM, ibwood <span dir="ltr"><<a href="mailto:ianbenjiman@hotmail.com">ianbenjiman@hotmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Hi everyone,<br>
<br>
I was really close to successfully compiling a code of mine, when I ran into<br>
this error:<br>
<br>
"expected constructor, destructor, or type conversion before "=" token"<br>
<br>
in lines 126-129 (with ms1, ms2, ms3, ms4 assignments). What does it mean<br>
and how can I fix it?<br>
<br>
<br>
Here is the code:<br>
<br>
<br>
#define PI = 3.14159265358979323846264338327950288419716<br>
<br>
#include "ros/ros.h"<br>
#include "std_msgs/String.h"<br>
<br>
#include <sstream><br>
#include <cmath><br>
#include <iostream><br>
<br>
#include <sys/ioctl.h><br>
#include <sys/types.h><br>
#include <sys/stat.h><br>
#include <stdio.h><br>
#include <limits.h><br>
#include <string.h><br>
#include <fcntl.h><br>
#include <errno.h><br>
#include <termios.h><br>
#include <unistd.h><br>
<br>
using namespace std;<br>
<br>
const double r=0.125, R=0.55, ratio=127; // initialize constants<br>
<br>
int main(int argc, char **argv)<br>
{<br>
unsigned ms1, ms2, ms3, ms4; //motor speeds of omnimaxbot<br>
int i, j, wr, rd, x=0, y=0, z=0, fd, numSent=0;<br>
char parseChar[1], stringIn[50];<br>
<br>
// unsigned long bytes_read = 0; //Number of bytes read from port<br>
// unsigned long bytes_written = 0; //Number of bytes written to the port<br>
<br>
int bStatus;<br>
struct termios options; //Contains various port settings<br>
<br>
<br>
<br>
// attempt to open serial port<br>
<br>
fd = open("/dev/HCS12",O_RDWR | O_NOCTTY | O_NDELAY);<br>
<br>
// set settings for serial port<br>
<br>
system("stty -F /dev/HCS12 115200 cs8 -cstopb -parity -icanon hupcl<br>
-crtscts min 1 time 1");<br>
<br>
<br>
// check for errors opening port<br>
<br>
if (fd == -1 )<br>
<br>
{<br>
<br>
printf("open_port: Unable to open /dev/HCS12");<br>
<br>
}<br>
<br>
<br>
else // if no error<br>
<br>
{<br>
<br>
fcntl(fd, F_SETFL,0);<br>
<br>
printf("Test Port HCS12 has been successfully opened and %d is the file<br>
description\n",fd);<br>
<br>
}<br>
<br>
// get current settings of serial ports<br>
tcgetattr(fd, &options);<br>
<br>
// set the read and write speeds<br>
cfsetispeed(&options, B115200);<br>
cfsetospeed(&options, B115200);<br>
<br>
// set parity<br>
options.c_cflag &= ~CSIZE;<br>
options.c_cflag |= CS8;<br>
<br>
if (bStatus != 0)<br>
{<br>
cout << "byte status error!" << endl;<br>
}<br>
<br>
// initalize node<br>
ros::init(argc, argv, "joyTalker");<br>
ros::NodeHandle joyTalker;<br>
<br>
// Publish to topic joyChatter<br>
ros::Publisher pub = joyTalker.advertise<std_msgs::String>("joyChatter",<br>
1000);<br>
<br>
ros::Rate r(10);<br>
<br>
while (joyTalker.ok())<br>
{<br>
parseChar[0]=0;<br>
<br>
for(j=0; j<50; j++)<br>
{<br>
stringIn[j]=0;<br>
}<br>
<br>
i=0;<br>
<br>
while(parseChar[0] != 10)<br>
{<br>
if(i==50) // exceeds the allowable size<br>
{<br>
break;<br>
}<br>
<br>
rd = read(fd,parseChar,1);<br>
// printf("%s ",parseChar);<br>
if ((parseChar[0] > 43) && ((parseChar[0] < 58) || (parseChar[0]==32)))<br>
{<br>
stringIn[i]=parseChar[0];<br>
i++;<br>
}<br>
<br>
if (wr != 0)<br>
{<br>
cout << "byte status error!!!" << endl;<br>
}<br>
<br>
// kinematics of the omnimaxbot<br>
ms1 = ((x/sqrt(2))+y+(R*tan((z/ratio)*(2*PI))))/((2*PI)*r);<br>
ms2 = (-(x/sqrt(2))+y+(R*tan((z/ratio)*(2*PI))))/((2*PI)*r);<br>
ms3 = ((x/sqrt(2))+y-(R*tan((z/ratio)*(2*PI))))/((2*PI)*r);<br>
ms4 = (-(x/sqrt(2))+y-(R*tan((z/ratio)*(2*PI))))/((2*PI)*r);<br>
<br>
fd = open("/dev/Driver1&2",O_RDWR | O_NOCTTY | O_NDELAY);<br>
<br>
if (fd == -1 )<br>
<br>
{<br>
<br>
perror("open_port: Unable to open /dev/Driver1&2");<br>
<br>
}<br>
<br>
// send to ROS node for communication<br>
numSent = sprintf(stringIn, "%3d,%3d\n", ms1, ms2);<br>
// status[0] = Serial_SendBlock(stringIn, numSent, &numSentS);<br>
<br>
fd = open("/dev/Driver3&4",O_RDWR | O_NOCTTY | O_NDELAY);<br>
<br>
if (fd == -1 )<br>
<br>
{<br>
<br>
perror("open_port: Unable to open /dev/Driver3&4");<br>
<br>
}<br>
<br>
// send to ROS node for communication<br>
numSent = sprintf(stringIn, "%3d,%3d\n", ms3, ms4);<br>
// status[0] = Serial_SendBlock(stringIn, numSent, &numSentS);<br>
}<br>
<br>
printf("got this string %s\n",stringIn);<br>
<br>
// convert message to string for ROS node communication<br>
std_msgs::String msg;<br>
std::stringstream ss;<br>
ss << stringIn;<br>
ROS_INFO("%s", ss.str().c_str());<br>
msg.data = ss.str();<br>
// publish data under topic joyChatter<br>
pub.publish(msg);<br>
<br>
ros::spinOnce();<br>
}<br>
<br>
<br>
return 0;<br>
}<br>
<br>
--<br>
View this message in context: <a href="http://ros-users.122217.n3.nabble.com/C-type-conversion-error-tp1004701p1004701.html" target="_blank">http://ros-users.122217.n3.nabble.com/C-type-conversion-error-tp1004701p1004701.html</a><br>
Sent from the ROS-Users mailing list archive at Nabble.com.<br>
<br>
------------------------------------------------------------------------------<br>
The Palm PDK Hot Apps Program offers developers who use the<br>
Plug-In Development Kit to bring their C/C++ apps to Palm for a share<br>
of $1 Million in cash or HP Products. Visit us here for more details:<br>
<a href="http://p.sf.net/sfu/dev2dev-palm" target="_blank">http://p.sf.net/sfu/dev2dev-palm</a><br>
_______________________________________________<br>
ros-users mailing list<br>
<a href="mailto:ros-users@lists.sourceforge.net">ros-users@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/ros-users" target="_blank">https://lists.sourceforge.net/lists/listinfo/ros-users</a><br>
_______________________________________________<br>
ros-users mailing list<br>
<a href="mailto:ros-users@code.ros.org">ros-users@code.ros.org</a><br>
<a href="https://code.ros.org/mailman/listinfo/ros-users" target="_blank">https://code.ros.org/mailman/listinfo/ros-users</a><br>
</blockquote></div><br></div>