ApolloAuto / apollo

An open autonomous driving platform
Apache License 2.0
24.79k stars 9.64k forks source link

Setting destination of apollo not from DreamView / How to create record file #14809

Closed Kim-mins closed 1 year ago

Kim-mins commented 1 year ago

System information

Questions:

HI I'm new to apollo and I followed the installation instructions and successfully ran the record file(of the tutorial!) I'm currently using bridge(from: https://github.com/guardstrikelab/carla_apollo_bridge) with apollo, and I got two questions on apollo

1. How can I set the destination for apollo? (other than via DreamView)

To the best of my knowledge, the only way I found for the destination setting is providing destination from DreamView, with Route Editing -> Add Point of interest. But I believe there is the way to provide the destination point via command line or some other way. Could you please tell me how I can set the destination?

2. How can I create record file?

I could know I can run a record file from the tutorial, but I wonder how can I create a record file. There seems a tab for recording on DreamView, but I don't know how to use it. Could you please help?

Kim-mins commented 1 year ago

What I've tried for the questions until now:

Destination setting -> Help Wanted

After the investigation, I got to know the way to set destination via websocket:

import json
from websocket import create_connection

ip = 'xxx.xxx.xxx.xxx'
port = 'yyyy'
url = "ws://" + ip + ":" + port + "/websocket"
msg = {
    "type": "SendRoutingRequest",
    "start": {
        "x": 92.36650848388672,
        "y": -36.36920928955078,
        "z": 0,
        "heading": -3.141588392532049,
    },
    "end": {"x": 92.82344955910465, "y": -38.1568439287467, "z": 0},
    "waypoint": "[]",
}
ws = create_connection(url)
ws.send(json.dumps(msg))
print(ws.recv())

However, there are no changes on Dreamview UI. In order to test if the connection is bad, I also made a request of changing a current map. The data I sent was:

msg = {"type": "HMIAction", "action": "CHANGE_MAP", "value": 'Carla Town01'}

and it worked properly. But I could not know why that routing request doesn't work!!

Creating record file -> RESOLVED

I could find the link on the cyber_recorder tutorial: https://github.com/ApolloAuto/apollo/blob/93f69712269da572206e021cc7419b21c6feb595/docs/04_CyberRT/CyberRT_Developer_Tools.md I tested and this works fine for me.

Kim-mins commented 1 year ago

I found the reason: starting point and heading should be same with the current location of ego vehicle.

Cyrus-k commented 1 year ago

Hi,Kim-mins, I also use the carla-apollo-bridge like u. I want to know whether you get the start point by using the cyber_monitor to get the ego vehicle pose. I also want to know how you get the heading. Thanks for your patience.

Kim-mins commented 1 year ago

Hi @Cyrus-k! Well, there could be some nice ways to do this, but actually I added an alert to print the current position and the heading of the start position, above this line. But maybe directly inserting the statement does not work, so I found another file by ctrl + shift + f (in visual studio code) with WS.requestRoute as a keyword, which contains a serialized version of the code above, with anonymized(?) variables and inserted alert statement there.

Cyrus-k commented 1 year ago

Thank you for your reply. Now I can get the exact point of the ego vehicle. And I still have a question. Could you tell me how to start the simulation without clicking on the 'setup' button? When I send routing request, the dreamview shows a red line just like I click on the dreamview. But if I want to move the car in Carla simulator, I have to turn on the sim control and the control module. Then the car in Apollo and the car in Carla cannnot move together, it looks like there's something wrong with sim control in the guardstrike bridge.(from: https://github.com/guardstrikelab/carla_apollo_bridge). Can you tell me how you start the simulation by using command line? Thank you very much again!

Kim-mins commented 1 year ago

@Cyrus-k Good news! I did not experienced your situation, but maybe you mean switching up every module of Apollo. You can refer to these two codes: https://github.com/lgsvl/PythonAPI/blob/a1d1524f684d48b3633d60e9d5e9b325932b84b0/lgsvl/dreamview/dreamview.py#L111 https://github.com/lgsvl/PythonAPI/blob/13c92096e7b0ba3c4ac9ad3ea5fee95b56efd234/examples/SampleTestCases/random-traffic.py#L92

I do have a question to you. Did you successfully run Apollo 8.0 on Carla? or just 7.0? If it is 8.0, could you please describe the way to run it with Carla to me?

Cyrus-k commented 1 year ago

Sorry, I just run Apollo 7.0 with Carla 0.9.13. I haven't tried this bridge with Apollo 8.0 till now.

Kim-mins commented 1 year ago

@Cyrus-k I see.. same situation.. thanks. Anyway, if you have any further question, please tell me. My experience can help you, I guess.

Cyrus-k commented 1 year ago

@Kim-mins Thanks for your helping. I do have a question for you. Do you mean that you write some codes like https://github.com/lgsvl/PythonAPI/blob/a1d1524f684d48b3633d60e9d5e9b325932b84b0/lgsvl/dreamview/dreamview.py so that you can run the whole simulation without any click on dreamview? I know I can set_destination but I am now puzzled of starting the co-simulation. Can you tell me your experience?

Kim-mins commented 1 year ago

@Cyrus-k What I understood was, you cannot enable modules automatically when you initialized apollo. In more detail, line 92 defines module names and line 113 pass those module names. Each module name eventually reaches here. So you can use websocket to enable each module as the code does. As an example, you can enable Routing module by sending the message below to the websocket:

{"type": "HMIAction", "action": "START_MODULE", "value": "Routing"}
Cyrus-k commented 1 year ago

Sorry, maybe I don't explain the question very well. But according to your description, It seems that if I set the modules right and set ego vehicle,destination and send routing request, then the co-simulation will start. But I read the instructions in guardstrike respository, after it sent the routing request, I have to click the 'setup' button. Is that true that when I set the modules, ego vehicle, destination and send the routing request, carla and apollo will work together and I will see the car moving in the dreamview?

Kim-mins commented 1 year ago

@Cyrus-k Yes I remember that I could run it without clicking the setup button.

fpeanut commented 1 year ago

@Kim-mins Hello, I also encountered similar problems after installing carla0.9.1 and apollo7. I just use the following steps:

  1. Open dreamview, carla and bridge
  2. I select the start point and end point on the dremview interface, send a routing request, and configure the corresponding modules (routing, planning, contorl) in the settings. Problem: The ego car will not drive, there is only one red planned route. But before I open the sim control, it will run, but the speed trajectory of the car on the dremview is different from that on the carla, and the carla always runs for a short period of time and then stops.
Kim-mins commented 1 year ago

Hi @fpeanut. I think we are on a bit different situations. What I understood on your situation is, the ego-vehicle does not move after sending the routing request on DreamView UI. But after following the instruction from carla-apollo bridge, I could successfully make the ego-vehicle drive via DreamView UI. Unlike your situation, my ego-vehicle did not move when I gave the starting/destination points via websocket this way, and I could resolve it by correcting the value for heading. Regardless of the difference on the situation, I've never experienced your situation.. sorry for no help.

cfs4819 commented 6 months ago

Hi @fpeanut. I think we are on a bit different situations. What I understood on your situation is, the ego-vehicle does not move after sending the routing request on DreamView UI. But after following the instruction from carla-apollo bridge, I could successfully make the ego-vehicle drive via DreamView UI. Unlike your situation, my ego-vehicle did not move when I gave the starting/destination points via websocket this way, and I could resolve it by correcting the value for heading. Regardless of the difference on the situation, I've never experienced your situation.. sorry for no help.

I just open a PR for carla_apollo_bridge, adding a feature to set destination by dreamview websocket. The heading can be caculated by heading = math.radians(-ego_vehilce.get_transform().rotation.yaw).