0
$\begingroup$

Rosanswers logo

Hello everyone,

I am running ROS melodic on ubuntu 18.04 and I have encountered a problem for which I couldn't find any info , or I didn't know how to look for it (which could be possible! ) and I would like your help!

I have been using rosserial in the past with no issues at all. However, I have never tried using the serial communication on the arduino side, while it is plugged in the computer and the rosserial is running. When I did try yesterday to control a VESC through arduino's software serial library, if I do not send any commands to the vesc through UART all is fine and ros is happily connected to the arduino, but the moment I try to send a vesc command (no matter what command i try to send ) I get the following error on the terminal:

[INFO] [1603186275.781290]: Requesting topics... Requesting topics... [ERROR] [1603186290.784412]: Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino

The setup is as follows:

Laptop running ros -> arduino -> vesc

Joystick sends commands to the arduino over rosserial || the arduino sends the current value to the vesc (vesc being controlled in current mode )

The rosserial is communicating with the arduino at 56200 BAUD whereas the software serial ( I am using this library because of lack of serial ports ) is set to 19600 BAUD.

I can control the vesc with ppm control and rosserial but then I lose all the info I could get back from it using the UART, which is something I would rather not!

Here is a simple arduino code:

#include <Arduino.h>
#include <VescUart.h>
#include <SoftwareSerial.h>
#include <ros.h>
#include <geometry_msgs/Twist.h>

 // OBJECT INITIALIZATION
SoftwareSerial vesc1_serial(6, 7); // RX , TX
VescUart vesc1;
ros::NodeHandle nh; 
 
/////// PUBLISHERS /////////

geometry_msgs::Twist vel_recieved;
ros::Publisher velocity_pub("/report/vel_received", &vel_recieved);

void setup()
{
  // Serial.begin(19200);
  // vesc1_serial.begin(19200);

  nh.getHardware()->setBaud(57600);
  nh.initNode();
  nh.subscribe(control_sub);
  nh.advertise(velocity_pub);

  /** Define which ports to use as vesc1 */
  vesc1.setSerialPort(&vesc1_serial);
}

void loop()
{

  nh.spinOnce();

  vel_recieved.linear.x = 3;
  velocity_pub.publish(&vel_recieved);

  vesc1.setCurrent(current);

  vel_recieved.linear.x = 0;
  velocity_pub.publish(&vel_recieved);

  // drive_vesc();
  // get_vesc_values();

  delay(50);
}

The command that makes rosserial through the error is this one:

vesc1.setCurrent(current);

This is the library I use for vesc uart control. Important! It has to be the development branch because this allows controlling vescs over software serial.

Any idea as to what might be causing that? Any advice greatly appreciated!

Should you require any additional info, please let me know!


Originally posted by ekptwtos on ROS Answers with karma: 35 on 2020-10-20

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

The answer to this question unfortunately was not the one I was looking for.

The software serial library, even though it allows you to use whichever pins you want as software serial, it still uses the hardware serial, therefore microcontrollers that have only 1 hardware serial port can not be used for this application.

My solution was to buy a Feather M0 which has 1 hardware serial, but you can create more hardware serial ports through SERCOMs. Here is the relevant link for those who are interested.

IMPORTANT NOTE it took me some time before I could make the Feather communicate over its USB with rosserial. The reason behind this: to use samd21 native usb port you have to add

#define USE_USBCON

before including any ros libraries in the Feather code.

Hope this helps someone, and /or save some and frustration!

Best,

Mike


Originally posted by ekptwtos with karma: 35 on 2020-11-23

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by attaoveisi on 2021-01-04:
Hi, I am having exactly the same problem. I am trying to publish the GPS data from my mega2560 using rosserial and SIM808 module is using the SoftwareSerial. Can you show me exactly, how did you solve this?

I also noticed this from the documentation of SoftwareSerial: "The library has the following known limitations:

If using multiple software serial ports, only one can receive data at a time. "

but here I am trying to receive GPS data with SoftwareSerial and publish (tx) with rosserial. I am guessing that should be possible.

I also have stumbled upon this gem: https://titanwolf.org/Network/Articles/Article?AID=84ad92ad-f77b-4b23-bf5e-323aee0680ee#gsc.tab=0 which could be the answer.

$\endgroup$

Your Answer

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