User Tools

Site Tools


operating_drc-hubo_inside_the_simulator

Operating DRC-Hubo inside the Simulator

Author:Keitaro Nishimrua E-mail:katnimura@gmail.com
Date Last Edited:08/15/16
Keywords: Gazebo, PODO, ROS, R-viz

How to use this tutorial


This tutorial will take the user through how to use the PODOGUI together with Gazebo to simulate real world use of the DRC-hubo robot. For certain movements the usage of ROS will be needed. The reader is expected to have already gone through the previous tutorials and be comfortable using terminal and ROS. This tutorial will follow this flow:


This tutorial will take the reader between 3-4hrs. The operating with ROS section will take the longest time. I expect it to take by itself 2hrs.

How to open simulators with DRC-Hubo model and GUI


1. Open a new terminal and run:


roscore




2. Open a new terminal and run:


cd ~/catkin_ws/src/drc_hubo/podo/Execute\ Daemon/


then run:


./PODOLauncher




3. Once the PODOLauncher is open make sure that the Daemon.exe file is from the drc_hubo folder and that gazebo and use ROS are selected. Then click Start Daemon.

4. Open a new terminal and run the following commands:


roslaunch drc_podo_connector drc_hubo.launch


This will run both R-viz and gazebo at the same time.

5. Open qt and find the session you used for the PODOGUI and ALPrograms from inside the drc-hubo folder. Run the PODOGUI and connect it to Daemon.

6. Once inside the tab you will notice that there are 5 different sections. Tutorial, Pose Change, Head Control, Wheel Control, and Object Picking.

PODOGUI

I will take you through what some of these buttons do and what to expect when you press them. I will go over these sections in this order:

  • Tutorial
  • Pose Change
  • Wheel Control
  • Head Control
Tutorial

This is just a test button that you can use confirm if the GUI and simulators are connected. It will turn the waist to the right a little.

Open the module tab and double click the ALTutorial AL to turn it on.

The 'test' button in the Tutorial frame.

3. You should now see the model in both rviz and gazebo move to it's final position.

Pose Change

These are a set of buttons that will move the model into pre-set poses.
Open the module tab and double click both the WalkReady and OmniWheel ALs to turn them on. Then double click the ALTutorial AL to turn it off. If you have trouble turning and AL on or off close the GUI and re-run it from qt.

The Home Pos button to return the model to it's original position after the test movement. This is also the position that the model uses when uploaded into the simulators.

The Walk Ready button. This will put the model into it's initial walking position.

The To Wheel button. This will put the model into it's wheel mode and be able to roll around using the wheels on it's legs.

The To Walk button. This will bring the model back to it's walk ready position.

Please put the model into walk ready before going into wheel mode. If you don't the arms will hit the ground and possible break the model in rviz.

Wheel Control

I will only talk about the bottom part of this frame. I will explain the ROS Mode and AL Mode buttons in the next section. For now ROS Mode turn on ROS mode and AL Mode turns off ROS mode.
If you haven't already turn on the OmniWheel AL.

The x, y, z, and angle inputs are what tells the model how far it needs to move. In this tutorial we will only use x and angle. If you put .5 into the x input and -25 into the angle input and click Goto Point the model will move .5m forward then turn 25 units to the right. The angle input is not in degrees or radians so please play around with different inputs to see for yourself. Also the model will always move forward first then turn, so if you want to turn the model first you will need to command it to only turn first then move.

When doing more than one movement you will have to keep an eye on the daemon terminal. Only after it is done processing one movement can you start the next one.

Head Control


This frame allows you to scan the area in front of the model and also to move a camera to a specified position.

The Scan button scans the area in front of the model using the laser scanner on it's head. The inputs on the left give you the freedom to choose from what angle to what angle you want to scan and how for how long.

The GO TO button allows you to move the camera on the models head to a specific angle.

Using ROS together with the GUI and simulators

In this section I will teach the reader how to use ROS together with PODO to control the model inside the simulators. This will not be an extensive tutorial and the reader is advised to learn further. I will go over two specific implementations:

