Make a serial connection using Arduino
Hello all,
I have to get some data from a Battery Management System (BMS), it uses serial communication which is made thanks to a USB cable and a USB to serial converter.
I didn't found any packages on the internet, and I am not experienced enough to create one by myself.
I was wondering how I could make this link ?
One of my ideas is to use an Arduino (UNO+USB host shield) in order to create an interface, but I don't know how to integrate an Arduino in ROS.
I also downloaded PySerial but I don't know how to use it for the moment...
Can somebody help me or give me other ideas please ?
Thanks, Juliette
- ROS Indigo on Virtual Box
- C++/Python
Asked by Juliette_ROS on 2019-10-04 07:26:31 UTC
Comments
Seeing your previous questions, it might be good if you could tell us something about your own skills: what languages are you comfortable in/with? Or which would you prefer?
Asked by gvdhoorn on 2019-10-04 07:56:28 UTC
@gvdhoorn : I have some bases in Python and C++
Asked by Juliette_ROS on 2019-10-04 08:07:51 UTC
Ok.
To not complicate things unnecessarily: I would suggest to avoid introducing yet another piece of technology (ie: the Arduino) and work with PySerial and your converter directly.
That is not something specific to ROS though, so I would suggest you try and find some decent PySerial tutorials, and then work on completing those. Then work on communicating with your BMS without ROS. So just a stand-alone script that is able to periodically print some value you can retrieve from your BMS over the serial port.
At that point you should be comfortable enough with both PySerial as well as your BMS, and only then would it start to make sense to look into wrapping this in a ROS node.
My suggestion would be, if you're new to all of this, to not mix multiple new things together, but take everything one step at a time.
Asked by gvdhoorn on 2019-10-04 08:18:25 UTC
@gvdhoorn Thank you very much for your answer, I am going to try using PySerial and then I will see for ROS.
Asked by Juliette_ROS on 2019-10-07 01:57:08 UTC
@gvdhoorn I downloaded PySerial on my virtual machine, and created a code reading and printing the battery values on Python IDLE on my Virtual machine. Now I would like to include this program into a ROS node, do you think that ther are things I need to know ?
Asked by Juliette_ROS on 2019-10-09 07:13:24 UTC
Have you already written a simple node that periodically publishes a
std_msgs/String
?Like the
Publisher
in this tutorial?Asked by gvdhoorn on 2019-10-09 07:25:47 UTC
@gvdhoorn Yes, and I think that I managed to do what I wanted ! Thank you very much for your help !!!
Asked by Juliette_ROS on 2019-10-10 02:46:07 UTC
If you haven't done so already, please use sensor_msgs/BatteryState to publish BMS state, not
std_msgs/String
or some other message fromstd_msgs
.Asked by gvdhoorn on 2019-10-10 02:47:15 UTC
Ok, but my BMS is sending a lot of informations so will it work ?
Asked by Juliette_ROS on 2019-10-11 02:53:53 UTC
It's fine to publish more information -- on different topics -- but by using standard messages you immediately become compatible with existing software.
That is a huge benefit of using a component based software engineering.
Using standardised messages is very important and I would recommend you do this as much as possible.
Any information not captured by standard messages would be something you could create a custom messages for.
Asked by gvdhoorn on 2019-10-11 03:29:32 UTC