These commands are used while debugging or working with your ros2 package and gazebo world.
sudo apt install python3-colcon-common-extensions
source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash
rosdep install -i --from-path src --rosdistro humble -y
colcon build
Note 1: with this build method you have to always build your workspace/package whenever you make any change in your node.
There is a way that will automatically keep in sync your build environment with your changes so that u don't need to build explictly if u do some changes in your node :
colcon build --symlink-install
Note 2: In case you get warning while building your package like SetuptoolsDepreciation warning: setup.py install is depreciated. Use build and pip and other standard based tools.
Just follow the following steps :
pip3 list
pip3 list | grep setuptools
pip3 install setuptools==58.2.0
pip3 list | grep setuptools
source ~/.bashrc
downgrade setuptools version from 59.6.0 to 58.2.0.
colcon build --packages-select my_pkg
ros2 pkg create my_pkg --build-type ament_python dependencies rclpy
ros2 topic list
ros2 topic info /topic_name
ros2 interface list
These are basically ways to inteface/communicate in a ros environment.
Or your can also use
ros2 interface list | grep msg
ros2 interface show /topicType
ros2 topic echo /topic_name
ros2 services are usually to apply/change specific settings of a robot or to do some computations (so that a response only happens when we call that service).
ros2 service list
ros2 service type /service_name
ros2 interface show /service_msg__type
ros2 service call /service_name /service_msg_type "{arguments_of_service}"
sudo apt install ros-humble-tf2-tf2_tools
source /opt/ros/humble.setup.bash
ros2 run tf2_tools view_frames
This command will generate a pdf file listing all the transforms being used currently in your current working directory.
ros2 run tf2_ros tf2_echo frame_1 frame_2
ROS2 bags are basically way to record ros2 topic's data in a file.
Make sure you've already created a bags
folder in your workspace/package to make it more clear. All these commands should be run while your're currenlty in bags
directory n your terminal.
ros2 bags record /topic_name
By default the folder name will be rosbag2_YYYY_MM_DD-HH_MM_SS. In case you want to save the file in folder with a specific name, you can use the command
ros2 bag record /topic_name -o folder_name
ros2 bag record /topic_name1 /topic_name2 -o folder_name
ros2 bag record -a -o folder_name
ros2 bag info /ros2bag_folder_name
ros2 bag play /ros2bag_folder_name
Using this you don't need to explicitly publish the data on that node, this bag will publish the pre-recorded data on all those topics whom it recorded and you can see those topics in topic list and echo and stuff. It's basically playing those same topics without your original robot's ros environment.
We'll use a urdf_tutorial
of ros2 to visualize a urdf file with all it's links, joints, movements and all.
sudo apt install ros-humble-urdf_tutorial
source /opt/ros/humble/setup.bash
ros2 launch urdf_tutorial display.launch.py model:=absolute_path_to_urdf_file
gz sim
gz sim empty.sdf
ros2 launch ros_gz_sim gz_sim.launch.py gz_args:=empty.sdf
gz topic -list
or
gz topic -l
gz topic --echo --topic /topic_name
or
gz topic -e -t /topic_name
gz topic --echo --topic /topic_name
or
gz topic -e -t /topic_name
rqt_graph