The reader is expected to be comfortable with terminal and ROS.

Using a game controller to control the DRC-Hubo model in wheel mode

As I stated in the Wheel Control part of the earlier section we will be using the ROS Mode and AL Mode buttons in this section.
We are going to use a Linux compatible game controller(like the one shown below) and use the left joystick to move the DRC-Hubo model through the structure that it launches in. The controller connects via-usb so keep a usb port open for it. I will not go in-depth into the code so please read the documentation. We will be using the ROS-Joy package to accomplish this task.

-Please note for the second tutorial (as of 08/08/16) the code isn't up to date and will not work on any distro past Indigo. But the explanation of the code is still correct. Note that the tutorial uses rosbuild instead of catkin. Compare the explanations to this code instead.
img_20160808_110839.jpg
This will be split up into two parts:

  • Configuring the Controller and Joy
  • Implementing Joy with PODO
  • How PODO works with ROS-Joy
Configuring the Controller and Joy

1. Open a new terminal and install the ROS-Joy package:


sudo apt-get install ros-<YOUR DISTRO>-joy




2. Now connect your controller to your computer and run the command:


ls /dev/input/


A list of all the input devices on your computer will show up. Look for the jsX input (X stands for an arbitrary number). This is your joystick.

3. Use the following command to confirm that the joystick is working:


sudo jstest /dev/input/jsX


You should see the input values change as you move the joysticks around and press buttons.

4. Now that you have confirmed that the controller works use this command to check the permissions of the joystick:


ls -l /dev/input/jsX




If you see rw where the red box is then it is configured properly. If not run the following command to change the permission:


sudo chmod a+rw /dev/input/jsX




Now open a new terminal and run:


roscore



5. Now we need to tell the joy node where to look for the joystick. The default setting is js0 so if your joystick is already js0 you don't have to do this step but doing it won't hurt. Run the command to tell the node where to look:


rosparam set joy_node “/dev/input/jsX”



6. Now run these commands to check that the node and the joystick are properly communicating:


rosrun joy joy_node




Then in a new terminal:


rostopic echo joy


You should see the output of joy change as you play with the controller. Note: you won't see anything in the terminal until you start playing with the controller.

Implementing Joy with PODO

1. Open a new terminal and create a new package inside your ROS workspace. First:


cd ~/catkin_ws/src


then:


catkin_create_pkg hubo_joy roscpp joy



2. Now create a cpp file inside the src folder of your new package.


gedit hubo_joy/src/hubo_teleop.cpp


and copy the following code into it:

#include <ros/ros.h>
#include <geometry_msgs/Twist.h>
#include <sensor_msgs/Joy.h>
 
 
class TeleopHubo
{
public:
  TeleopHubo();
 
private:
  void joyCallback(const sensor_msgs::Joy::ConstPtr& joy);
 
  ros::NodeHandle nh_;
 
  int linear_, angular_;
  double l_scale_, a_scale_;
  ros::Publisher vel_pub_;
  ros::Subscriber joy_sub_;
 
};
 
 
TeleopHubo::TeleopHubo():
  linear_(1),
  angular_(2)
{
 
  nh_.param("axis_linear", linear_, linear_);
  nh_.param("axis_angular", angular_, angular_);
  nh_.param("scale_angular", a_scale_, a_scale_);
  nh_.param("scale_linear", l_scale_, l_scale_);
 
 
  vel_pub_ = nh_.advertise<geometry_msgs::Twist>("/cmd_vel", 1);
 
 
  joy_sub_ = nh_.subscribe<sensor_msgs::Joy>("joy", 10, &TeleopHubo::joyCallback, this);
 
}
 
void TeleopHubo::joyCallback(const sensor_msgs::Joy::ConstPtr& joy)
{
  geometry_msgs::Twist twist;
  twist.linear.x = l_scale_*joy->axes[linear_];
  twist.angular.z = a_scale_*joy->axes[angular_];
  vel_pub_.publish(twist);
}
 
 
int main(int argc, char** argv)
{
  ros::init(argc, argv, "teleop_hubo");
  TeleopHubo teleop_hubo;
 
  ros::spin();
}

