ros-drivers / rosserial

A ROS client library for small, embedded devices, such as Arduino. See: http://wiki.ros.org/rosserial
517 stars 525 forks source link

Teensy 4.0 Support #455

Closed shakeebbb closed 4 years ago

shakeebbb commented 4 years ago

Teensy now have 4.0 board and compiling the HelloWorld (or compiling any code that includes ros.h) is giving the error

error: cannot convert 'usb_serial_class' to 'HardwareSerial' in assignment iostream = &Serial; ^ Multiple libraries were found for "ros.h"

Following an older thread (https://github.com/ros-drivers/rosserial/issues/259), I fixed it by modifying the line

if defined(MK20DX128) || defined(MK20DX256) || defined(MK64FX512) || defined(MK66FX1M0) || defined(MKL26Z64)

to

if defined(MK20DX128) || defined(MK20DX256) || defined(MK64FX512) || defined(MK66FX1M0) || defined(MKL26Z64) || defined(IMXRT1062).

Is this the right solution to the issue? Can Teensy 4.0 support be included in rosserial?

romainreignier commented 4 years ago

Yes, this seems like the correct way to do it. You should open a Pull Request. Thanks

shakeebbb commented 4 years ago

Great, thanks! Pull requested

mikepurvis commented 4 years ago

Sorry for the delay on this, but it should now be fixed in noetic-devel and will also be patched onto melodic-devel and released for Melodic in coming weeks.

dr-parker commented 4 years ago

@mikepurvis Didn't want to re-open this ticket, but I was checking melodic-devel and didn't see an update? I've been installing from the package manager (running melodic), but wasn't sure if the patch had been made or released for melodic. Is there an update?

fjp commented 3 years ago

On ROS noetic, I am trying to compile a script for the Teensy 4.0 that works on Teensy 3.2. Compiling for 4.0 gives me a similar error as described above:

In file included from /home/fjp/Arduino/libraries/Rosserial_Arduino_Library/src/ros.h:39:0,
                 from /home/fjp/git/diffbot/diffbot_base/scripts/encoders/encoders/encoders.ino:12:
/home/fjp/Arduino/libraries/Rosserial_Arduino_Library/src/ArduinoHardware.h: In constructor 'ArduinoHardware::ArduinoHardware()':
/home/fjp/Arduino/libraries/Rosserial_Arduino_Library/src/ArduinoHardware.h:54:16: error: cannot convert 'usb_serial_class*' to 'HardwareSerial*' in assignment
       iostream = &Serial;
                ^
Error compiling for board Teensy 4.0.

I have checked for updates in the Arduino IDE and ubuntu ros packages but it seems that I have the latest Arduino rosserial 0.7.9 installed and all ubuntu packages are up to date. Anything else that I need to take care of?

I am not using the ubuntu Arduino IDE because it is not possible to install the Teensyduino addon to it. Instead I had to download the Arduino IDE separately.

marcomasa commented 3 years ago

It may seem kind of obvious, but for everyone who doesn't get it right bc you simply copy paste:

Line 44 in ArduinoHardware.h should be:

#if defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__MKL26Z64__) || defined (__IMXRT1062__)

@shakeebbb, your comment was missing the underscores bc you didn't mark the lines as code in your comment. Thanks for the solution anyways!