Lecture VI: Constraints and Controllers. Parts Based on Erin Catto s Box2D Tutorial

Similar documents
Lecture VI: Constraints and Controllers

ROBOTICS 01PEEQW. Basilio Bona DAUIN Politecnico di Torino

A simple example. Assume we want to find the change in the rotation angles to get the end effector to G. Effect of changing s

Motion Capture & Simulation

Chapter 4. Mechanism Design and Analysis

Table of Contents. Chapter 1. Modeling and Identification of Serial Robots... 1 Wisama KHALIL and Etienne DOMBRE

Simulation in Computer Graphics. Deformable Objects. Matthias Teschner. Computer Science Department University of Freiburg

10/11/07 1. Motion Control (wheeled robots) Representing Robot Position ( ) ( ) [ ] T

Last Time? Inverse Kinematics. Today. Keyframing. Physically-Based Animation. Procedural Animation

Articulated Characters

Written exams of Robotics 2

Last Time? Animation, Motion Capture, & Inverse Kinematics. Today. Keyframing. Physically-Based Animation. Procedural Animation

CMPUT 412 Motion Control Wheeled robots. Csaba Szepesvári University of Alberta

Lesson 1: Introduction to Pro/MECHANICA Motion

Model Library Mechanics

1. Introduction 1 2. Mathematical Representation of Robots

Applications. Human and animal motion Robotics control Hair Plants Molecular motion

Animation Lecture 10 Slide Fall 2003

Last Time? Animation, Motion Capture, & Inverse Kinematics. Today. Keyframing. Physically-Based Animation. Procedural Animation

1 Trajectories. Class Notes, Trajectory Planning, COMS4733. Figure 1: Robot control system.

COPYRIGHTED MATERIAL INTRODUCTION CHAPTER 1

Lecture Note 2: Configuration Space

Connection Elements and Connection Library

Chapter 1 Introduction

What Is SimMechanics?

ME 115(b): Final Exam, Spring

INTRODUCTION CHAPTER 1

Chapter 3: Kinematics Locomotion. Ross Hatton and Howie Choset

Flexible Modeling and Simulation Architecture for Haptic Control of Maritime Cranes and Robotic Arms

Computer Animation Fundamentals. Animation Methods Keyframing Interpolation Kinematics Inverse Kinematics

DYNAMICS FOR ANIMATION. Rémi Ronfard, Animation, M2R MOSIG

Serial Manipulator Statics. Robotics. Serial Manipulator Statics. Vladimír Smutný

Motion Control (wheeled robots)

CS 775: Advanced Computer Graphics. Lecture 3 : Kinematics

Modelling of mechanical system CREATING OF KINEMATIC CHAINS

John Hsu Nate Koenig ROSCon 2012

Anatomy of a Physics Engine. Erwin Coumans

Optimal motion trajectories. Physically based motion transformation. Realistic character animation with control. Highly dynamic motion

10/25/2018. Robotics and automation. Dr. Ibrahim Al-Naimi. Chapter two. Introduction To Robot Manipulators

Introduction to Multi-body Dynamics

CS545 Contents IX. Inverse Kinematics. Reading Assignment for Next Class. Analytical Methods Iterative (Differential) Methods

Jacobian: Velocities and Static Forces 1/4

Example 24 Spring-back

Simulation. x i. x i+1. degrees of freedom equations of motion. Newtonian laws gravity. ground contact forces

Chapter 19- Object Physics

Optimization of a two-link Robotic Manipulator

Structure and Synthesis of Robot Motion

Jacobian: Velocities and Static Forces 1/4

SAMPLE STUDY MATERIAL. Mechanical Engineering. Postal Correspondence Course. Theory of Machines. GATE, IES & PSUs

Unit 2: Locomotion Kinematics of Wheeled Robots: Part 3

Design of a dynamic simulation system for VR applications

Fundamentals of Computer Animation

ME451 Kinematics and Dynamics of Machine Systems

Chapter 4: Kinematics of Rigid Bodies

Kinematics Fundamentals CREATING OF KINEMATIC CHAINS

