ROS Driver problems and modifications

General discussion of using Roboclaw motor controllers
jasmin92
Posts: 4
Joined: Tue Aug 23, 2016 2:04 am
ROS Driver problems and modifications

Post by jasmin92 »

I'm using packet serial mode via USB wired to my PC directly with no USB to TTL board, I saw somewhere in the forum that this is possible. But I'm having some issues in serial communication the roboclaw takes too long to receive the commands and execute them so slowly and discontinuously. Am I obliged to wire S1 and S2 pins to a ttl board and then to my computer instead of using a simple USB communication?
When using the ion motion software there is nothing wrong but these problems occur when using my ROS node.
Is it possible that some parameters are not set correctly causing this synchronization problem?
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Roboclaw takes too long to execute movement commands / packet serial over USB

Post by Basicmicro Support »

Since we didnt write the ROS lirbary(it was provided free by an end user that uses it in his own projects) I dont know too much about the guts of it. However I'll do what I can.

First make sure you have the latest firmware. Also please describe in detail what you are doing in ROS that accesses the roboclaw(eg what commands and how often). Are you using any error handling code that may be in the ROS library?
jasmin92
Posts: 4
Joined: Tue Aug 23, 2016 2:04 am
Re: Roboclaw takes too long to execute movement commands / packet serial over USB

Post by jasmin92 »

The code I'm using is a simple python code where the roboclaw commands are included, for instance I'm using movement and speed commands such as 0,1, 37... I'm pretty sure that there is nothing wrong with the ros-roboclaw communication , the commands are received but there is always a lag when executing them.

the driver I'm using keep telling me that there is a problem with serial communication. I would be greatfull if you explain to me the correct way to wire the roboclaw with my PC in order to use the packet serial mode with no problems.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Roboclaw takes too long to execute movement commands / packet serial over USB

Post by Basicmicro Support »

Please be more specific about the "driver is telling me there is a problem".

If the roboclaw is communicating(even just some times) you probably have it wired correctly. S1 is the receive pin and S2 is the transmit pin. The roboclaw requires TTL serial signals(0 to 5v max). If oyu are connected to a PC make sure you are using a TTL converter(eg max232). Make sure you have the latest firmware installed in the roboclaw. Check different baudrates to see if the problem is specific to a particular baudrate.
gdoisy
Posts: 33
Joined: Tue Oct 18, 2016 7:53 am
Re: Roboclaw takes too long to execute movement commands / packet serial over USB

Post by gdoisy »

I am having similar issues with a roboclaw 30A x2 (last firmware) and the ROS driver (that i had to patch according to this topic to get odometry feedback https://github.com/sonyccd/roboclaw_ros/issues/3)
I have random delays up to few seconds both in commanding the motors and receving odometry feedback.
Tested with the direct usb mode and with the packet serial mode through a usb to serial adapter, same results.
jasmin92, did you solve your problem?
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Roboclaw takes too long to execute movement commands / packet serial over USB

Post by Basicmicro Support »

Is there any communications problems when testing with the IonMotion application?

If not then the problem is most likely in the ROS driver. As I said in a earlier post in this thread we did not write that driver so Im not sure what could be happening.

Note, if the Roboclaw does not reply in several milliseconds it is not going to reply. If you are seeing seconds of delay the problem is somewhere else(eg in the ROS library logic most likely). We do not currently have a setup to run ROS. Its in our todo but its still several projects away. Until then if you can add some debugging code(log to a file) I may be able to figure out the problem.

It looks like ROS has loggin functions built in. Here is the link: http://wiki.ros.org/roscpp/Overview/Logging

Add this in each command in the ROS driver so we can see what commands are executing and when. Send me your modified ROS driver and the log when you have generated one and I'll look it over to see if I can find the problem.
gdoisy
Posts: 33
Joined: Tue Oct 18, 2016 7:53 am
Re: Roboclaw takes too long to execute movement commands / packet serial over USB

Post by gdoisy »

Hi,
Thanks for your answer.
No communications issue with the Ion Motion software. I assumed the ROS driver was working well but it is very buggy. The problem was that the encoder values could not be read while sending motors commands (both were trying to communicate in the same time).
I am going to rewrite part of the driver to solve the issues, to make it more robust and to expose the motors current values. I am also planning to implement some kind of watchdog for connection breaks as suggested here http://forums.ionmc.com/viewtopic.php?t=212
I will report my results here.
gdoisy
Posts: 33
Joined: Tue Oct 18, 2016 7:53 am
Re: Roboclaw takes too long to execute movement commands / packet serial over USB

Post by gdoisy »

Forked here: https://github.com/doisyg/roboclaw_ros
for now, just corrected the com issues and increased loop to 30hz
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Roboclaw takes too long to execute movement commands / packet serial over USB

Post by Basicmicro Support »

Thanks for the post and the link. Im assuming htere were two threads in ROS trying to read/write to the serial port at the same time? Or some kind of overlapped serial was being used?
gdoisy
Posts: 33
Joined: Tue Oct 18, 2016 7:53 am
Re: Roboclaw takes too long to execute movement commands / packet serial over USB

Post by gdoisy »

Precisely, two threads were trying to read/write to the serial port at the same time. Still need to check in depth the robustness of the com implementation. I am new in python, and while when using C++ with ROS, callbacks are handling thread conflict, it has to be done manually in python.

I have made the following changes to the ROS drivers already, but github is down so i will push them on monday:

Added thread usage for simultaneous odom and command
Watchdog hack using SpeedDistanceM1M2 function
Inverted l/r motor command
Added Currents feedback on rosdebug

Post Reply