Skip to content

Conversation

goktug97
Copy link
Contributor

@goktug97 goktug97 commented Dec 7, 2019

If the plot is dynamic such that the plt.pause is used to show the plot, it doesn't let you use the terminal if you are using a window manager such as i3. You have to spam Ctrl+C while clicking to the terminal to close early. Added

plt.gcf().canvas.mpl_connect('key_release_event',
        lambda event: [exit(0) if event.key == 'escape' else None])

statement to every script that uses plt.pause to create dynamic plots, if the plots are static and drawn only once, the statements is not added. Now the scripts can be closed by pressing ESC.

- The obstacle rotation for the rectangle obstacle calculation
is wrong. It should be positive instead of negative.
condition check is moved from the inside of the resampling function
to the outside of the function, this way the purpose of the
function is much clear. Instead "resampling" every iteration,
resample if the condition holds.
@coveralls
Copy link

coveralls commented Dec 7, 2019

@AtsushiSakai
Copy link
Owner

AtsushiSakai commented Dec 13, 2019

@goktug97 Thank you for interesting PR. Can I ask a question?.

It doesn't let you use the terminal if you are using a window manager such as i3

Do you want to use terminal during simulation? I don't know whether it is useful or not because I am not a user of i3.

@goktug97
Copy link
Contributor Author

goktug97 commented Dec 13, 2019

@goktug97 Thank you for interesting PR. Can I ask a question?.

It doesn't let you use the terminal if you are using a window manager such as i3

Do you want to use terminal during simulation? I don't know whether it is useful or not because I am not a user of i3.

I don't need to use a terminal but if I want to use one, I can change to another workspace. The problem is, if I want to close the simulation it is a little bit hard and annoying because the matplotlib plot changes the focus so I need to click to the terminal and press Ctrl + C at the same time.

@AtsushiSakai
Copy link
Owner

@goktug97 OK. I got it. I would like to merge this PR, but I have a request. Please check the review.

@goktug97
Copy link
Contributor Author

from pathlib import Path

string = 'mpl_connect'
for filename in Path('PythonRobotics').rglob('*.py'):
    f = open(filename, 'r')
    with open(filename, 'r') as f:
        lines = f.readlines()
    numbers = []
    for i, line in enumerate(lines):
        if string in line:
            numbers.append(i)
    for number in reversed(numbers):
        ws = len(lines[number]) - len(lines[number].lstrip(' '))
        lines.insert(number, (ws * ' ') + '# for stopping simulation with the esc key.\n')
    with open(filename, 'w') as f:
        f.writelines(lines)

Kind of back fired but done.

@AtsushiSakai AtsushiSakai merged commit ad5e1aa into AtsushiSakai:master Dec 14, 2019
@AtsushiSakai
Copy link
Owner

@goktug97 Thank you!!

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

Successfully merging this pull request may close these issues.

3 participants