Make a serial connection using Arduino

asked 2019-10-04 07:26:31 -0500

Juliette_ROS gravatar image

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
edit retag flag offensive close merge delete

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?

gvdhoorn gravatar image gvdhoorn  ( 2019-10-04 07:56:28 -0500 )edit

@gvdhoorn : I have some bases in Python and C++

Juliette_ROS gravatar image Juliette_ROS  ( 2019-10-04 08:07:51 -0500 )edit

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 gravatar image gvdhoorn  ( 2019-10-04 08:18:25 -0500 )edit

@gvdhoorn Thank you very much for your answer, I am going to try using PySerial and then I will see for ROS.

Juliette_ROS gravatar image Juliette_ROS  ( 2019-10-07 01:57:08 -0500 )edit

@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 ?

Juliette_ROS gravatar image Juliette_ROS  ( 2019-10-09 07:13:24 -0500 )edit

Have you already written a simple node that periodically publishes a std_msgs/String?

Like the Publisher in this tutorial?

gvdhoorn gravatar image gvdhoorn  ( 2019-10-09 07:25:47 -0500 )edit

@gvdhoorn Yes, and I think that I managed to do what I wanted ! Thank you very much for your help !!!

Juliette_ROS gravatar image Juliette_ROS  ( 2019-10-10 02:46:07 -0500 )edit

If you haven't done so already, please use sensor_msgs/BatteryState to publish BMS state, not std_msgs/String or some other message from std_msgs.

gvdhoorn gravatar image gvdhoorn  ( 2019-10-10 02:47:15 -0500 )edit