ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ESP32 + rosserial_python over WiFi: Lost sync with device

asked 2019-08-07 10:22:20 -0500

sachin0x18 gravatar image

Hi,

I am trying to establish rosserial communication between ESP32 (using ESP-IDF and not Arduino framework) and host Ubuntu machine. Here is my implementation: https://github.com/sachin0x18/rosseri...

I am using ROS Kinetic and Ubuntu 16.04. rosserial_python version is 0.7.7 (as per package.xml).

I can establish communication over UART using rosrun rosserial_python serial_node.py and it can recognise publisher and subscriber topics.

When I establish communication over WiFi socket using rosrun rosserial_python serial_node.py tcp, rosserial_python on my Ubuntu machine can establish a connection and recognise the publisher and subscriber topics but after 15 seconds, it spits out Lost sync with device, restarting... and the same thing happens in a loop

[INFO] [1565188371.809821]: ROS Serial Python Node
Fork_server is:  False
[INFO] [1565188371.814939]: Waiting for socket connections on port 11411
waiting for socket connection
[INFO] [1565188380.808154]: Established a socket connection from 10.0.0.137 on port 49464
[INFO] [1565188380.809062]: calling startSerialClient
[INFO] [1565188382.986998]: Note: publish buffer size is 1024 bytes
[INFO] [1565188382.989866]: Setup publisher on chatter [std_msgs/String]
[ERROR] [1565188397.960632]: Lost sync with device, restarting...
[INFO] [1565188398.027021]: Setup publisher on chatter [std_msgs/String]
[ERROR] [1565188413.012285]: Lost sync with device, restarting...
[INFO] [1565188413.073520]: Setup publisher on chatter [std_msgs/String]

I am calling nh.spinOnce()every 1 second so it shouldn't be a problem of time sync failure. https://github.com/sachin0x18/rosseri...

For debug purpose, I have dumped the bytes that I receive and bytes that I transmit

I (3645) event: sta ip: 10.0.0.137, mask: 255.255.254.0, gw: 10.0.0.1                                          
I (3645) wifi station: got ip:10.0.0.137
I (3645) wifi station: Connected to AP
I (3735) wifi station: Successfully connected
Received at read: 0xff
Received at read: 0xfe
Received at read: 0x0
Received at read: 0x0
Received at read: 0xff
Received at read: 0x0
Received at read: 0x0
Received at read: 0xff
I (5955) rosserial: Sending message over ROS 16
I (5965) Sent buffer: ff fe 08 00 f7 0a 00 00  00 00 00 00 00 00 00 f5     |................|
I (5965) rosserial: Sending message over ROS 80
I (5975) Sent buffer: ff fe 48 00 b7 00 00 7d  00 07 00 00 00 63 68 61     |..H....}.....cha|
I (5985) Sent buffer: 74 74 65 72 0f 00 00 00  73 74 64 5f 6d 73 67 73     |tter....std_msgs|
I (5995) Sent buffer: 2f 53 74 72 69 6e 67 20  00 00 00 39 39 32 63 65     |/String ...992ce|
I (6005) Sent buffer: 38 61 31 36 38 37 63 65  63 38 63 38 62 64 38 38    |8a1687cec8c8bd88|
I (6015) Sent buffer: 33 65 63 37 33 63 61 34  31 64 31 00 04 00 00 21     |3ec73ca41d1....!|
I (7025) rosserial: Sending message over ROS 24
I (7025) Sent buffer: ff fe 10 00 ef 7d 00 0c  00 00 00 68 65 6c 6c 6f       |.....}.....hello ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-12-08 02:50:11 -0500

getsense gravatar image

the ROS message "Lost sync with device, restarting..." because of socket read in blocked mode take a look https://github.com/getsense1/rosseria... in file esp-idf/components/rosserial_esp32/ros_lib/tcp_client.c function unsigned char _conn_ros(void) has call fcntl(sock,F_SETFL,O_NONBLOCK); it's set the socket async mode and look at file esp-idf/components/rosserial_esp32/ros_lib/ESP32Hardware.h that has functions: int read() void write(uint8_t* data, int len) used async mode

try it

edit flag offensive delete link more

Comments

Setting the socket to async mode worked! Thanks !

Since it is non-blocking, it returns with errno 11: EAGAIN continuously (which I ignore) but it works. Was wondering if rosserial actually requires async read calls or is this just a hacky way to get it working ? Can it be made blocking with SO_RCVTIMEO ?

sachin0x18 gravatar image sachin0x18  ( 2019-12-25 00:49:40 -0500 )edit

i think roserial requires async read! Look at ros/node_handle.h(rosserial lib), the function spinOnce() ... hardware_.read() and then the ROS node on PC waiting and rosserial lib on device waiting, we have lost time sync's

getsense gravatar image getsense  ( 2019-12-25 10:18:38 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-08-07 10:22:20 -0500

Seen: 1,971 times

Last updated: Aug 07 '19