Robot Operating System/ROS

[ROS] teleop_twist_keyboard 터미널 이상하게 출력되는 현상 수정 방법

jstar0525 2023. 3. 31. 20:00
반응형

문제 현상

https://github.com/ros-teleop/teleop_twist_keyboard

 

GitHub - ros-teleop/teleop_twist_keyboard: Generic Keyboard Teleop for ROS

Generic Keyboard Teleop for ROS. Contribute to ros-teleop/teleop_twist_keyboard development by creating an account on GitHub.

github.com

위 링크의 teleop_twist_keboard를 다른 ros package와 같이 launch하면

아래와 같이 터미널이 정상적으로 출력되지 않음

currently:      speed 0.22      turn 0.187
                                           currently:   speed 0.242     turn 0.2057
                                                                                    currently:  speed


currently:      speed 0.322102  turn 0.2737867
                                               currently:       speed 0.3543122 turn 0.30116537
                                                                                                curre
                                                                                                     977

currently:      speed 0.4715895382      turn 0.40085110747
                                                           currently:   speed 0.51874849202     turn

                                                                                                     urn 0.533532824043
                   currently:   speed 0.690454242879    turn 0.586886106447
                                                                            currently:  speed 0.75949

currently:      speed 0.835449633883    turn 0.710132188801
                                                            currently:  speed 0.918994597271    turn

                                                                                                     urn 0.945185943294
                   currently:   speed 1.22318180897     turn 1.03970453762
                                                                           currently:   speed 1.34549

 

해결방법

https://github.com/ros-teleop/teleop_twist_keyboard/blob/master/teleop_twist_keyboard.py

 

GitHub - ros-teleop/teleop_twist_keyboard: Generic Keyboard Teleop for ROS

Generic Keyboard Teleop for ROS. Contribute to ros-teleop/teleop_twist_keyboard development by creating an account on GitHub.

github.com

위 파일의 175번줄

tty.setraw(sys.stdin.fileno())를

tty.setcbreak(sys.stdin.fileno())으로 수정

 

ref.

https://stackoverflow.com/questions/52780783/issue-printing-out-to-terminal-with-correct-format

 

Issue printing out to terminal with correct format

I've written a very simple program that has multiple threads that is supposed to print out to the terminal. One thread prints out an array of 10 stars, where the other thread is supposed to run in ...

stackoverflow.com

반응형