42
John Hsu Nate Koenig ROSCon 2012

Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

John HsuNate Koenig

ROSCon 2012

Page 2: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Outline

What is Gazebo, and why should you use it

Overview and architecture

Environment modeling

Robot modeling

Interfaces

Getting Help

Page 3: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Simulation for Robots

Towards accurate physical simulationEasy transition to and from simulationRemove hardware issues and resource constraints

Support common robot control softwareCustom client codeROS interfacePlayer interfaces

Page 4: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Use Cases

Page 5: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Overview & Architecture

Page 6: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

New in 1.0

Separation of physics and visualizationserver: physics and sensor generationclient: visualization and user interface

Socket communicationProtobuf provides message passing

Simplified plugin interfaceControl any aspect of simulation

Simulation Description Format (SDF)XML based format for worlds and models

Page 7: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Architecture

Physics Rendering Interfaces

Rigid BodyDynamics

OpenGL Plugins and IPC

ODEBullet*

OGRE Google ProtobufBoost ASIO

GUIQT

CEGUI

User Interfaces

Page 8: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Architecture

server

client

Run Loop

Physics Update

Sensor Data Generation

Plugins and IPC Update

Page 9: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Environment Modeling

Page 10: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

EnvironmentsSimple

Focused scenarioManipulationPerception

Aerial robotsOutdoor mobile and legged robots

Outdoor

IndoorPath planningMobile manipulationClone real environment

Page 11: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Creating Environments

Built into Gazebo

3D Warehouse or model editor

Image editor

Page 12: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Alignment and sizeMove meshes to origin (0,0,0) when exportingStay consistent with units (preferably metric)

Materials and lightingAmbient and diffuse color properties are importantLighting requires outward facing normalsImprove texture quality before mesh quality

Efficient meshesReduce polygon countUse normal maps for improved lighting

A Word on Meshes

Page 13: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Organizing ResourcesDirectory structure for a project

Meshes: [project_path]/Media/modelsImages: [project_path/]Media/materials/texturesMaterials: [project_path]/Media/materials/scripts

Environment variableexport GAZEBO_RESOURCE_PATH=[project_path]

APIgazebo::SystemPaths::AddGazeboPaths(string);

Page 14: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Efficient Environments

Static ModelsNot dynamically simulatedAct only as collision objectsStatic models can be animated

Reduce JointsCreate models using composite links

Page 15: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Add Visual Realism

LightingLimit number of lights, and reduce ambient lightUse directional lights for shadowsDesired effects requires parameter tuning

Custom shadersCreate and load vertex and pixel shader via material scripts

Sky and fogAdd any material to a sky domeFog can add a horizon and add sense of distance

Page 16: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Robot Modeling

Page 17: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

A collection of links, joints, sensors, actuators and plugins.

Link 2

What is a Robot (Model)?

Link 1

Link 3

Sensor

X

Y

X

Y

Model

J1X

Y

XY

J2g

Page 18: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Example: Mass Spring System

Simple mass spring system in Gazebo:

Page 19: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Example: SCARA Arm

Simplified arm model

Page 20: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Robot Models

Simple platformsBuilt-in shapesMesh skinning

Realistic physical properties

Meshes as collision objectsMass and inertia propertiesSurface friction6 joint types

Full sensor suiteLaser range findersMono/Stereo camerasKinectContactJoint force/torques

Page 21: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Why 3D Dynamics Simulator

Dynamics simulation"Looks right" interactive mechanical behaviorsNon-interactive higher fidelity dynamics

Visual simulation3D image, range, depth sensor generation

Closing the loop between visual and dynamics simulation.

Page 22: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

What to Expect (Dynamics)

MotionNewton-Euler equations.First order time integrator.

ConstraintsFrictionless joints.

CollisionPerfectly inelastic collision*.

ContactFriction pyramid.

Page 23: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Modeling: URDF and SDF

How to specify a robot modelURDF format and SDF format

URDF vs SDF

URDF --> SDF convertersrosrun urdf2model -f <urdf> -o <sdf>

Contributing robot modelsSoon to be released online model database

URDF SDF

● Tree● Link --> Link transforms● Link and Joint + "Extensions"

● Graph● Model --> Link transforms● Link, Joint, Sensors, Plugins,

Lights, Physics, Scene.

Page 24: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

What are Links

Inertial (mass, moment of inertia)The "M" in f=Ma for physics engines

Collision (geometry)Used by collision engine to generate contact joints for the physics engine

Visual (geometry)Used by render engine to generate images for GUI and camera or depth sensors

Page 25: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Joints

User defined joints

Dynamically createdContact joints between objects

Created from colliding collision geometriesLimited to 20 contacts for each colliding pair by defaultContact information accessible through Contact Sensor

Type DOF

