for running ros 1: first terminal:
roscore
command to start the port
second Terminal:
catkin_make
source path/devel/setup.bash
python3 mainwindow.py
Colcon build, catkin_make and catkin build are ros debugger
they will detect any errors indicating in the table below.
if rosrun is not working
# 1) Make sure the file has a Python shebang for Noetic (Python 3)
sed -n '1p' /root/catkin_ws/newui_Greyform/src/talker_listener/talker_listener/listener_node.py
# If the first line is not this, add it:
# #!/usr/bin/env python3
# Add/ensure the shebang (idempotent; only adds if missing)
awk 'NR==1 && $0!~/^#!\\/usr\\/bin\\/env python3$/ {print "#!/usr/bin/env python3"} {print}' \\
/root/catkin_ws/newui_Greyform/src/talker_listener/talker_listener/listener_node.py \\
> /tmp/_listener_node.py && \\
mv /tmp/_listener_node.py /root/catkin_ws/newui_Greyform/src/talker_listener/talker_listener/listener_node.py
# 2) Fix Windows line endings if the file came from Windows (prevents /usr/bin/env^M errors)
sed -i 's/\\r$//' /root/catkin_ws/newui_Greyform/src/talker_listener/talker_listener/listener_node.py
# 3) Mark it executable
chmod +x /root/catkin_ws/newui_Greyform/src/talker_listener/talker_listener/listener_node.py
# 4) Make sure your workspace is sourced
source /opt/ros/noetic/setup.bash
cd /root/catkin_ws/newui_Greyform
catkin_make # (not strictly required for pure-Python, but fine)
source devel/setup.bash
# 5) Start roscore (in another shell/tab, or background)
roscore &
sleep 1
# 6) Now rosrun will work because the file is executable
rosrun talker_listener listener_node.py
In Summary ros 1 noetic in docker is required to run 2 terminal while ros 2 humble is required to run 1 terminals for the setup since i am using subprocess from python library , the subprocess library are considered a command line for running an extra terminal for rosrun.
This algorithm subprocess.Popen([”rosrun/ros2run” , “package_name” , “listener_node.py”],) will reduce one terminal process.
the requirement to run this code is to source your ros after catkin_make and colon build . make sure you source the right file directory after catkin_make and colon build. Double check ros2 pkg list or rospack list if there is a talkerlistener in the list.