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
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?
@gvdhoorn : I have some bases in Python and C++
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.
@gvdhoorn Thank you very much for your answer, I am going to try using PySerial and then I will see for ROS.
@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 ?
Have you already written a simple node that periodically publishes a
std_msgs/String
?Like the
Publisher
in this tutorial?@gvdhoorn Yes, and I think that I managed to do what I wanted ! Thank you very much for your help !!!
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
.