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

How to configure tcp server

asked 2022-09-20 06:45:37 -0500

praveen_khm gravatar image

Hi,

I have built a robot with ESP32 module communicating over WiFi to control the robot. The robot is working well and I am able to send cmd_vel from pc to robot and it seems to be driving well.

const char* ssid = "my_ssid";
const char* password = "my_pwd";
IPAddress server(192, 168, 0, 110); // ip of ROS server
client.connect(server, 11411);

How do I make it truly mobile where in I go to a different location, another WiFi and still able to connect to this robot without reprogramming the robot with ssid and password?

Secondly, once I rebooted, the IP address of my PC changed (on VM). I understand that I can use ROS_MASTER to configure server, but some servers have 192.168.0.xxx while others have 192.168.1.xxx.

Lastly, "11411" port, is this universal that I can keep it stored always on the robot controller, or will that also change if I install ROS on a different system?

Thank you for any support provided. -Praveen

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2022-09-20 21:14:51 -0500

tomarRobin gravatar image

updated 2022-09-21 01:42:57 -0500

Hello praveen, If I understand you correctly you want to be able to communicate with your robot without changing the network settings of your robot. The only thing which is required here is a common network on which you and your robot both can connect. I need a few more details here to help you

  1. Does your robot has an onboard PC on which you can run ros master?
  2. Are you using your PC as ROS master and only sending velocity commands to robot with esp node?

Edit 1

If they are on same network then only problem we have is to make sure server takes up same ip every time. This can be done by allocating a static ip to your PC in network settings and then telling rosmaster to pick that ip every time. Taking a static ip on network is easy part for making rosmaster to take a particular ip. You’ll need to write these lines in your pc’s ~/.bashrc file

export ROS_MASTER_URI=http://pc_ip:11311 export ROS_IP=pc_ip export ROS_HOSTNAME=pc_ip Then source the bashrc and run code from that terminal

edit flag offensive delete link more

Comments

Hi,

Thank you for the response.

That is exactly what I want to do. Make sure the robot communicates with pc irrespective of change of ip on pc. I have a way to configure the said and password of esp32 and so it will be a common network. But ipaddress of server is kind of bothering.

  1. Yes, it has an esp32 onboard. It does not have Ros, but connects via wifi as a Ros node.
  2. Yes. PC is used to send velocity commands and receive encoded counts from esp node.
praveen_khm gravatar image praveen_khm  ( 2022-09-21 00:22:53 -0500 )edit

Try the steps in edited answer. And make sure to replace the pc_ip with actual static ip of your pc

tomarRobin gravatar image tomarRobin  ( 2022-09-21 01:44:14 -0500 )edit

Well, this is where the problem starts. The PC or laptop will not be on the same network always. If I go to a different location, the ip address changes. I can feed that ip to master, but not on the robot. On the robot, I can feed ssid and password remotely, but not the IPAddress server. Is there a way I can make IPAddress server static on robot such that it connects to master irrespective of network? Just a small misunderstanding I had; same I meant common across both network robot and pc; but the actual network can be either my home of office network.

praveen_khm gravatar image praveen_khm  ( 2022-09-21 01:45:53 -0500 )edit

I will try to explain it more clearly.

Suppose I am at home where the IP address is http://192.168.0.100:11311 with ssid1 and password1. I will feed ssid1 and password1 on robot and laptop. Now when I go to office, the IP address on the laptop will be http://192.168.1.105:11311 with ssid2 and password2. I will still be able to feed the robot and laptop with ssid and password credentials. However, I need the robot to get ipaddress of server directly.

Say for example, I feed an alias as "http://10.10.10.1" ( or Hostname) on the PC irrespective of any network it connects to. Now the robot should always connect to this IPaddress which is the master so that I dont have to change it / or program it everytime.

If I follow this advice:

export >ROS_MASTER_URI=http://pc_ip:11311 
export ...
(more)
praveen_khm gravatar image praveen_khm  ( 2022-09-21 01:56:47 -0500 )edit

Firstly, You can only run the rosmaster on an IP if that ip is actually used by your system , if you have a static ip of 192.168.1.xx and you try to set rosmaster ip to be 192.168.1.yy then server will not start. Secondly, there is no way for esp to know on which ip in this current network is my rosmaster running so the only way to keep communicating is to have same static ip on any network. Is there any problem in having same static ip in a different network?

tomarRobin gravatar image tomarRobin  ( 2022-09-21 03:11:32 -0500 )edit

I have no control over outside network. This simply means that if I go to any location, I should be able to connect to a wifi network there and make the robot work.

https://answers.ros.org/question/2287...

This posts kind of answers the requirement. The OP there has a similar requirement, but I am not sure how it is solved.

praveen_khm gravatar image praveen_khm  ( 2022-09-21 04:10:01 -0500 )edit

As much as i could understand from the answer you pointed, Since you have no control over the network as you mentioned, that solution will not work for you as well because that would require you to configure the DNS server of the network and tell it that anyone trying to look for name “xyz” should be directed to my pc ip. Where xyz could be your ros master hostname.

tomarRobin gravatar image tomarRobin  ( 2022-09-21 08:59:27 -0500 )edit

Can you please point me in how to configure dns? If that is a possibility, i will try to configure the dns, if it's a one time job.

praveen_khm gravatar image praveen_khm  ( 2022-09-21 10:05:45 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2022-09-20 06:45:37 -0500

Seen: 169 times

Last updated: Sep 21 '22