MEM380 Applied Autonomous Robots Winter Robot Kinematics

2.7 Cloth Animation. Jacobs University Visualization and Computer Graphics Lab : Advanced Graphics - Chapter 2 123

DESIGN AND MODELLING OF A 4DOF PAINTING ROBOT

This week. CENG 732 Computer Animation. Warping an Object. Warping an Object. 2D Grid Deformation. Warping an Object.

INSTITUTE OF AERONAUTICAL ENGINEERING

7 Modelling and Animating Human Figures. Chapter 7. Modelling and Animating Human Figures. Department of Computer Science and Engineering 7-1

LECTURE 13: SOLUTION METHODS FOR CONSTRAINED OPTIMIZATION. 1. Primal approach 2. Penalty and barrier methods 3. Dual approach 4. Primal-dual approach

ROSE-HULMAN INSTITUTE OF TECHNOLOGY

Animation. Keyframe animation. CS4620/5620: Lecture 30. Rigid motion: the simplest deformation. Controlling shape for animation

Analytical and Applied Kinematics

SimWise. 3D Dynamic Motion, and Stress Analysis. integrated with Alibre Design

Computer Animation and Visualisation. Lecture 3. Motion capture and physically-based animation of characters

Quick Start Training Guide

Virtual Marionettes: A System and Paradigm for Real-Time 3D Animation

Announcements. CS 188: Artificial Intelligence Fall Robot motion planning! Today. Robotics Tasks. Mobile Robots

CS 188: Artificial Intelligence Fall Announcements

Homework 2 Questions? Animation, Motion Capture, & Inverse Kinematics. Velocity Interpolation. Handing Free Surface with MAC

Local Search Methods. CS 188: Artificial Intelligence Fall Announcements. Hill Climbing. Hill Climbing Diagram. Today

CS 231. Control for articulate rigid-body dynamic simulation. Articulated rigid-body dynamics

Animations in Creo 3.0

Chapter 4 Dynamics. Part Constrained Kinematics and Dynamics. Mobile Robotics - Prof Alonzo Kelly, CMU RI

Basilio Bona ROBOTICA 03CFIOR 1

Kinematics of Machines. Brown Hills College of Engineering & Technology

Kinematics of Machines Prof. A. K. Mallik Department of Mechanical Engineering Indian Institute of Technology, Kanpur. Module 10 Lecture 1

Kinematics of Machines Prof. A. K. Mallik Department of Mechanical Engineering Indian Institute of Technology, Kanpur. Module - 2 Lecture - 1

Theory of Machines Course # 1

Lecture 18 Kinematic Chains

Parallel Robots. Mechanics and Control H AMID D. TAG HI RAD. CRC Press. Taylor & Francis Group. Taylor & Francis Croup, Boca Raton London NewYoric

11. Kinematic models of contact Mechanics of Manipulation

Multibody Dynamics Module

ÉCOLE POLYTECHNIQUE DE MONTRÉAL

Module 1 Lecture Notes 2. Optimization Problem and Model Formulation

Kinematics. Kinematics analyzes the geometry of a manipulator, robot or machine motion. The essential concept is a position.

Rachel Weinstein, Joseph Teran and Ron Fedkiw

Using MSC.Nastran for Explicit FEM Simulations

Controlling Reactive, Motion Capture-driven Simulated Characters

KINEMATICS FOR ANIMATION. Rémi Ronfard, Animation, M2R MOSIG

Animation. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 4/23/07 1

A Simplified Vehicle and Driver Model for Vehicle Systems Development

MCE/EEC 647/747: Robot Dynamics and Control. Lecture 1: Introduction

Multibody dynamics and numerical modelling of muscles LORENZO GRASSI

CALCULATING TRANSFORMATIONS OF KINEMATIC CHAINS USING HOMOGENEOUS COORDINATES

SimWise 4D. Integrated Motion and Stress Analysis

Recent developments in simulation, optimization and control of flexible multibody systems

T6: Position-Based Simulation Methods in Computer Graphics. Jan Bender Miles Macklin Matthias Müller

