0
$\begingroup$

Rosanswers logo

Hello,

I'm trying to use rosserial with Teensy 3.5 through bluetooth.

My first step: change the serial port from Serial to Serial1.

I follow the thread: https://answers.ros.org/question/198247/how-to-change-the-serial-port-in-the-rosserial-lib-for-the-arduino-side/?answer=295159#post-id-295159

It compiles with Arduino Mega board but no with Teensy 3.5 (or other Teensy boards)


I use: Ubuntu 16.04, Kinetic ros, Arduino 1.8.5 The Hello World example code: http://wiki.ros.org/rosserial_arduino/Tutorials/Hello%20World


I tried to ways:

  1. Modify the line 73 in the code arduino.1.8.5/libraries/ros_lib/ArduinoHardware.h

iostream = &Serial1;

  1. Replace:

    ros::NodeHandle nh;

with:

class NewHardware : public ArduinoHardware
{
  public:
  NewHardware():ArduinoHardware(&Serial1, 57600){};
};
ros::NodeHandle_<NewHardware>  nh;

The error when I try to compile is:

.../arduino-1.8.5/libraries/ros_lib/ArduinoHardware.h:67:5: note:   no known conversion for argument 1 from 'HardwareSerial*' to 'usb_serial_class*'
no matching function for call to 'ArduinoHardware::ArduinoHardware(HardwareSerial*, int)'

ArduinoHardware.h: http://docs.ros.org/jade/api/rosserial_arduino/html/ArduinoHardware_8h_source.html


Originally posted by jordiguerrero on ROS Answers with karma: 16 on 2018-06-24

Post score: 0


Original comments

Comment by jayess on 2018-06-24:
What is your original problem (i.e., please update your question with a copy and paste of the error)? Why are you modifying the source code of a library? Can you please update your question with a copy and paste of of the code that you wrote?

Comment by gvdhoorn on 2018-06-25:
@jordiguerrero: please post your last edit as an answer, and then accept your own answer.

Comment by gvdhoorn on 2018-06-25:
Also: I don't see #define USE_TEENSY_HW_SERIAL in your last edit?

Comment by jordiguerrero on 2018-06-25:
Ok, I make the changes. Sorry about any inconvenient, it is my first post...

Comment by gvdhoorn on 2018-06-25:
No need to apologise. Just keep it in mind for next time.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

SOLVED: I forget to add the next include:

#define USE_USBCON

It was solved in the teensy forum, thank you to Theremingenieur user: https://forum.pjrc.com/threads/52928-rosserial-bluetooth-teensy-problem

The modified Hello World sample:

/*
 * rosserial Publisher Example
 * Prints "hello world!"
 */

// Use the following line if you have a Leonardo or MKR1000 
#define USE_USBCON


#include <ros.h>
#include <std_msgs/String.h>

//ros::NodeHandle nh;
class NewHardware : public ArduinoHardware
{
  public:
  NewHardware():ArduinoHardware(&Serial1, 57600){};
};
ros::NodeHandle_<NewHardware>  nh;

std_msgs::String str_msg;
ros::Publisher chatter("chatter", &str_msg);

char hello[13] = "hello world!";

void setup()
{
  nh.initNode();
  nh.advertise(chatter);
}

void loop()
{
  str_msg.data = hello;
  chatter.publish( &str_msg );
  nh.spinOnce();
  delay(1000);
}

Originally posted by jordiguerrero with karma: 16 on 2018-06-25

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.