To work with ROS one needs to source the environmental setup
source /opt/ros/melodic/setup.zsh
rospack find NAME rospack find roscpp roscd NAME roscd turtle rosls NAME rosls turtle rospack depends NAME rospack depends1 NAME rospack depends1 rospy
To create a package one first must create and cd to subdirectory project/src/
catkin_create_pkg <package_name> [depend1] [depend2] [depend3] catkin_create_pkg beginner_tutorials std_msgs rospy roscpp
To build a catkin workspace must first cd to project/ and run
catkin_make
To source workspace to ROS environment
source src/devel/setup.zsh
Starting ROS core server
roscore
Listing and getting information about ROS nodes
rosnode list rosnode info /rosout
rosrun allows you to use the package name to directly run a node within a package
rosrun [package_name] [node_name] rosrun turtlesim turtlesim_node rosrun turtlesim turtlesim_node __name:=my_turtle
ROS graph showing the interaction between nodes and topics
rosrun turtlesim turtlesim_node rosrun turtlesim turtle_teleop_key rosrun rqt_graph rqt_graph
Listing ROS Topics
rostopic list -v
List data published to the Topic
rostopic echo [topic] rostopic echo /turtle1/cmd_vel
Get the message type of the published Topic
rostopic type /turtle1/cmd_vel
Get the details of the message type
rosmsg show geometry_msgs/Twist
Publishing data to ROS Topic
rostopic pub [topic] [msg_type] [args] rostopic pub -1 /turtle1/cmd_vel geometry_msgs/Twist -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, 1.8]' rostopic pub /turtle1/cmd_vel geometry_msgs/Twist -r 1 -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, -1.8]'
Reports rate at which data is published to Topic
rostopic hz [topic] rostopic hz /turtle1/pose
Display plots of data published to the Topics
rosrun rqt_plot rqt_plot
Services allow to request a node for a response.
Basic commands
rosservice list rosservice type [service] rosservice type /clear rosservice call [service] [args] rosservice call /clear rosservice call /spawn 2 2 0.2 ""
ROS Parameters allow to store data in ROS Parameter Server
rosparam list rosparam set [param_name] rosparam get [param_name] rosparam set /background_r 150 rossservice call /clear
Recording a replaying ROS inputs.
Recording a bagfile
mkdir ~/bagfiles cd ~/bagfiles rosbag record -a rosbag record -O subset /turtle1/cmd_vel /turtle1/pose
Examining bagfile
rosbag info FILE
Replaying bagfile
rosbag play FILE rosbag play -r 2 FILE