Transcription:

Lecture VI: Constraints and Controllers Parts Based on Erin Catto s Box2D Tutorial

Motion Constraints In practice, no rigid body is free to move around on its own. Movement is constrained: wheels on a chair human body parts trigger of a gun opening door actually almost anything you can think of in a game... http://static4.gamespot.com/uploads/scale_medium/mig/2/4/7/7/2282477-garrys_13231_screen.jpg http://i2.cdn.turner.com/cnnnext/dam/assets/14081 3101135-best-biking-cities-utrecht-horizontal-largegallery.jpg 2

Degrees of Freedom Description of allowed movement by specifying degrees of freedom (DOF) Translational (3 DOF max) Rotational (3 DOF max) 3

Kinematic Pair Kinematic pair: connection between two bodies that imposes constraints on their relative movement. Lower pair: constraint on a point, line or plane Revolute pair, or hinged joint: 1 rotational DOF. Prismatic joint, or slider: 1 translational DOF. Screw pair: 1 coordinated rotation/translation DOF. Cylindrical pair: 1 translational + 1 rotational DOF. Spherical pair, or ball-and-socket joint: 3 rotational DOF. Planar pair: 3 translational DOF. Higher pair: constraint on a curve or surface. 4

Constraints Resolution Energy of components on constrained d.o.f. can be lost. Converted into heat and sound (! " ) As opposed to putting pressure on the joint, causing degradation. Project net force on the unconstrained degrees of freedom. Not true for soft bodies! Deforming accordingly (Lagrangian) Approximation: no loss of energy. https://www.youtube.com/watch?v=t_zb0jviw68 5

Constrained Game-Engine Loop Previous state: & $, (($) ) $, *($) Forces "($) Integrate velocities and positions Resolve Interpenetrations Per-body change & $ + $, (($ + $) ) $ + $, -($ + $) Position correction Resolve Constraints and Collisions Velocity correction

Constraint Representation Often with an implicit function! ", ", " = 0. Example: position constraint on a curve:! ', ( = 0 Constraints dependent only on position are called holonomic. Equality constraints:! ", ", " = 0 Inequality constraints:! ", ", " 0 Examples? 7

Differential Equality Constraints Our purpose: Move from "($) to "($ + $) and conserve: ( "($) = ( "($ + $) = 0 Algebraic interpretation: the following are conserved: ( "($) = 0 (position),-,. = 0 (constraint velocity), 0 -/,. 0 = 0 (constraint acceleration) Because function should be constant 0! ( " = " 2 8

+ &, &, & = 0 Velocity Constraint Chain rule (single constraint, single bodies):!"!# = %" %& '!&!# = %" %& ' ) = 0 Multiple constraints, multiple bodies: + = ",, " /, 0 = &,, & 1 We get the Jacobian J / 1 = 45 6 47 8 Kinematic velocity constraint: J ) = 0 9

& ', ', ' = 0 Velocity Constraint J # = 0 means # is in the right null space of J Dimension of null space ó degrees of valid movement. Full rank of J è null space empty è no allowed movement! Physical example: move on two curves at the same time. How do we adhere to allowed velocity all the time? 10

>?,?,? = 0 Acceleration constraint:!" # =!&!$ "!$ Net external force: -.. Mass matrix: Acceleration Constraint ( + * + = 0 / 01201 = 34+5(/ 7, / 7, / 7,, / 1, / 1, / 1 ) To obey the constraint, we need to assume a virtual force - ;. Dynamic force equation: 3* 3< ( + */=7 -. + - ; = 0 11

The Constraint Force The constraint force diverts free (unconstrained) movement to valid movement. Geometric intuition: constraint force kills invalid movement and nothing else. Principle of virtual work:! " does no work on $. Motivation: (energy-wise) lossless constraint. Also: since it never causes illegal movement! Where have we seen this? 12

The Constraint Force Principle of virtual work:! " # % = 0. We have that J % = 0. è! " is spanned by the rows of J:! " = ) + * J(I,. ) = 1 2 + + : Lagrange Multiplier. * How do we get + in order to compute! "? 13

1 3 = ) 4 5 Direct Solution To get :!" #!$" = 0, we need to solve for the Lagrange Multiplier: () (*, + )./0 1 2 + 1 3 = () (*, + )./0 1 2 + ) 4 5 We get: ). /0 ) 4 5 = () (*, + )./0 1 2 Disadvantages: Square 8 8 matrix Expensive linear solve ),!6 change at each point 7!!$ Might need complicated derivatives:!6.!$ Discrete integration combined with this will make an inexact solution. 14

