hbrobotics / ros_arduino_bridge

ROS + Arduino = Robot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wont compile for NodeMCU (esp8266 boards)?

chrissunny94 opened this issue · comments

Below is the debug message i recieved on the arduino IDE

ROSArduinoBridge:125: error: 'int index' redeclared as different kind of symbol int index = 0; ^ In file included from /home/chris/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/xtensa-lx106-elf/include/stdlib.h:11:0, Multiple libraries were found for "Servo.h" Used: /home/chris/.arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/Servo Not used: /opt/arduino-1.8.4/libraries/Servo from /home/chris/.arduino15/packages/esp8266/hardware/esp8266/2.3.0/cores/esp8266/Arduino.h:27, from /home/chris/Arduino/ROSArduinoBridge/ROSArduinoBridge.ino:79: /home/chris/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/xtensa-lx106-elf/include/string.h:55:8: error: previous declaration of 'char* index(const char*, int)' char *_EXFUN(index,(const char *, int)); ^ /home/chris/Arduino/ROSArduinoBridge/ROSArduinoBridge.ino: In function 'void resetCommand()': ROSArduinoBridge:149: error: assignment of function 'char* index(const char*, int)' index = 0; ^ ROSArduinoBridge:149: error: cannot convert 'int' to 'char*(const char*, int)' in assignment /home/chris/Arduino/ROSArduinoBridge/ROSArduinoBridge.ino: In function 'void loop()': ROSArduinoBridge:295: error: invalid types 'char [16][char*(const char*, int)]' for array subscript if (arg == 1) argv1[index] = NULL; ^ ROSArduinoBridge:296: error: invalid types 'char [16][char*(const char*, int)]' for array subscript else if (arg == 2) argv2[index] = NULL; ^ ROSArduinoBridge:305: error: invalid types 'char [16][char*(const char*, int)]' for array subscript argv1[index] = NULL; ^ ROSArduinoBridge:307: error: assignment of function 'char* index(const char*, int)' index = 0; ^ ROSArduinoBridge:307: error: cannot convert 'int' to 'char*(const char*, int)' in assignment ROSArduinoBridge:318: error: invalid types 'char [16][char*(const char*, int)]' for array subscript argv1[index] = chr; ^ ROSArduinoBridge:319: error: ISO C++ forbids incrementing a pointer of type 'char* (*)(const char*, int)' [-fpermissive] index++; ^ ROSArduinoBridge:319: error: lvalue required as increment operand ROSArduinoBridge:322: error: invalid types 'char [16][char*(const char*, int)]' for array subscript argv2[index] = chr; ^ ROSArduinoBridge:323: error: ISO C++ forbids incrementing a pointer of type 'char* (*)(const char*, int)' [-fpermissive] index++; ^ ROSArduinoBridge:323: error: lvalue required as increment operand exit status 1 'int index' redeclared as different kind of symbol

commented

I know this is super late but I’ve only just got to using this code with my esp32. To fix those error messages you first need to rename ‘index’ ( I think that name is already defined somewhere? ). The other thing is to remove the ‘\0’ in the UPDATE PID case and replace it with 0 instead. This should now compile.

another weird thing I had with this board is that it did not like the switch case in it’s own function. After sending a char it executed the correct case then got forever stuck in another random case and looped indefinitely. The work around I found was to move the switch case out of the function and put it straight into the main loop.

I hope this helps someone who may try this code with esp32/8266 boards.