The second ROS-joy tutorial will go over this code. Please refer to that for more information.
6. Now open the CMakeLists.txt file inside your package using gedit:


gedit [Path to your package]/CMakeLists.txt


Once open you will need to find the


CATKIN_DEPENDS roscpp joy


line and uncomment it by deleting the '#' in front of it.

Then add these two lines at the very end:

add_executable(hubo_teleop src/hubo_teleop.cpp)
target_link_libraries(hubo_teleop ${catkin_LIBRARIES})



7. Now go to your workspace:


cd ~/catkin_ws


and run:


catkin_make



8. Now create a new launch folder and file. First the folder:


mkdir [path to hubo_joy]/launch


Then the file:


gedit [path to hubo_joy]/launch/hubo_joy.launch


Once opened copy this code into it:

<launch>
 
 <!-- joy node -->
  <node respawn="true" pkg="joy"
        type="joy_node" name="hubo_joy" >
    <param name="dev" type="string" value="/dev/input/js0" />
    <param name="deadzone" value="0.1" />
  </node>
 
 <!-- Axes -->
  <param name="axis_linear" value="1" type="int"/>
  <param name="axis_angular" value="0" type="int"/>
  <param name="scale_linear" value="1.0" type="double"/>
  <param name="scale_angular" value="1.0" type="double"/>
 
  <node pkg="hubo_joy" type="hubo_teleop" name="teleop"/>
 
</launch>

Note: Inside the joy node the value is set to jsX. Please make sure that it is the correct jsX.
–The deadzone value in the joy node section is how far you need to change the input controller value before the model actually moves.
–The values in the Axes section are all variable. The axis_linear/angular are what controller input it looks for. The values are the same as those you was when you used rostopic echo joy.
–The Scale values in the Axes section is how the code scales the controller input to the movement of the model. A larger scale value mean quicker movement, and lower value means slower.

9. Now open a new terminal and start the PODOLauncher to start Daemon. Launch the DRC-model in rviz and gazebo and open qt to run the PODOGUI.

10. Once the gui is open connect it to Daemon and start the walk ready and omniwheel als. Go to the tutorial tab and click ROS Mode in the wheel control frame. You should see the message OMNIWHEEL ROS…!!! in Deamon three times.

11. Now you will be able to move the model using the joystick. The default is set to the left joystick forwards and back make the model move forwards and back while left and right will rotate the model left and right.

Here is a video of me opening all the needed software and code to control the model using the controller.
Note: I didn't know that it was recording sound from my microphone as well so please mute the sound when playing.


This is a separete page that I made for those who are interested in the PODO side of the code. The explanation is based off of the controller example you just finished. Again this is a short explanation but will hopefully help you understand better what is happening.
How PODO Works with ROS-Joy

Simple navigation of DRC-Hubo in wheel mode

In this section we will use pre-prepaired code already inside the drc-hubo file. This section will take you through the various packages and stacks that you will need to download to get these files to work. I will also add videos at the end showing what you should see with the code running properly.
There are two sets of code I will explain:

  • drc_slam
  • drc_navi

==drc_slam==

As the name suggests this code will create start slam (Simultanious Locolization and Mapping) using DRC-Hubo's lidar. This code will allow the user to explore the simulated environment with the controller, relying on data retried from the lidar. This code however will not allow autonomous navigation inside the simulator. Instead this code will use the ros-joy code used in the the previous example.

Package installation

If you go into the launch file inside the drc_slam folder you will see the packages that the code needs to work.
You will notice that there are three packages needed. The twist-teleop-joy pkg, the gmapping pkg, and the rviz pkg.

twist-teleop-joy
We have a substitute for the twist-teleop-joy pkg, the joy pkg. Go into the launch file and change the launch path to open the hubo_joy.launch file created in the previous example. Change to code:

<include file="$(find teleop_twist_joy)/launch/teleop.launch"/>

into:

