My ROS Notes

Creating a Workspace
> mkdir -p ~/catkin_ws/src
# After every new package or change in workspace
> cd ~/catkin_ws
# Building the workspace
> catkin_make
# Source in order to update environment
> source devel/setup.bash

Packages in a catkin Workspace(Structure)
# Only work on src folder, dont touch others devel or build
workspace_folder/
  src/
  CMakeLists.txt
  package_1/
  CMakeLists.txt
  package.xml
  package_2/
  CMakeLists.txt
  package.xml

Creating a catkin Package in Workspace
> cd ~/catkin_ws/src
> catkin_create_pkg beginner_tutorials std_msgs rospy roscpp
# After every new package or change in workspace
> cd ~/catkin_ws
# Building the workspace
> catkin_make
# Source in order to update environment
> source devel/setup.bash

Nodes Communication
        # each topic has a message type
/teleop_turtle(node)->/turtle1/cmd_vel(topic)->/turtle_sim(node)

# Create an anonymous node to listen to the cmd_vel topic
> rostopic echo /turtle1/cmd_vel
# if you publish to cmd_vel topic, then you can move the robot
        > rostopic pub /turtle1/cmd_vel geometry_msgs/Twist -r 1 -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, -1.8]'

Github and linking ros packages
# Downloading codes from github
> cd ~/git
> git clone <github_address.git>
# Symlink the new package to your catkin workspace
> ln -s ~/git/<package_name> ~/catkin_ws/src
# After every new package or change in workspace
> cd ~/catkin_ws
# Building the workspace
> catkin_make
# Source in order to update environment
> source devel/setup.bash

ROS Launch
# Launch multiple nodes at once
# Automatically starts roscore
> roslaunch <package_name> <launch_name.launch>
# In order to set arguments
> roslaunch launch_file.launch arg_name:=value
# Including other Launch Files in a Launch file
<include file="package_name">
<arg name="" value=""/>
</include>
# Including parameters or parameters file(.yaml)
<rosparam command="load" file="$(find rosparam)/example.yaml" />
<rosparam>
a: 1
b: 2
</rosparam>
# Dont copy and paste a launch file from a ros package, open it from your launch file

# state publishers
joint_state_publisher:
        we dont need joint_state_publisher node because it is published by gazebo.
robot_state_publisher:
        robot_state_publisher uses the URDF specified by the parameter robot_description and
the joint positions from the topic joint_states to calculate the forward kinematics of the robot and         publish the results via tf.

RQT GRAPH
# This graph helps you to see all the connections.
> rosrun rqt_graph rqt_graph


Turtlesim
#
> rosrun turtlesim turtlesim_node
> rosrun turtlesim turtle_teleop_key
# Publish
> rostopic pub /turtle1/cmd_vel geometry_msgs/Twist -r 1 -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, -1.8]'
# Show the data on a topic
> rostopic echo /turtlesim
# Message info
> rostopic type /turtle1/cmd_vel | rosmsg show
# Ros topics in verbose option
> rostopic list -v

Creating Msg and Srv
# Msg
Header header
string child_frame_id
geometry_msgs/PoseWithCovariance pose
geometry_msgs/TwistWithCovariance twist
# Srv
int64 A
int64 B
---
int64 Sum

Husky
# husky_robot: husky_base, husky_bringup
# husky_simulator: husky_gazebo
# husky_desktop: husky_viz
# common: husky_control, husky_description, husky_msgs
# application: husky_navigation, husky_ur5_moveit_config

TF
# After broadcasting tf of turtle, we can see the tfs between two frames
> rosrun tf tf_echo /world /turtle1
> rosrun tf tf_echo /world /turtle2


RVIZ
        # open turtle_rviz.rviz with rviz
> rosrun rviz rviz -d `rospack find turtle_tf`/rviz/turtle_rviz.rviz

***message_filters/time_synchronizer.h -> synchronize two sensor information***


Errors:
1-Error: Could not find a package configuration file provided by "gazebo" with any of the following names:
gazeboConfig.cmake
gazebo-config.cmake
1-Solution: Installing libgazebo7-dev solved it

2-Error: Fixed frame [Map] does not exist
2-Solution: rosrun tf static_transform_publisher 0.0 0.0 0.0 0.0 0.0 0.0 map my_frame 100
OR add this line to launch file: <node pkg="tf" type="static_transform_publisher" name="map_nav_broadcaster" args="0 0 0 0 0 0 map nav 100" />
Note: static_transform_publisher x y z yaw pitch roll frame_id child_frame_id period_in_ms

Publish a static coordinate transform to tf using an x/y/z offset in meters and yaw/pitch/roll in radians. The period, in milliseconds, specifies how often to send a transform. 100ms (10hz) is a good value.

3-Error: sudo apt-get install ros-indigo-husky-* -> dependencies error
3-Solution:
1. sudo apt-get install libsdformat-dev gazebo2 ros-indigo-gazebo-ros ros-indigo-gazebo-ros-pkgs ros-indigo-gazebo-ros-control libsdformat1
2. sudo apt-get install ros-indigo-husky-*
3. sudo apt-get remove gazebo2
4. sudo apt-get install gazebo7

Comments