ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

rosserial Teensy bluetooth problem

asked 2018-06-24 06:52:20 -0500

jordiguerrero gravatar image

updated 2018-06-25 06:08:52 -0500

gvdhoorn gravatar image

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/1982...

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...


I tried to ways:

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

    iostream = &Serial1;

  2. 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/rosseria...

edit retag flag offensive close merge delete

Comments

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?

jayess gravatar image jayess  ( 2018-06-24 11:11:57 -0500 )edit

@jordiguerrero: please post your last edit as an answer, and then accept your own answer.

gvdhoorn gravatar image gvdhoorn  ( 2018-06-25 05:48:59 -0500 )edit

Also: I don't see #define USE_TEENSY_HW_SERIAL in your last edit?

gvdhoorn gravatar image gvdhoorn  ( 2018-06-25 05:49:55 -0500 )edit

Ok, I make the changes. Sorry about any inconvenient, it is my first post...

jordiguerrero gravatar image jordiguerrero  ( 2018-06-25 05:55:26 -0500 )edit

No need to apologise. Just keep it in mind for next time.

gvdhoorn gravatar image gvdhoorn  ( 2018-06-25 06:08:38 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-06-25 05:53:33 -0500

jordiguerrero gravatar image

updated 2018-06-25 05:58:16 -0500

gvdhoorn gravatar image

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-...

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);
}
edit flag offensive delete link more

Question Tools

Stats

Asked: 2018-06-24 06:52:20 -0500

Seen: 319 times

Last updated: Jun 25 '18