Ros launch (Python Script) [closed]

asked 2020-08-24 12:17:49 -0500

HASSAN ISMAIL gravatar image

updated 2022-08-07 08:57:14 -0500

lucasw gravatar image

I wrote a single node and package ros program

the python program is

#! /usr/bin/env python

import rospy

 rospy.init_node('hassan')
 print "My name is Hassan Ismail"

but when i launch the program then the following error occurred.

   File "/home/robotics/catkin_ws/src/my_package/src/ismail.py", line 5
    rospy.init_node('hassan')
    ^
IndentationError: unexpected indent
[hassan-2] process has died [pid 5873, exit code 1, cmd /home/robotics/catkin_ws/src/my_package/src/ismail.py __name:=hassan __log:=/home/robotics/.ros/log/f0f7a8d6-e629-11ea-9691-f54b74ed3492/hassan-2.log].
log file: /home/robotics/.ros/log/f0f7a8d6-e629-11ea-9691-f54b74ed3492/hassan-2*.log
edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant. Please see http://wiki.ros.org/Support for more details. by gvdhoorn
close date 2020-08-24 13:45:57.271446

Comments

1

I'm sorry, but this is not a ROS question.

I would suggest you post your question on a more appropriate forum. One about learning Python should be able to help you.

gvdhoorn gravatar image gvdhoorn  ( 2020-08-24 13:46:46 -0500 )edit

Take a look at the official docs for 2.7. Also, the hint that the interpreter is giving you

   File "/home/robotics/catkin_ws/src/my_package/src/ismail.py", line 5
    rospy.init_node('hassan')
    ^
IndentationError: unexpected indent
jayess gravatar image jayess  ( 2020-08-24 19:08:18 -0500 )edit