Alternative: Sequential impulses Previously: working with forces to get valid acceleration. Now: working with impulses to get valid velocity. Sequential impulses (SI) Applying impulses at each constraint iteratively to correct velocity. Quite stable and converges to a global solution. Pro: Easier friction and collision handling. Velocity rather than acceleration. In a time step, impulse ó force. Con: velocity constraints are not precise è might produce position drift è breaking the constraint. l 1 l 2 l 3 m 2 m 1 m 3 15

Sequential impulses Step 1 Integrate applied forces, yielding to tentative velocities Step 2 Apply impulses sequentially for all constraints to correct the velocity errors Step 3 Use the new velocities to update the positions http://allenchou.net/wpcontent/uploads/2013/12/contacts-figure.png 16

Computing the Impulses A single constraint! currently has " # $ 0. " # - row vector, normal to constraint at closest point. Change velocity by Δ$ to get " # $ + Δ$ = 0. + # = - -. - /0 12. For infinitesimal time step: + # / 0 è + # = " # 4 5 # = 6Δ$ (a different Lagrange multiplier that we need to compute) We compute 5 # : " # $ + 6 78 " # 4 5 # = 0 5 # = " #$ " # 6 78 " # 4 17

Sequential Integration As solving a constraint for a body may influence the solving for another one, we need an iterative process while (!done) { for all constraints c do solve c; } Convergence is usually ensured by reaching either a maximal amount of iterations or a minimal change in every constraints 18

Inequality Constraints Constraints are inactive when! " > 0. When they becomes active, solve for them. Otherwise ignore. Example: collision and interpenetration. body 2 n body 1 p d 19

Collision Constraint In previous iteration:! " is out of the object. After position integration:! "#$ is penetrating. Penetration normal: %& (pointing outwards) body 2 n Must make sure: the projected point! "#$ is non-penetrating. Constraint: '! "#$ =! "#$! " %& 0. body 1 p d Velocity constraint: -. %& 0 Note: Can invalidate other constraints. 20

Working with rigid bodies Constraints depend on chosen center! and orientation ": c x, q = 0. As such, velocity constraints are of the form: *+ *, -,. = 0 Mass matrix consequently contains tensors of inertia: / = 0123 / 4, / 4, / 4, 5 4,, / 7, / 7, / 7, 5 7 21

Collision Resolution as Constraint Solving!"!# = & '( & *( +,- = & '( + 0 '( 2 ' & *( 0 *( 2 * +,- =,- 2 ',-,- 2 ',- & '( 0 '( & *( 0 *( = 3& Handy Identities ( ) ( ) ( ) A B C = C A B = B C A 4 ' 789:;<= 5 * ' 789:;<= 4 = ' -? ' * 4 ' 5 & '( * & *( @ & '6 A = 3& & *6 34 6B 3 C 22

