How to configure the environment
If the developer has purchased a platform kit including an industrial computer, the Ubuntu operating system has been installed and the environment required for development has been installed at the factory, and the learning of the primary tutorial can be started directly. If the developer buys the HandsFree platform kit without IPC, then they need to prepare a laptop (or a single-board computer such as Raspberry Pi, TX2, etc.), install the ubuntu operating system, and configure the development of ROS and HandsFree. surroundings. The HandsFree program supports the indigo version of ROS and Kinetic, ubuntu14.04 only supports indigo, ubuntu16.04 only supports kinetic, you can refer to ROS official installation tutorial.
This section describes how to install ROS Kinetic on Ubuntu 16.04 and configure the HandsFree program. The HandsFree team provides a one-click configuration script and a step-by-step installation tutorial for the development environment under the ubuntu operating system for the X86 CPU architecture.
Install ubuntu16 operating system
The first step, developers need to prepare a computer with the ubuntu operating system installed. HandsFree provides a tutorial for installing the ubuntu operating system. (recommended to install ubuntu16.04)
- Install ubuntu operating system on laptop or industrial computer
- Install ubuntu operating system via virtual machine on windows
After installing the operating system, developers can choose according to their needs, one-click installation script or step-by-step installation to configure the development environment. If the one-click installation script cannot be installed normally, you can also choose the step-by-step installation method.
Solve the problem that github files cannot be downloaded due to the hosts problem in mainland China
First let's try to open this link https://raw.githubusercontent.com/HANDS-FREE/handsfree/master/Documentation/auto_install_all_ubuntu16.04.sh
If the following picture appears
We need to open the hosts file with a text editor, (ctrl+alt+t) to open a terminal and enter the following command:
sudo gedit /etc/hosts
Copy the following content into the hosts file, save it, and close the text editor
151.101.76.133 raw.githubusercontent.com
Using automatic installation scripts (for ubuntu16)
If you are a user of the HandsFree platform, after you install the ubuntu system, you can configure the system development environment, install ROS, and install the HandsFree ROS program by running the one-click installation script we provide. Tips: Please note that the version of the system and the script should correspond.
View system version command: cat /etc/os-release
If your system version is ubuntu16.04, install HandsFree kinetic: (recommended to install ubuntu16.04)
cd ~
wget https://raw.githubusercontent.com/HANDS-FREE/handsfree/master/Documentation/auto_install_all_ubuntu16.04.sh
bash auto_install_all_ubuntu16.04.sh
Tips: If the file cannot be downloaded, please follow the previous step Solve the problem that the github file cannot be downloaded due to the hosts problem in mainland China
After the installation script is successfully executed, please skip the "step-by-step installation" in the next section and directly enter the "development environment test" section. After the test is successful, developers can start learning the beginner tutorial. If the installation fails or the test fails, follow the "step-by-step installation" tutorial to reinstall.
Step by step installation (for ubuntu16)
Download Handsfree code
Update software list
sudo apt-get update
This command will visit each URL in the source list, read the software list, and save it on the local computer. Each URL is a source, and the data pointed to by this address identifies which software can be installed and used on the source server. And this source list is the sources.list file, in which directory, will be mentioned later.
Install git
sudo apt-get install -y git
Git is an open source distributed version control system that can handle version management of projects from very small to very large efficiently and at high speed, and our HandsFree code is placed in the git remote repository. By installing git , we can use its related commands to download the code in the remote repository to the local.
Download Handsfree project
mkdir -p ~/handsfree/handsfree_ros_ws/ cd ~/handsfree/handsfree_ros_ws/ git clone https://github.com/HANDS-FREE/handsfree.git src/handsfree/
We need to create a directory to store the files you downloaded from the git remote repository for management and viewing.
We need to enter the created handsfree_ros_ws directory to execute the relevant commands, so that the files can be downloaded to this directory accurately.
Download all the files under https://github.com/HANDS-FREE/handsfree.git to the src directory through the git command. When the download is complete, there will be an extra file in the handsfree_ros_ws directory src directory, which will store the files you downloaded.
You can check if the download is complete by opening the file
Back up the source list sources.list file, you can check whether there is an extra file in the corresponding folder
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
Here, the original sources.list file is copied by the command and named sources.list.backup. You can view the contents through the
gedit /etc/apt/sources.list
command. If you double-click to open it, you will not see the contents.Go to the script directory, make a copy of sourcesubuntu_16_04.list in the directory, and replace the sources.list source list with the source list. You can check whether the content is through
gedit /etc/apt/sources.list
was replacedcd ~/handsfree/handsfree_ros_ws/src/handsfree/Documentation/script sudo cp sources_ubuntu_16_04.list /etc/apt/sources.list
Because the URLs in sources.list are all foreign URLs at first, we can access them, but it will be very slow. Therefore, it is necessary to replace these foreign URLs with domestic URLs.
Update software list
sudo apt-get update
Since we replaced the previous source list with domestic ones, we need to update it again.
Install ROS
Enter the script file and run the ros_kinentic_base.sh script in the terminal. The function of bash is to read the commands in ros_kinentic_base.sh
cd ~/handsfree/handsfree_ros_ws/src/handsfree/Documentation/script bash ros_kinetic_base.sh
ros_kinetic_base.sh This file contains the commands written for installing ROS. In order to facilitate the installation of users, we turn these commands into a script file, and these commands can be executed only by running the script file, and users do not need to input these commands step by step. It is equivalent to our previous automatic installation script. (may need to enter admin password)
After a long wait, we have finally completed the installation, close the terminal, and reopen a terminal to run:
roscore
Keep this terminal ,and open a new terminal and run:
rosrun turtlesim turtlesim_node
If the turtle on the left of the picture below appears, it means that ROS is successfully installed
Installing ROS common packages
Similar to installing ROS, you need to run the ros_kinetic_ext.sh script file on the terminal to install common ROS function packages
cd ~/handsfree/handsfree_ros_ws/src/handsfree/Documentation/script bash ros_kinetic_ext.sh
You will encounter File to patch:
We just need to hit enter, then type y and enter again (repeat 4 times in total)
Install HandsFree ROS package
The source command is usually used to re-execute the just-modified initialization file to take effect immediately, without having to log out and back in.
source ~/.bashrc
Enter the src directory, use the directory as the catkin workspace, and initialize
cd ~/handsfree/handsfree_ros_ws/src catkin_init_workspace
The
catkin_init_workspace
command initializes the current directory as a ROS workspace.Enter handsfree_ros_ws and compile the workspace
cd ~/handsfree/handsfree_ros_ws/ catkin_make
The
catkin_make
command is to compile the workspace. After successful execution, as shown in the figure
Write source ~/handsfree/handsfree_ros_ws/devel/setup.sh to bashrc file
echo "source ~/handsfree/handsfree_ros_ws/devel/setup.sh" >> ~/.bashrc
This command is to add ROS environment variables to the current user
Re-execute the .bashrc file you just modified to take effect immediately without having to log out and back in.
source ~/.bashrc
Set the HandsFree environment variable
Open the user's .bashrc file
gedit ~/.bashrc
shell is a command line interpreter, a shell of the linux kernel, responsible for the interaction between the outside world and the linux kernel. There are many different shell , bash is one of them. And the shell of Ubuntu16.04 is bash.
When you open a terminal, the operating system associates terminal with shell, and when we enter a command in terminal, shell is responsible for interpreting the command.
No matter what kind of shell there will be a hidden file .bashrc, which is equivalent to the shell's configuration file, used to store and load your terminal configuration and environment variables.
Find the environment variable HANDSFREE_ROBOT_MODEL,
stone_v3
is the model of the robot, you need to change this value to the model of your robot, you can choose from the four models of[mimi, stone_v2, stone_v3, giraffe]
.### MODEL type [mini, stone_v2, stone_v3, giraffe] export HANDSFREE_ROBOT_MODEL=stone_v3
Set usb rules
Go to the Documentation directory and run the ros_kinetic_ext.sh script file in the terminal
cd ~/handsfree/handsfree_ros_ws/src/handsfree/Documentation/ bash set_usb_env.sh
This file is used to modify the usb rules for the system, since there are many devices on the robot. If there is no processing on permissions and mapping relationships, these devices will not be able to start normally.
Development environment testing
After successful installation, you can connect to the robot using USB, open a new terminal, and run:
roslaunch handsfree_hw handsfree_hw.launch
If all is well, it will display:
auto-starting new master
process[master]: started with pid [9562]
ROS_MASTER_URI=http://Robot:11311
setting /run_id to ffa41cce-05bd-11e8-8df0-001e64f02337
process[rosout-1]: started with pid [9575]
started core service [/rosout]
process[handsfree_hw_node-2]: started with pid [9585]
process[mobile_base/controller_spawner-3]: started with pid [9589]
process[robot_state_publisher-4]: started with pid [9591]
[ERROR] [1517317423.863958024]: hf link initialized failed, please check the hardware
[INFO] [WallTime: 1517317424.295263] Controller Spawner: Waiting for service controller_manager/load_controller
[INFO] [WallTime: 1517317424.298319] Controller Spawner: Waiting for service controller_manager/switch_controller
[INFO] [WallTime: 1517317424.301498] Controller Spawner: Waiting for service controller_manager/unload_controller
[INFO] [WallTime: 1517317424.304670] Loading controller: joint_state_controller
[INFO] [WallTime: 1517317424.351596] Loading controller: servo1_position_controller
[INFO] [WallTime: 1517317424.399306] Loading controller: servo2_position_controller
[INFO] [WallTime: 1517317424.419282] Loading controller: mobile_base_controller
[INFO] [WallTime: 1517317424.469234] Controller Spawner: Loaded controllers: joint_state_controller, servo1_position_controller, servo2_position_controller, mobile_base_controller
[INFO] [WallTime: 1517317424.479183] Started controllers: joint_state_controller, servo1_position_controller, servo2_position_controller, mobile_base_controller
Open a new terminal and run the following command:
roslaunch handsfree_hw keyboard_teleop.launch
Now you can remotely control the robot to walk. If the robot can be remotely controlled properly, the environment is successfully configured.