lgsvl / simulator

A ROS/ROS2 Multi-robot Simulator for Autonomous Vehicles
Other
2.28k stars 780 forks source link

How to communicate with custom client using custom brigde plugin? #1950

Open umdreamer opened 2 years ago

umdreamer commented 2 years ago

I want to communicate simulator with my custom client (e.g. a client can send message to control ego vehcile and receive ego vehcile state messages) using custom bridge plugin. I found in #930 https://github.com/lgsvl/simulator/issues/930, they can use websocket to achieve this.

In the documentation https://www.svlsimulator.com/docs/plugins/bridge-plugins/, I only found how to write a custom bridge plugin in Simulator. But how I can communicate with this bridge in my custom client. Could give me some suggestion how to do? What should I do in the custom client? Thanks.

EricBoiseLGSVL commented 2 years ago

What do you mean custom client? A custom simulator build? What are you trying to accomplish?

umdreamer commented 2 years ago

What do you mean custom client? A custom simulator build? What are you trying to accomplish?

Our custom client is another program which is used to send and receive vehicle data. That is, I want to use this program to control the vehicle in the Simulator (which is built from source based on 2021.3) throgh custom bridge.

umdreamer commented 2 years ago

Hi @EricBoiseLGSVL ,

To explain more about my question. I view the Simulator as the server. And I want to send and receive data to/from the Simulator using a client written by Python API. In Python API, I can connect the bridge by ego.connect_bridge('127.0.0.1', 9090). And I can make sure the bridge is connected by checking the status of ego.bridge_connected.

Then after that, how can I get data from the ego sensors? For example, how can I receive images from ColorCameraSensor? and How can I receive data from CanBusSensor?

Thank you.

umdreamer commented 2 years ago

After read again the documentation, I finally understood that the communication between Simualtor and client is through ROS2 messages. After diving into a bit of the ROS, I worked out my problem. Now, I can send and receive messages to and from Simulator.

umdreamer commented 2 years ago

The documentation is https://www.svlsimulator.com/docs/tutorials/create-ros2-ad-stack/. It is helpful:)

After read again the documentation, I finally understood that the communication between Simualtor and client is through ROS2 messages. After diving into a bit of the ROS, I worked out my problem. Now, I can send and receive messages to and from Simulator.