Comments (5)
Hi Ali,
The error is because in your code snipped, action
is a 3 dimensional array instead of an integer.
As documented here , when "discrete_actions"
is set to true (the default), the action space of the Carla-v0
environment is Discrete(9)
.
Therefore, you can simplify your pick action function something like below:
def pick_random_discrete_action(t, current_action):
# a = env.action_space.sample()
# return a
if t < 60:
return np.array(3) # Go forward
if t % 5 > 0:
return current_action
rn = random.randint(0,9)
return rn
To see what each discrete action means, please refer to the table here.
If you want to use the continuous action space, you can set the "discrete_actions": False
here:
and then provide a 2 dimensional action (example: np.array([0, 1]) ) to the env.step(...)
function. The definitions for the continuous action space is listed here.
Hope that helps.
from hands-on-intelligent-agents-with-openai-gym.
Thanks Praveen,
In fact, In my dataset, I have 3 dimensional control action in the form of [steer, gas, break]
. One quick hack may be change this part in carla-env.py
:
def step_env(self, action):
if self.config["discrete_actions"]:
action = DISCRETE_ACTIONS[int(action)]
assert len(action) == 3, "Invalid action {}".format(action)
throttle = float(np.clip(action[0], 0, 1))
brake = float(np.abs(np.clip(action[0], -1, 0)))
steer = float(np.clip(action[1], -1, 1))
reverse = False
hand_brake = False
where I changed assert len(action) == 2
to assert len(action) == 3
. It solves the problem, but it turns out this is not good for driving policy as it is pointless to accelerate while braking. In fact, as we already discussed, it is good idea to concatenate gas
and brake
into a single [-1 , 1]
, which indicates [-1 , 0)
for brake and (0, 1]
for gas. However, I do not know how can I modify the code or dataset to take into account this? Is there any way to resolve the issue without modifying or
re-collecting the dataset? In other words, is there any way to keep the size of the control action as 3?
from hands-on-intelligent-agents-with-openai-gym.
@AliBaheri : Sorry for the delay. I was just able to get to this.
You could use a 3 dimensional control action in this form [steer, gas, brake]
with the Carla Gym environment implementation.
In that case, you can use a modified step function in place of the the original step function in carla_env.py or for quick experiments, you can replace the following lines:
with
def step_env(self, action): # action: [ steer, gas, brake]
steer = float(np.clip(action[0], -1, 1))
throttle = float(np.clip(action[1], 0, 1))
brake = float(np.clip[action[2], 0, 1))
from hands-on-intelligent-agents-with-openai-gym.
@AliBaheri: Is your question answered?
from hands-on-intelligent-agents-with-openai-gym.
Author provided the solution. Reopen if you want to continue discussion.
from hands-on-intelligent-agents-with-openai-gym.
Related Issues (20)
- How to do inference for Carla after training on OpenAI gym using Ray? HOT 1
- Deep Q-learning on Carla Env HOT 11
- A2C agent doesn't act HOT 5
- Carla agent performance and training time HOT 4
- Have you tried to use DQN on the Carla environment? HOT 3
- wrapper for CARLA 0.9.x HOT 3
- Error connecting: (localhost:18872) failed to connect: [Errno 111] Connection refused, attempt 0 HOT 1
- Best episode reward didn't save HOT 6
- brew install boost-python --with-python3 does not work anymore HOT 2
- does carla_gym env work on windows? HOT 2
- ch7 error during reset HOT 3
- How to replace self._spec = lambda: None HOT 3
- ERROR: tcpserver 41826 : error writing message: Broken pipe HOT 8
- Continue to turn right when use non-discrete_actions HOT 5
- Change weather during the training HOT 2
- ModuleNotFoundError: No module named 'gym.envs.atari' still happening HOT 1
- TCP connection error in ch 7 HOT 3
- what is the version of all packages? HOT 1
- Sensors problem ch7
- input shape of carla-v0.ptm
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hands-on-intelligent-agents-with-openai-gym.