How to specify port for topic?

asked 2021-04-13 17:50:08 -0500

elbrown47 gravatar image

TL;DR, How can I specify the port on which a topic will be started?

I am trying to use AWS Robomaker to run a Gazebo simulation and interact with it using rospy on the AWS Cloud9 IDE, but am facing some Networking issues. The Robomaker Simulation Job and the Cloud9 IDE are both hosted in EC2 instances (as far as I can tell) and are in a VPC to allow communication with each other. The Cloud9 IDE allows you to open all ports inside the VPC; however, the Simulation Job requires you to specify up to 10 ports to open prior to launching (link).

I have opened up port 11311 (default for ROS master) on the Simulation Job, and have set the ROS_MASTER_URI in the Cloud9 IDE to point at the Simulation Job's IP within the VPC. I can successfully connect to the Simulation Job's master from Cloud9 and view the list of topics via rostopic list and nodes via rosnode list.

Where I am facing issues is in communicating along the topics, because the ports are dynamically allocated at runtime from within the Simulation Job (and I cannot open ports after starting the job). For example: on the Cloud9 IDE, rosnode list shows the \gazebo node, but rosnode ping /gazebo's connection is refused because the random port it is assigned to has not been opened on the Simulator Job.

How can I specify the port that a topic (e.g, gazebo) will use before it is dynamically assigned within the Simulator Job?

edit retag flag offensive close merge delete

Comments

How can I specify the port that a topic (e.g, gazebo) will use [..]

Short answer: if you're using vanilla ROS, you can't.

Some previous Q&As about this topic: #q245273 and #q268213, and a very old one: #q12206.

before it is dynamically assigned within the Simulator Job?

I'm not up-to-date on whether AWS has changed anything specifically for making things work in their systems.

gvdhoorn gravatar image gvdhoorn  ( 2021-04-14 02:34:12 -0500 )edit