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

How to transmit data to specific TCP port?

asked 2018-07-23 06:46:38 -0600

KARIM gravatar image

updated 2018-07-23 13:50:59 -0600

gvdhoorn gravatar image

Dear altruist, I am trying to send some data on this settings

#define SERVER_IP       "192.168.1.121"
#define SERVER_PORT     5000
#define TCP_DATA_LEN    256

this is on a WiFi board(ESP32) which is directly controlling some actions. Is there any simple demo example of such application Regards


Edit: Hello gvdhoorn, thanks for your querry. I have setup the server with the card. So if I now send

> echo "3" | nc 192.168.0.102 3000

I get response to that.
So to implement in ROS, I need to send a value to IP address: 192.168.0.102 and Port: 3000

How can I achieve that easily, if my computer is connected to this server by LAN connection.

Regards Muntahi

edit retag flag offensive close merge delete

Comments

2

Can you clarify how this is related to ROS? This board is rather focused on ROS-specific topics, and general programming of embedded boards (such as an ESP32) does not fall into that category.

gvdhoorn gravatar image gvdhoorn  ( 2018-07-23 07:25:14 -0600 )edit
1

re: edit: so you are trying to write a ROS node that sends that 3 to the IP?

If so: I don't believe there is anything that ROS adds or changes here. I would advise you to look up some plain C++ examples of what you are trying to achieve, make sure you understand those and then add ROS.

gvdhoorn gravatar image gvdhoorn  ( 2018-07-23 14:01:01 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-07-23 16:23:42 -0600

lucasw gravatar image

https://github.com/abhinavjain241/com... looks like it was aiming to be a generic TCP/IP ros node- it or one of its forks could be a good starting point for a lot of these questions (like #q219872). It sends strings received by the client node and the server node publishes out any string it receives.

For talking to netcat I couldn't get a netcat client to talk to a comm_tcp server, but the other way around worked:

netcat -l 4444
rosrun comm_tcp client_node 127.0.0.1 4444
rostopic pub /client_messages std_msgs/String "data: 'foo'"

It puts the incoming String in a buffer and sends it repeatedly, but that is easy to fix.

Dynamic reconfigure for ports and server ip address and for connecting and disconnecting would be useful. Adding UDP and most anything else netcat can do would be good also.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-07-23 06:46:38 -0600

Seen: 1,629 times

Last updated: Jul 23 '18