当前位置:网站首页>Introduction to ROS learning notes (II)

Introduction to ROS learning notes (II)

2022-04-23 18:40:00 Why is it so difficult to name?

Start

The last installation completed dual systems and ROS operating system , Before I start learning theory , Try to understand a simulation project .
ROS-Academy-for-Beginners
website : https://github.com/DroidAITech/ROS-Academy-for-Beginners.git
This is a Chinese University MOOC The source code provided in the introduction course of robot operating system , This blog is based on the lecture notes , If there is something wrong , Please correct .
You can't take a bus before you learn to drive .

Download source package

  1. stay Ubuntu On the system , Make sure git Is already installed $ sudo apt-get install git
  2. Then create a file named tutorial_ws Working space for , In its src Clone under path ROS-Academy-for-
    Beginners software package
$	cd	
$	mkdir	-p	tutorial;								# establish catkin working space 
$	cd	tutorial_ws/src									# Get into src route , Clone teaching software package 
$	git	clone	https://github.com/DroidAITech/ROS-Academy-for-Beginners.git
  1. Wait for the installation to complete

Installation dependency

install ROS-Academy-for-Beginners The dependence needed

$	cd	~/tutorial_ws
$	rosdep	install	--from-paths	src	--ignore-src	--rosdistro=kinetic	-y

Be careful : The above command is very important , Lack of dependencies will cause the software package to fail to compile and run normally .
Before you start compiling , Need to ensure Gazebo stay 7.0 Above version

$	gazebo	-v		# confirm 7.0 And above 

If your Gazebo Version below 7.0, You need to upgrade

$	sudo	sh	-c	'echo	"deb	http://packages.osrfoundation.org/gazebo/ubuntu-stable	`lsb_release	-cs`	main"	>	/etc/apt/sources.list.d/gazebo-stable.list'
$	wget	http://packages.osrfoundation.org/gazebo.key	-O	-	|	sudo	apt-key	add	-
$	sudo	apt-get	update
$	sudo	apt-get	install	gazebo7

compile

Then go back to catkin_ws Compile below

$	cd	~/tutorial_ws
$	catkin_make
$	source	~/tutorial_ws/devel/setup.bash			# Refresh the environment 	 Method 1 
$	rospack	profile									# Refresh the environment 	 Method 2 

Be careful :source command , After compiling, you must refresh the environment of the workspace , Otherwise, you may not find a workspace . Many times we can run the compiled in the workspace in order to open the terminal ROS Program , Usually put source ~/tutorial_ws/devel/setup.bash The command is appended to ~/.bashrc In file , So every time you turn on the terminal , The system will refresh the workspace environment . Can pass echo "source~/tutorial_ws/devel/setup.bash" >> ~/.bashrc Command to append .

Run the simulation program

After compiling, you can run the simulation , Input

$	rospack	profile
$	roslaunch	robot_sim_demo	robot_spawn.launch

You will see the simulation screen start , The simulation interface includes software Museum and Xbot Robot models .

 Insert picture description here You can drag around , You can zoom in and see the details The aerial view is as follows : Insert picture description here

Open a new terminal , Enter the following command , Use the keyboard to control the robot to move

$   source ~/tutorial_ws/devel/setup.bash
$	rosrun	robot_sim_demo	robot_keyboard_teleop.py

Focus control program window , Press down i、j、l Wait for the button , So you can control the movement of the robot through the keyboard .

 Insert picture description here
This is the end of the experience !( So this is the big man's world )
I really want to learn after taking a bus ROS 了 !

Possible problems

I'm opening gazebo When the door cannot be opened , Stuck in "Preparing your world"

Solution :

1. upgrade gazebo( ditto )

$	sudo	sh	-c	'echo	"deb	http://packages.osrfoundation.org/gazebo/ubuntu-stable	`lsb_release	-cs`	main"	>	/etc/apt/sources.list.d/gazebo-stable.list'
$	wget	http://packages.osrfoundation.org/gazebo.key	-O	-	|	sudo	apt-key	add	-
$	sudo	apt-get	update
$	sudo	apt-get	install	gazebo7

2.model The library cannot be opened due to incorrect loading , Then download all models to... Under the user's root directory .gazebo/models

$ 	cd ~/.gazebo/
$ 	mkdir -p models
$ 	cd ~/.gazebo/models/
$ 	wget http://file.ncnynl.com/ros/gazebo_models.txt
$ 	wget -i gazebo_models.txt
$ 	ls model.tar.g* | xargs -n1 tar xzvf

版权声明
本文为[Why is it so difficult to name?]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210609243534.html