universalball

screw

2 rotational3 rotational

1 trans. 1 rot.

Type DOF

revoluteprismaticrevolute2

1 rotational1 translational

2 rotational

Page 26: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Sensors

CameraRender to offscreen buffer

KinectDepth camera

LaserCPU and GPU based ray casting

ContactGenerated by collision engine

RFIDInformation generated from model positions

Force torqueSpecific to joints at the moment

Page 27: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Efficient Robot Models

Physics (CPU):Limit contacts (<physics max_contacts="3"/>)Kinematic trees are better than loopsReduce number of joints in a model

Collision (CPU):Primitives are more efficient than trimeshesLimit collision mesh size (< ~5k triangles per link)

Rendering (GPU):Limit visual mesh size (< ~5k triangles per link)Limit image/depth sensor resolution or rate

Page 28: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

How to Improve Dynamics Accuracy

...with maximal (Cartesian) coordinate solvers such as ODE or Bullet.

How to choose time step size:Motor controller frequency driven.First order Euler time stepping O(Δt).

How to tweak solver parameters:<solver type="quick" iters="100"/>Default 10 iterations for LCP solve, increase if necessary.

Model physics of the real robot more closelyAccount for more details. E.g. prismatic vs. screw.

Page 29: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Controlling the Robot Model

Graphical joint control widget in GazeboDirect force control.PID position and velocity.

Programmatic controlLevel of abstraction, hardware/software transparency.World plugins: access to all models.Model plugins: access to all joints and links.

Page 30: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Troubleshooting Models

Mesh is out of place or has improper scaleRecenter and scale mesh using 3D modeling applicationEnable "Show Collisions" in GUI to debug

Improper joint placement and rotationEnable "Show Joints" in GUI to debug

Improper inertial values

Page 31: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Symptom: Model flies away, spins out of control Cause: Interpenetration with surroundingsSolution: Step through simulation slowly. Check for collisions, interpenetrations between model/ground. Spawn model away from other objects.

Troubleshooting Models

Page 32: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Troubleshooting Models

Symptom: Model spins out of control Cause: Large accelerations (f >> m)Solution: Remove forces, e.g. disable plugins that sets forces on joints or links, and see if problem goes away Look for tiny inertia values.

Page 33: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Troubleshooting Models

Symptom: Model is jitteryCause: Stiff system. Large mass ratio between connected linksSolution: Reduce time step size or increase inner iteration counts

Page 34: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Interfaces

Page 35: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Plugins

Programmatic interface to GazeboTypes

System: Control the load and init processWorld: All models and physics engineModel: Joints and linksSensor: Control data generation and processing

Use casesSystem: Specify custom search pathsWorld: Dynamically change physics engineModel: Joint controller, such as a differential driveSensor: Data filtering or add noise models

Page 36: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Creating Plugins

ReferenceGazebo wiki tutorials and API specificationExamples distributed with the gazebo sources

ROS pluginsGazebo ROS package provides interface between Gazebo and ROS frameworkgazebo_plugins ROS package

Contribute pluginsSubmit patches to GazeboNear future: Online database for plugins

Page 37: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Interprocess Communication

TopicsUsage nearly identical to ROS

PublisherPtr pub = node->Advertise<msg_type>(topic_name);SubscriberPtr sub = node->Subscribe(topic_name, callback);

Topics vs pluginsTopics: Run server remotely, start & stop clientPlugins: Access to complete API, updates every cycle

Page 38: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Commandline Tools

Gazebo toolsSystem inspection: gztopic, gzstatsInsert and remove models: gzfactory

ROS toolsrosrun gazebo spawn_modelrosrun gazebo urdf2model

Page 39: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Getting Help

ROS Answersanswers.ros.org

Gazebo mailing listgazebosim.org/support.html

Wiki and Tutorialsgazebosim.org/wiki

Contributing codeSubmit patches (kforge.ros.org/gazebo/trac)Send email to mailing list for suggestions

Page 40: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Questions

Page 41: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Differential DriveControls two joints attached to a chassis and wheelsAccepts velocity commands, produce joint torquesExample usage: Pioneer2dx mobile base

ROS PR2 Controllergazebo_ros_controller_manager ROS pluginMimics the real PR2 motors at transmission levelAllows code developed in simulation run on a real PR2

Plugin Examples

Page 42: Nate Koenig John Hsugazebosim.org/assets/gazebo_roscon_2012-edc898dbe... · Example: SCARA Arm Simplified arm model. Robot Models Simple platforms Built-in shapes Mesh skinning Realistic

Topic Examples

Graphical InterfaceAll communication between the server and client is handled via topics

Player InterfacePlugins are loaded into Player which then communicate to Gazebo via Topics

Command line toolsReport statistics and offer basic world control functionality