Ask Your Question
0

ROS2 launch.py, execute node on actual terminal

asked 2019-06-26 16:07:58 -0500

updated 2019-06-28 09:25:07 -0500

I am writing a ros2 launch file for a Python node that draws on terminal with curses - namely key_teleop. The node runs just fine with ros2 run but crashes when going through ros2 launch. The launch file is kept to the minimum,

import os  
from launch import LaunchDescription  
import launch_ros.actions  

def generate_launch_description():
    proc_env = os.environ.copy()
    proc_env['PYTHONUNBUFFERED'] = '1'

    return LaunchDescription([launch_ros.actions.Node(
        package='key_teleop', node_executable='key_teleop',
        env=proc_env)])

Is there anything in the launch framework that would prevent the node from accessing the terminal ?
Is there some parameters, handler or whatnot to define / set up for my application to run smoothly ?

The error, while I don't expect it to be very helpful, is the following:

Traceback (most recent call last):
 File "/usr/lib/python3.6/curses/__init__.py", line 78, in wrapper
   cbreak()
_curses.error: cbreak() returned ERR

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
 File "/usr/lib/python3.6/curses/__init__.py", line 100, in wrapper
   nocbreak()
_curses.error: nocbreak() returned ERR

Edit:

After some reading, curses requires a full blown terminal application which launch most likely does not offer. One could launch a terminal from the launch file to execute the script but that sounds awful. E.g. with launch-prefix="gnome-terminal --command".

This so answer suggests using pyte.

edit retag flag offensive close merge delete

Comments

Have you tried adding output='screen'? Does that change anything?

kyrofa gravatar imagekyrofa ( 2019-06-27 16:43:41 -0500 )edit

I did and beside not fixing anything it messes up the terminal.

artivis gravatar imageartivis ( 2019-06-28 08:15:46 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-06-27 10:09:24 -0500

jhassold gravatar image

It looks like your return statement is outside of the generate_launch_description() function. Do you still get an error if you indent it over to be in line with proc_env?

In other words, something like this:

import os  
from launch import LaunchDescription  
import launch_ros.actions  

def generate_launch_description():
    proc_env = os.environ.copy()
    proc_env['PYTHONUNBUFFERED'] = '1'

    return LaunchDescription([launch_ros.actions.Node(
            package='key_teleop', node_executable='key_teleop',
            env=proc_env)])
edit flag offensive delete link more

Comments

The indentation issue comes from copy/pasting, the original script is correct. I'll edit the question, thx.

artivis gravatar imageartivis ( 2019-06-27 10:31:58 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2019-06-26 16:07:58 -0500

Seen: 96 times

Last updated: Jun 28