He, Peng

A Roboticist.

The secret of getting ahead is getting started.

ROS Essential Skills B4 You Start

ROS Naming Convention

Class name is still camelCase: class TrackerUI
Var names are small case underbared: var roi_window
Function names are small case verb front underbared: func get_roi_window

I feel it is comfy to do things in this way rather than the camelCase and just try to shorten every variable in one or two words, not too fancy.

ROS Workspace Structure

How to organize your packages & workspaces

  • If the project is based on a unique instance, for example, it will finally be applied to a robot then make it a separate ws named folder under the company ws folder. In this case, you should make the whole project a repo.

  • If this project is an implementation of a small function — a simple ROS package, put it in under the catkin_ws/src folder that under the company ws folder. You can always put the non-ROS related project under this folder and treat them as a package. Make each single package a repo. I'll show how in the folder tree view below.

This is helpful to isolate the package functions and also help to use the find pkg inline macro to merge packages together for a bigger project.

When you need to publish a product, for example, copy over all the function package you developed in the catkin_ws and make a commit, nothing needs to change.

Do this under the "git root" folder to link the folder to a remote

First, you should create the remote repo online. Then do
git remote add origin git@github.com:User/UserRepo.git

<COMPANY_NAME>_ws # manually create this  
├── <PROJECT_NAME>_ws # manually create this
│   ├── install
│   │   ├── rules
│   │   └── scripts
│   ├── README.md
│   └── src # manually create this, this should be the **repo root**
│       ├── <PROJECT_NAME>_description
│       ├── <PROJECT_NAME>_nav
│       ├── <PROJECT_NAME>_robot
│       ├── CMakeLists.txt 
│       ├── kinect_aux
│       ├── ray_efficiency_heatmap
│       └── rplidar_ros
├── catkin_ws # manually create this
│   └── src # manually create this
│       ├── CMakeLists.txt 
│       ├── hp_utils   # manually create, **repo root**
│       ├── openni_tracker # if the repo is created online, 
│       └── speech_command # git clone it directly under `/src`

ROS [Joy] Using Guide

First, you need to install the package:

sudo apt-get install ros-<distro>-joy

Get the test

sudo jstest /dev/input/jsX

device to use- the default is js0.

rosparam set joy_node/dev "/dev/input/jsX"

Now we can start the joy node.

rosrun joy joy_node

Echo the /joy topic to figure out the real date order. In general here is how the callback looks like.

ROS [Param Server] Get Parameters

- Fetch value from the Parameter Server. You can optionally pass in a default value to use if the parameter is not set. Names are resolved relative to the node's namespace. If you use get_param() to fetch a namespace, a dictionary is returned with the keys equal to the parameter values in that namespace. KeyError is raised if the parameter is not set.

global_name = rospy.get_param("/global_name")
relative_name = rospy.get_param("relative_name")
private_param = rospy.get_param('~private_name') # `~` = `NODE_NAME/`
default_param = rospy.get_param('default_param', 'default_value')

# fetch a group (dictionary) of parameters
gains = rospy.get_param('gains')
p, i, d = gains['P'], gains['I'], gains['D']

so in this feature_type = rospy.get_param("~feature_type","SIFT")
you can actually set and get back the param at same time.

ROS Node Param

There are two param types, one is global, one is local. You will find the local param in ROS doc prefixed with ~.
How to set local param from a terminal?
For example. In ROS joint state node:

~use_gui (Boolean, default: False)

  • Whether to use the GUI or not

This should be used as :
rosrun joint_state_publisher joint_state_publisher _use_gui:=true

Where in a launch file you should do:

<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" output="screen"/>
<param name="use_gui" value="true"/>

ROS [Topic] Publish Once No data array

rostopic echo /front_cam/image_raw --noarr -n1

ROS [Service] Command Line Call

rosservice call /stop_motor "{}" 

ROS [TF] View

rosrun tf view_frames

Wait for this to complete, and then type in:

evince frames.pdf

ROS [Navigation Stack] Cancel A Goal

To cancel a move_base planning

rostopic pub /move_base/cancel actionlib_msgs/GoalID -- {}
Recent Posts

ROS Trivial Troubleshooting

Abstract: The most annoying parts are the tiny parts break you developing flow when dealing with the…

In ROS, TroubleShootingRead More
Earlier Posts

Robotics 101: Sharpening The Tools -- Shorthands For Environment Setups

Abstract: After month and month working in robotics, I realize that a good knowledge of tooling coul…

In ConfigRead More
comments powered by Disqus