304x Filetype PDF File size 2.38 MB Source: mrs.felk.cvut.cz
MRSlab ROS platform Cheat Sheet
by Tomas Baca (github.com/klaxalk) @ Multi-robot Systems (MRS), http://mrs.felk.cvut.cz, v1.0.0
Ubuntu terminal - GNU/Linux basics Git version control system
Hitting hTabi autocompletes commands, filenames, etc. Git is a distributed version control system. Repositories are equal, some are just used as a “server” (called
New terminal Ctrl+Alt+t remote). Git uses branches to isolate ongoing work on the same project. Branches can be merged to combine
Need help append --help after command the work back into a single piece. Changes in the files should be commited. Only commit “runnable” code.
Need more help! :$ man [command]
Change directory :$ cd [path] Cloning a repository over ssh :$ git clone git@mrs.felk.cvut.cz:uav/uav core
Path symbolic links . – current directory over https :$ git clone https://github.com/klaxalk/linux-setup
.. – previous directory Update origin state :$ git fetch
∼–homedirectory (also $HOME) Update current branch from remote :$ git pull
/ – root directory Update current branch to remote :$ git push
create a file :$ touch [path] Add files for commit :$ git add [file]
remove a file :$ rm [path] Commit changes :$ git commit -m "commit message"
move (also rename) a file :$ mv [from] [to] Checkout a branch :$ git checkout [branch name]
copy a file :$ cp [from] [to] Create a branch :$ git checkout -b [branch name]
print a file :$ cat [path] unstage the file :$ git reset [file name]
edit a file :$ vim [path], :$ nano [path] undo all uncommited changes :$ git reset --hard
set a variable :$ VARIABLE="dog", VARIABLE=3.0 remove all new unstaged files :$ git clean -fd
print a variable :$ echo "the content is: $VARIABLE" Merge a branch :$ git merge [branch name]
run a script or executable :$ ./script.sh, ./program Rebase on a branch :$ git rebase [branch name]
output redirection > – to a file (rewrite) refactor branch history :$ git filter-branch [lot of args]
>> – to a file (append) show status :$ git status
| – pipe to another command show log :$ git log
redirect to /dev/null > /dev/null 2>&1 show better log :$ glog
Would You Like to Know More? http://google.com – is an alias for :$ git log with more arguments
show super forest log :$ flog
TMUX-Terminal multiplexer – uses /.scripts/git-forest.sh
Would You Like to Know More? https://try.github.io/
Run tmux :$ tmux
List all sessions :$ tmux ls .bashrc – Bash configuration
Attach to a session :$ tmux a -t [session name]
New window (tab) Ctrl+t When a new terminal is opened and an instance of bash is launched, the ∼/.bashrc file is sourced (executed
New vertical split Ctrl+s while its leftover variables, functions and aliases stay in the context). We use .bashrc heavily for setting con-
New horizontal split Ctrl+d text for ROS and our development environment. .bashrc sources ROS setup scripts, which are also generated
Moving through windows (tabs) Shift+→, Shift+← by each workspace. If you change this file, source it (or open a new terminal) to activate the changes:
Moving through panes (splits) Alt+→, Alt+←, Alt+↑, Alt+↓ :$ source ∼/.bashrc or just :$ sb. Here is an example of what should not be missing in the bottom of a
prefix Ctrl+a healthy .bashrc file:
Killing window prefix x, :$ exit, :$ :q # THIS IS FOR VIM
Killing session prefix k export CTAGS_SOURCE_DIR="-R ~/mrs_workspace -R ~/workspace"
Detach from session prefix d export CTAGS_ONCE_SOURCE_DIR="-R /opt/ros/melodic/include"
Enter vim mode (scrolling, copying) F2, prefix [ export ROS_WORKSPACE="~/mrs_workspace ~/workspace"
Would You Like to Know More? https://github.com/klaxalk/linux-setup/wiki/tmux
export GIT_PATH=$HOME/git
Vim – a modern pluginizable text processor
source /opt/ros/melodic/setup.bash
Vim is not a joke. Although you might not know how to exit it (yet), it is a very powerful tool. Our vim # SOURCE ONLY ONE WORKSPACE AT A TIME
is filled with features, including code snippets, code completion (ROS aware), code formatting, syntax high- source ~/workspace/devel/setup.bash
lighting and tmux integration. Its control is completely mouse-less and it is fully usable over ssh, which makes # source ~/other_workspace/devel/setup.bash
it great for remote editing on a drone. Moreover, its modal editing paradigm is very intuitive. Lastly, when
you learn how to control vim, you also learn to control other tools such as Linux manual pages, ranger, less # NEEDED FOR SIMULATION
and much more. Even gmail uses vim-like controls natively. Run :$ vimtutor to start learning vim using an source /usr/share/gazebo/setup.sh
interactive “file tutorial”. Here are some simple commands: source $GIT_PATH/simulation/install/share/simulation/setup.sh
export UAV_MASS=3.0
switch to insert mode i jump a word/Word forwards w/W
return to normal mode ESC jump a word/Word backwards b/B # SWAP LOCALHOST FOR A HOSTNAME OF A REMOTE ROS SERVER
cut a line to clipboard dd change current word/Word ciw/ciW export ROS_MASTER_URI=http://localhost:11311
paste a clipboard p delete 3 lines down 3dj
open a command line : substitute dog for cat :%s/dog/cat/g # SET TO FALSE IF YOU DON’T LIKE TMUX
save :w move cursor left/down/up/right h/j/k/l export RUN_TMUX=true
quit :q delete every line containing dog :%g/dog/normal dd
Would You Like to Know More? https://www.tutorialspoint.com/vim/ source $GIT_PATH/linux-setup/appconfig/bash/dotbashrc
1
ROSin Linux terminal ROSpackage structure
Please, visit http://wiki.ros.org/ROS/Tutorials before starting work on a bigger project. Some of the following items might be missing, depending on the package use case.
Use hTabi to complete commands, topic names, message types and pre-fill message contents.
Getting help append --help after any following command package.xml manifest, dependencies and plugins
Listing all ROS nodes :$ rosnode list CMakeLists.txt description of compilation procedure
Listing all ROS topics :$ rostopic list src/ C and C++ source codes
Listing all ROS services :$ rosservice list include/ C and C++ headers
Listing all ROS params :$ rosparam list scripts/ Python and bash scripts
Running a ROS binary :$ rosrun package name binary name config/ yaml config files
Running a launch file :$ roslaunch package name launch file.launch cfg/ dynamic reconfigure scripts
Showing a node info :$ rosnode info /node/path launch/ ROS launch files
Showing a topic info :$ rostopic info /topic/path Would You Like to Know More? http://wiki.ros.org/Packages
Showing a service info :$ rosservice info /service/path
Showing a topic type :$ rostopic type /topic/path ROSvisualization tools
Showing a service type :$ rosservice type /topic/path
Showing a message type structure :$ rosmsg show [msg type] Rviz 3-D visualization of data and models
Showing a service type structure :$ rossrv show [srv type] :$ rviz
Showing topic messages :$ rostopic echo /topic/path :$ roslaunch mrs testing rviz uav1.launch
Showing a param value :$ rosparam get /parm/path Rqt plot simple and lightweight plotting
Calling a service :$ rosservice call /service/path [args] :$ rqt plot
Publishing on a topic :$ rostopic pub /topic/path [args] Rqt bag visualizing contents of a rosbag
Setting a param value :$ rosparam set /parm/path [args] :$ rqt bag
Would You Like to Know More? http://wiki.ros.org/ROS/CommandLineTools Plot juggler complex and powerful plotting
:$ rosrun plotjuggler PlotJuggler
ROSworkspace structure Rqt reconfigure online parameter setting
:$ rosrun rqt reconfigure rqt reconfigure
MRSlab main workspace Rqt image view camera images visualization
:$ rqt image view
path ∼/mrs workspace/ Gazebo client Gazebo GUI
contains src/uav core/ – core MRS repository :$ gzclient
src/uav modules/ – modules MRS repository rqt Integrates most of the rqt tools
:$ rqt
MRSlab student workspace Would You Like to Know More? http://wiki.ros.org/Tools
path ∼/workspace Useful UAV ROS topics and services
contains example packages/ Following ROS services and topics allow for controlling the UAV from terminal. Each address contains a
– waypoint flier – general ROS template particular name of the UAV.
– vision example – computer vision template
Informative topics (subscribe to know stuff)
General ROS package structure state estimate (rviz-able) /uav1/odometry/odom main
build generated makefiles and support files control reference (rviz-able) /uav1/control manager/cmd odom
do not modify control reference /uav1/control manager/position cmd
devel compiled binaries, libraries and installed headers active tracker status /uav1/control manager/tracker status
do not modify active controller status /uav1/control manager/controller status
src package source codes MPCtracker diagnostics /uav1/control manager/mpc tracker/diagnostics
place your stuff here
Would You Like to Know More? https://mrs.felk.cvut.cz/gitlab/uav/uav_core/wikis/file_structure Control Services/Topics (call or publish to influence stuff)
Even more? https://mrs.felk.cvut.cz/gitlab/uav/uav_core/wikis/repositories_structure The ROS topics and services for goto, goto relative and goto fcu have the same address.
Navigating and compiling ROS workspace world absolute goal /uav1/control manager/goto
world relative goal /uav1/control manager/goto relative
go to a package :$ roscd [package name] frame relative goal /uav1/control manager/goto fcu
compile the whole workspace :$ catkin build takeoff /uav1/uav manager/takeoff
compile a particular package :$ catkin build [package name] land /uav1/uav manager/land
compile current package :$ catkin bt land home /uav1/uav manager/land home
clean the whole workspace :$ catkin clean hover /uav1/uav manager/hover
clean a particular package :$ catkin clean [package name] switch controller /uav1/control manager/switch controller [Controller]
show workspace config :$ catkin config switch tracker /uav1/control manager/switch tracker [Tracker]
show compilation profiles :$ catkin profile list set tracker constraints /uav1/constraint manager/set constraints [Constraints]
set a compilation profile :$ catkin profile set [profile name] set SO(3) controller gains /uav1/gain manager/set gains [Gains]
create a new workspace :$ catkin init load trajectory /uav1/control manager/mpc tracker/load trajectory
set workspace extending :$ catkin config --extend [path] trajectory fly2start /uav1/control manager/mpc tracker/fly to trajectory start
trajectory fly /uav1/control manager/mpc tracker/start trajectory following
Would You Like to Know More? https://catkin-tools.readthedocs.io/en/latest/ You Like to Know More? https://mrs.felk.cvut.cz/gitlab/uav/uav_core/wikis/commanding_the_drone
2
SSH keys Quaternions (unit quaternions)
• Generate your SSH key by: :$ ssh-keygen -t rsa -b 4096 -C "your email@example.com". “Complex” numbers with three imaginary parts: i, j, k and k·k = 1.
• The keys are stored in ∼/.ssh. By axis [x,y,z] and angle φ q = cos φ +(xi+yj +zk)sin φ
2φ φ 2 φ φ
Component-wise q =cos , q =xsin , q =ysin , q =zsin
• Show the content of the public key by: :$ cat ∼/.ssh/id rsa.pub and copy it to Github or Gitlab. w 2 x 2 y 2 z 2
q −q i−q j−q k
Inverse quaternion q−1 = cos −φ +(xi+yj +zk)sin −φ = w x y z
2 2 q2 +q2+q2+q2
• Copy your public key over ssh to another machine by: :$ ssh-copy-id user@machine. w x y z
Transforming the vector [1,2,3] u=0+1i+2j+3k,v=quq−1
• Entries in the ∼/.ssh/config allow connecting to a machine via alias while using an ssh key:
host mrs Getting Euler angles from Odometry:
hostname mrs.felk.cvut.cz double yaw, pitch, roll;
user git tf2::Quaternion quaternion;
identityfile ~/.ssh/id_rsa tf2::fromMsg(odometry->pose.pose.orientation, quaternion);
tf2::Matrix3x3(quaternion).getRPY(roll, pitch, yaw);
Spawning a UAV in Gazebo simulator Would You Like to Know More? https://eater.net/quaternions
We created the :$ spawn command to dynamically load a UAV into the Gazebo/ROS simulator. Various Common ROS handlers in C++
arguments can be used to influence the type of the drone, its sensors, its starting location and additional
onboard hardware. Type :$ spawn --help to see the complete list, here are some notable examples: node handler ros::NodeHandle nh = ros::NodeHandle("∼");
nodelet handler ros::NodeHandle nh = nodelet::Nodelet::getMTPrivateNodeHandle();
start and stop the onboard firmware automatically --run --delete subscriber ros::Subscriber subscriber = nh.subscribe("name", 1, callback, this,
use initial position from a CSV file (id, x, y, z, heading) --file [file] ros::TransportHints().tcpNoDelay());
add down-facing rangefinder --enable-rangefinder publisher ros::Publisher publisher = nh.advertise("name", 1);
add front-facing camera --enable-bluefox-wall service client ros::ServiceClient client = nh.serviceClient("name");
add down-facing camera --enable-bluefox service server ros::ServiceServer server = nh.advertiseService("name", callback, this);
add front-facing RealSense --enable-realsense-front timer ros::Timer timer = nh.createTimer(ros::Rate(30), callback, this);
add 2-D rangefinder --enable-rplidar
add 3-D rangefinder --enable-velodyne Would You Like to Know More? http://wiki.ros.org/ROS/Tutorials
add UV camera for UVDAR --enable-uv-camera Common ROS handlers in Python
add UV leds for UVDAR --enable-uv-leds
set UV led frequencies --led-frequencies [L] [R] node handler rospy.init node(’node name’, anonymous=True)
add super long pendulum --enable-pendulum subscriber subscriber = rospy.Subscriber(’∼topic name’, MessageClass, callback,
add ball holder --enable-ball-holder queue size=1)
Atypical simulation spawning looks like: publisher publisher = rospy.Publisher(’∼topic name’, MessageClass, queue size=1)
:$ spawn 1 --run --delete --enable-rangefinder --enable-ground-truth --enable-bluefox-wall service client client = rospy.ServiceProxy(’∼service name’, MessageClass)
service server server = rospy.Service(’∼service name’, MessageClass, callback)
ROSonaremote machine timer timer = rospy.Timer(rospy.Duration(1/30.0), callback)
Would You Like to Know More? http://wiki.ros.org/ROS/Tutorials
• Add your local machine to the remote machine’s /etc/hosts and vice versa. Common Eigen operations in C++
• Make sure the machines can ping each other using their hostname.
• Add export ROS MASTER URI=http://localhost:11311 to the remote’s .bashrc. Fixed matrix Matrix A; element-wise product P.cwiseProduct(Q)
• Add export ROS MASTER URI=http://hostname:11311 to the local’s .bashrc, where hostname is the re- Dynamic matrix MatrixXd A; Norm v.norm()
mote’s hostname. Dynamic vector VectorXd v; Squred norm v.squaredNorm()
Zero matrix MatrixXd::Zero(rows, cols) Dot product v.dot(u)
• Run roscore only on the remote machine. Identity matrix MatrixXd::Identity(n, n) Cross product v.cross(v)
Vector element v(n) Solve Ax=b x = A.qr().solve(b);
The math that everybody needs, but nobody remembers Matrix element A(row, column) Eigen-decomposition EigenSolver eig(A);
Matrix inversion A.inverse() Matrix transposition A.transpose()
2-D rotational matrix: Degrees-to-radian conversion table with values of sin and cos: Matrix column A.col(n) #include for everything
deg 0 30 45 60 90 120 180 no. of rows and cols A.rows(), A.cols() #include for cross
R(φ)= cosφ −sinφ rad 0 0.523 0.785 1.047 1.57 2.09 3.14 Sub-matrix A.block(i, j, rows, cols) #include for QR decomposition
sinφ cosφ sin 0.0 0.500 0.707 0.866 1.0 0.866 0.0 Would You Like to Know More? https://eigen.tuxfamily.org/dox/AsciiQuickReference.txt
cos 1.0 0.866 0.707 0.500 0.0 -0.50 -1.0
visit the MRS lab!
(and use Google)
3
no reviews yet
Please Login to review.