ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ROS2 launch.py, execute node on actual terminal [closed]

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

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

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 reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2020-12-18 12:55:21.170193

Comments

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

kyrofa gravatar image kyrofa  ( 2019-06-27 16:43:41 -0600 )edit

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

artivis gravatar image artivis  ( 2019-06-28 08:15:46 -0600 )edit

or use bash scripts and register it under scripts in setup.py

Vincent_s gravatar image Vincent_s  ( 2022-11-29 08:26:39 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

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

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 image artivis  ( 2019-06-27 10:31:58 -0600 )edit

Question Tools

2 followers

Stats

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

Seen: 1,405 times

Last updated: Jun 28 '19