Ask Your Question
0

rosserial: node_handle hardware.read()

asked 2019-03-05 09:47:36 -0500

gab27 gravatar image

updated 2019-03-05 10:18:27 -0500

gvdhoorn gravatar image

Hi What does this line of code do (from here):

int data = hardware_.read();

thx

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-03-05 10:17:45 -0500

gvdhoorn gravatar image

updated 2019-03-05 10:53:18 -0500

It reads (bytes) from whatever is currently templated as being the "hardware" that rosserial uses for communication with the (ROS) host. It's a member variable of which the type depends on the Hardware template argument.

To make it more concrete: if the NodeHandle is specialised for an Arduino, it'll probably use the (first) serial port to read from / write to. If it were an embedded device that has an ethernet port, it'd probably be a TCP or UDP socket file handle. Etc, etc.


Edit:

So is this statement correct? The "hardware" is the Arduino?

Well, to be precise: hardware actually points to whatever the underlying platform uses to transmit and receive bytes. For Arduinos, that's typically:

  • hardware RS232
  • software RS232 (some pins)
  • Serial-over-USB

See rosserial_arduino/src/ros_lib/ArduinoHardware.h for the Arduino "serial type" class and rosserial_arduino/src/ros_lib/ros.h for the Arduino specialisation of the rosserial template (note that it could use the serial and the TcpHardware types).


Edit 2:

And for example the uint32_t ms = hardware_.time(); function reads the clock from the Arduino and not from the host?

It's defined here, as a member of ArduinoHardware and calls millis(), so it would seem so, yes.

edit flag offensive delete link more

Comments

Thanks for this nice answer. So is this statement correct? The "hardware" is the Arduino?

gab27 gravatar imagegab27 ( 2019-03-05 10:31:49 -0500 )edit

Thanks again. And for example the uint32_t ms = hardware_.time(); function reads the clock from the Arduino and not from the host?

gab27 gravatar imagegab27 ( 2019-03-05 10:50:17 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2019-03-05 09:47:36 -0500

Seen: 28 times

Last updated: Mar 05