First install ROS in ubuntu OS by following given official web address:
And after this follow given steps to run python node:
First create catkin_ws by using following command:
$mkdir catkin_ws
$cd catkin_ws/
And then after create directory src inside catkin_ws:
$mkdir src
$ls
$cd src/
Back to the catkin_ws and run catkin_make
$cd ..
$catkin__make
And then create devel inside it
$source devel/setup.bash
$clear
$ls
$cd #(go to the main directory)
$clear
Check roscore is running or not if not then run by using "roscore" and open new another terminal
And follow all command step by step which is given bellow.
$cd catkin_ws/
$ls
$cd src
$ls
$catkin_create_pkg tutorial std_msgs rospy roscpp
$cd ..
$catkin_make
$clear
$ls
$cd src
$cd tutorial/
$ls
$cd src
$ls
$clear
$nano talker.py #(new block window open paste code in it)
$ctrl+o #(for save)
$enter
$ctrl+x (fro exit)
$sudo chmod +x talker.py # chmod used for read and write mode
$clear
$cd -/catkin_ws/ # or use cd .., cd .., cd .. and goto the catkin_ws directory
$catkin_make
$ls
$cd devel/
$ls
$source setup.bash
$cd .. #(back to catkin_ws directory)
$clear
$rosrun tutorial talker.py #(running on catkin_ws directory)
$cd src/tutorial/src/
$ls
$nano listener.py # paste code and save
$ctrl+o
$ctrl+x # for exit
$sudo chmod +x listener.py # cd .., cd .. until back to the catkin_ws and run
$catkin_make
$clear
$cd devel
$source setup.bash
$cd .. #(back to catkin directory)
$clear
$rosrun tutorial listener.py
-------------------------------
if you want to edit file then this query
$rosed tutorial talker.py
If you need any help related to ros then contact at here or comments in comments sections.
Comments