Collision Resolution as Constraint Solving We get the well-known : 0 = (1 + 8 9 ) " #$ " %$ @ A! 1 + 1 + C ( # ( # A! 7 E $6 # C # A! + C % A! 7 E $6 % C % A! % For 8 9 = 0. Explanation: we solved for minimum velocity to resolve. Elastic restitution is an extra velocity bias. Handy Identities ( ) ( ) ( ) A B C = C A B = B C A! '()*+,- % # / '()*+,- # % 0 1 = 4" 45 $6 4 7 " #& " #$ " %$ " %& 23

Position Drift Even if velocities are fixed, the position integration might drift Since discrete time step. Solution: nothing simple Like interpenetration resolution Possible easy fix: project positions as well! More on that in position-based dynamics 24

Alternative: Reduced Coordinate Simulation Instead of breaking & correcting => only produce force / torque along a specific DOF. Reducing possible movement. impulse-based is a full coordinate simulation. Pro: faster simulation. less calculations. less tuning. Con: more vulnerable to numerical instability. might be difficult to parameterize the DOF system. For instance:!" = 0 => use only null space of!! 25

Motion control Imagine you have rigid bodies moving and constrained correctly according to the forces you apply. Letting them live on their own is fine for passive objects. projectile, furniture, environmental objects etc. Living beings produce motion! Otherwise they will just fall onto the ground at the beginning of the game http / / : img13.deviantart.net/8e3c/i/2015/333/d/7/a_falling_puppet_by_xxxblakexxx-d9ii9wq.jpg 26

Motion Control Animated bodies are controlled using a mix of kinematics and dynamics. Kinematics: replay and slightly adapt pre-recorded motions. Dynamics: passively animate objects reacting to external forces (e.g. human ragdoll). A real-time controller switches from one to the other according to events, forces, poses etc. 27

Motion Control Imagine that you want to actively actuate rigid bodies using forces and torques. not yet in games but will probably in a near future Actuators generate motion from within the bodies Joint torques External forces Virtual forces Muscle forces contractile elements continuummechanics.org/cm/index.html 28

https://www.youtube.com/watch?v=wujwwhdad9q Joint Torques Most straightforward actuation model. Joint torques directly generate torques for each actuated DOF. Assuming that there is a fake motor at the location of the joint that can produce torque. e.g. increase a joint angle ó positive torque. Very useful for tracking pre-recorded motions or any other error-based poses (e.g. balance pose) Amount of applied torque depends directly on the error http://files.maartenbaert.be/extremephysics/illustration-hinge-joint.png 29

https://www.youtube.com/watch?v=nonbrvkjeuq External Forces Applying external forces on the right object, local position, and for the right amount of time. Difficult to produce realistic motions. Does not really fit natural motions. Motion originates from inside! Similar to a puppetry technique. System control must be mastered. But very useful for the control of the global orientation and position of a complex system (root node). http://previews.123rf.com/images/pkdinkar/pkdinkar1109/pkdinkar110900022/10551 395-employee-as-a-puppet-on-strings-Stock-Vector-puppet-man-marionette.jpg 30

Virtual Forces Not really an actuation method. Emulate the effect of applying an external force by computing the equivalent joint torque. Use the relation between joint rotation and position where a force is applied (by the Jacobian of the system). 31

Muscle Forces Motion actually comes from the contraction of muscles. they also produce torques at joints, but not in a fake motor way. Emulating physical behavior to the model => realistic actuation of rigid bodies. commonly used in biomechanics / motion analysis the muscle model is usually a combination of non-linear springs and dampers. [Lou et al. 2013] Physics-based Human Neck Simulation https://jonbarron.org/sites/default/files/arm-muscle.jpg 32

Controller design Joint-space motion control. defines and tracks kinematics target. Stimulus-response network control genetically evolves controllers according to objectives. Constrained dynamics optimization control. finds optimal torques through online optimization. 33

PD Controller Proportional Derivative (PD) controller Used to compute joint torques linearly proportional to the difference between the current state and the target state. Based on joint orientation and angular velocity. http://www.gamedev.net/uploads/monthly_10_2014/ccs- 224713-0-48143500-1414694390.jpg 34

PD Controller! = # $ % & % + # ) % & % Where:! is the generated joint torque. % & and % the desired and current joint angles. % & and % the desired and current joint angular velocity. # $ and # ) are the controller gain. Regulating how responsive the controller is to deviation. 35

PD Controller Con: The motion-controller designer needs to carefully define the gain values. too high! " : producing stiff unresponsive motions. too low! " : not track target correctly. too high! # : converging too slowly to the target. too low! # : producing oscillations. Expect to spend time fine tuning gains! $ =! " & ' & +! # & ' & 36