Closed AliBaheri closed 5 years ago
With "scenarios": [scenario_config["Curve_Poses_Town2"]]
what error do you get?
Yes. That's right. changing x_res
and y_res
will change the observation size. With the configuration you listed above, you will get an observation of shape 64x64x3
which is one frame of the environment. If you set "framestack": 2
, you will get an observation of shape 64x64x6
which is two frames stacked along the channels.
What do you mean by "meaningless images"? If you are trying to visualize the image, be sure to use the correct channel order (BGR vs RGB).
You can display the observations using the following lines of code:
import cv2
# Assuming obs is the observation returned by the env
cv2.imshow("obs", obs)
cv2.waitKey(0)
With "scenarios": [scenario_config["Curve_Poses_Town2"]]
I get the following error:
Clearing Carla server state ERROR:Initializing new Carla server... Error during reset: Traceback (most recent call last): File "carla_env.py", line 223, in reset return self.reset_env() File "carla_env.py", line 247, in reset_env assert self.scenario["city"] == self.city, (self.scenario, self.city) TypeError: list indices must be integers, not str
Are you able to run with other scenarios?
What do you mean by "meaningless images"? If you are trying to visualize the image, be sure to use the correct channel order (BGR vs RGB). You can display the observations using the following lines of code:
import cv2 # Assuming obs is the observation returned by the env cv2.imshow("obs", obs) cv2.waitKey(0)
I will get something like this image:
Which is not clearly the road image. Are you able to get actual road image from that code snippet?
With "scenarios": [scenario_config["Curve_Poses_Town2"]] I get the following error: Clearing Carla server state ERROR:Initializing new Carla server... Error during reset: Traceback (most recent call last): File "carla_env.py", line 223, in reset return self.reset_env() File "carla_env.py", line 247, in reset_env assert self.scenario["city"] == self.city, (self.scenario, self.city) TypeError: list indices must be integers, not str
It is because you are using "Curve_Poses_Town2"
which is defined to be:
https://github.com/PacktPublishing/Hands-On-Intelligent-Agents-with-OpenAI-Gym/blob/df9ab3984237b3a02998e2c3d3df482f557945f9/ch8/environment/carla_gym/envs/scenarios.json#L75-L81
You should probably change the key name in your code.
If you want to create a scenario in Town2 where the vehicle is driving along some curves, you can add the following to scenarios.json:
"Curve1_Town2": {
"city": "Town02",
"start_pos_id": 8,
"end_pos_id": 24,
"num_vehicles": 25,
"num_pedestrians": 30,
"weather_distribution": [0],
"max_steps": 200
},
And then change this line: https://github.com/PacktPublishing/Hands-On-Intelligent-Agents-with-OpenAI-Gym/blob/df9ab3984237b3a02998e2c3d3df482f557945f9/ch8/environment/carla_gym/envs/carla_env.py#L75
to
"scenarios": [scenario_config["Curve1_Town2"]],
I have also add this explanation to the wiki here for future references.
Author provided the solution. Reopen if you want to continue discussion.
I have two questions about
carla_env.py
:1 - I am interested to try other senarios such as turn or navigation. However when I change the following part:
to:
I face with the error. I have also changed the scenario in the
json
file to the following:2- If I wanted to save the observations in, for example,
64x64x3
should I modify thecarla_env.py
to the following:Particularity, dose the meaning of frame-stack is the same as RGB channel?
I am asking this question because when I gather some observations in
numpy
and convert them to RGB image, I get some meaningless images, which are not the images from the road.