<include file="$(find hubo_joy)/launch/hubo_joy.launch"/>



gmapping
You will need to download the gmapping pkg. If you are interested this is the documentation on the package.
1. First move into the src folder of your workspace


cd ~/catkin_ws/src



2. Then download the stack from github and clone there.


sudo git clone -b hydro-devel https://github.com/ros-perception/slam_gmapping.git




3. Move back to the workspace:


cd ..


then make it:


catkin_make



4. If you do not recieve any errors while making you have successfully downloaded the package. However if you did get some error please go through the error message to figure it out.

rviz
You already have the rviz pkg as it came with the ROS installation.

Operation of drs_slam

1. Run the PODOLauncher from the podo folder in drc_hubo.


cd ~/catkin_ws/src/drc_hubo/podo/Execute\ Daemon


then:


./PODOLauncher




2. Run roscore and roslaunch the hubo silmulators.


roscore
roslaunch drc_podo_connector drc_hubo.launch




3. Run the GUI from qt

4. Turn on the walkready and omniwheel ALs and get the model into walk ready → wheel mode. Once the model has finished changing to wheel mode turn on ROS Mode for wheel control.

5. Now launch the drc_slam code


roslaunch drc_slam slam.launch


6. You can now see that the rviz window used by the simulator launch closes and opens again showing the slam created by the code and the lidar information from gazebo. As you move around the map using the controller the slam will create new features as the lidar hits new terrain.

NOTE: The code will not work if the hubo simulator is not already open and the head is at 0 degrees. If the you moved the head position before opening the drc_slam code put it back to 0 degrees using the goto button.


==drc_navi==

Similar to drc_slam if you take a look at the launch file for drc_navi you can see the needed packages needed for this code. The packages in this case being the map_server pkg, amcl pkg, move_base pkg, and rviz pkg.

Package Installation

map_server, amcl, move_base
map_server, amcl, and move_base are all packages that come with the navigation stack. You will need to download this stack and the dependencies needed to catkin_make it.
1. cd into your workspace src folder and download the navigation stack


cd ~/catkin_ws/src
git clone -b jade-devel https://github.com/ros-planning/navigation.git




Open the navigation stack folder and you will the various packages that the stack comes with.

2. You will need to go into each of the CMakeLists.txt files and change all instances of eigen to eigen3. It doesn't matter if eigen is capitalized or not. You will need to do this for all packages except for :

  • amcl
  • fake_localization
  • global_planner
  • map_server
  • nav_core
  • navigation
  • robot_pose_ekf
  • voxel_grid



Now you need to download/install other dependencies because if you try to make the navigation stack as it is, it will result in an error.

3. Open the Synaptic Package Manager find the libsdl-image1.2-dev and install it along with all of its dependencies. Once installed close the manager.

4. In a new terminal install the bfl and move_base_msgs packages. However do not install these into the src of the workspace as this will cause the catkin_make to fail.


sudo apt-get install ros-jade-bfl
sudo apt-get instll ros-jade-move-base-msgs



5. Now cd into the workspace and make it.


cd ~/catkin_ws
catkin_make



Operation of drc_navi

1. Run the PODOLauncher from the podo folder in drc_hubo.


cd ~/catkin_ws/src/drc_hubo/podo/Execute\ Daemon


then:


./PODOLauncher




2. Run roscore and roslaunch the hubo silmulators.


roscore
roslaunch drc_podo_connector drc_hubo.launch




3. Run the GUI from qt

4. Turn on the walkready and omniwheel ALs and get the model into walk ready → wheel mode. Once the model has finished changing to wheel mode turn on ROS Mode for wheel control.

5. Now roslaunch the navi code:


roslaunch drc_navi navi.launch



6. You will see the rviz window from the simulator launch code collapse and re-open with the navi map. Now you can take the 2-d navigation arrow to tell the model to move to a specified spot autonomously. However if you have a computer without a lot of computing power keep the distances between 2 points close.

operating_drc-hubo_inside_the_simulator.txt · Last modified: 2017/12/02 08:31 by keitaronishimura