Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Robot stuck/ slow when training #56

Open
Qtsho opened this issue Apr 23, 2021 · 4 comments
Open

Robot stuck/ slow when training #56

Qtsho opened this issue Apr 23, 2021 · 4 comments

Comments

@Qtsho
Copy link

Qtsho commented Apr 23, 2021

Hi,
Thanks so much for the repos,

I have a problem that when the memory is >64, then the script start to train the NN model. This makes the robot use the last cmd_vel it was told. The cmd_vel only be updated when the NN is trained and after one step ().

How can I parallel this work?

I am using stage 4 and GPU for running the script.

Thanks

@ROBOTIS-Will
Copy link

Hi @Qtsho
Thank you for your inquiry.
Could you give us more information about your environment and the version of ROS you are running?

@Qtsho Qtsho closed this as completed Apr 26, 2021
@Qtsho
Copy link
Author

Qtsho commented Apr 26, 2021

Hi,

I am using ROS1 melodic on Ubuntu 18.04.

tensorflow 2

I put some debuging line in the code and see it stucks for a long time between the for loop looping through the batch:

Line 114 file turtlebot3_dqn_stage_4.py

`

      for i in range(self.batch_size):

        states = mini_batch[i][0]
        actions = mini_batch[i][1]
        rewards = mini_batch[i][2]
        next_states = mini_batch[i][3]
        dones = mini_batch[i][4]

        q_value = self.model.predict(states.reshape(1, len(states)))
        self.q_value = q_value

        if target:
            next_target = self.target_model.predict(next_states.reshape(1, len(next_states)))

        else:
            next_target = self.model.predict(next_states.reshape(1, len(next_states)))

        next_q_value = self.getQvalue(rewards, next_target, dones)

        X_batch = np.append(X_batch, np.array([states.copy()]), axis=0)
        Y_sample = q_value.copy()

        Y_sample[0][actions] = next_q_value
        Y_batch = np.append(Y_batch, np.array([Y_sample[0]]), axis=0)

        if dones:
            X_batch = np.append(X_batch, np.array([next_states.copy()]), axis=0)
            Y_batch = np.append(Y_batch, np.array([[rewards] * self.action_size]), axis=0)

`

This causes the robot stuck for a while a use the last vel_cmd/. As well as slow down the process a lot

@Qtsho Qtsho reopened this Apr 26, 2021
@matheuslara
Copy link

matheuslara commented Feb 23, 2023

Hello.. I am having the same problem with ROS2 Foxy, Ubuntu 20.04, tensorflow. Did you find any solution for this problem?

@Zhefan-Xu
Copy link

I am watching the memroy usage and it is obvious the memory usage is keeping increasing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants