Skip to content

Latest commit

 

History

History
344 lines (260 loc) · 10.3 KB

force.rst

File metadata and controls

344 lines (260 loc) · 10.3 KB

trep

Force -- Base Class for Forces

param system

An instance of System to add the force to.

type system

System

param name

A string that uniquely identifies the force.

This is the base class for all forces in a System. It should never be created directly. Forces are created by instantiating a specific type of force..

See builtin_forces for the built-in types of forces. Additional forces can be added through either the Python or C-API.

Forces are used to include non-conservative and control forces in a mechanical system. Forces must be expressed in the generalized coordinates of the system. Conservative forces like gravity or spring-like potentials should be implemented using Potential instead.

Force Objects

Force.system

The System that this force belongs to.

(read-only)

Force.name

The name of this force or None.

Force.f(q)

param q

Configuration variable

type q

Config

Calculate the force on configuration variable q at the current state of the system.

Required for Calculations
Desired Calculation Required
Continuous Dynamics

?

1st Derivative

?

2nd Derivative

?

Discrete Dynamics

?

1st Derivative

?

2nd Derivative

?

Force.f_dq(q, q1)

param q

Configuration variable

type q

Config

param q1

Configuration variable

type q1

Config

Calculate the derivative of the force on configuration variable q with respect to the value of q1.

Required for Calculations
Desired Calculation Required
Continuous Dynamics

?

1st Derivative

?

2nd Derivative

?

Discrete Dynamics

?

1st Derivative

?

2nd Derivative

?

Force.f_ddq(q, dq1)

param q

Configuration variable

type q

Config

param dq1

Configuration variable

type dq1

Config

Calculate the derivative of the force on configuration variable q with respect to the velocity of dq1.

Required for Calculations
Desired Calculation Required
Continuous Dynamics

?

1st Derivative

?

2nd Derivative

?

Discrete Dynamics

?

1st Derivative

?

2nd Derivative

?

Force.f_du(q, u1)

param q

Configuration variable

type q

Config

param u1

Input variable

type u1

Input

Calculate the derivative of the force on configuration variable q with respect to the value of u1.

Required for Calculations
Desired Calculation Required
Continuous Dynamics

?

1st Derivative

?

2nd Derivative

?

Discrete Dynamics

?

1st Derivative

?

2nd Derivative

?

Force.f_dqdq(q, q1, q2)

param q

Configuration variable

type q

Config

param q1

Configuration variable

type q1

Config

param q2

Configuration variable

type q2

Config

Calculate the second derivative of the force on configuration variable q with respect to the value of q1 and the value of q2.

Required for Calculations
Desired Calculation Required
Continuous Dynamics

?

1st Derivative

?

2nd Derivative

?

Discrete Dynamics

?

1st Derivative

?

2nd Derivative

?

Force.f_ddqdq(q, dq1, q2)

param q

Configuration variable

type q

Config

param dq1

Configuration variable

type dq1

Config

param q2

Configuration variable

type q2

Config

Calculate the second derivative of the force on configuration variable q with respect to the velocity of dq1 and the value of q2.

Required for Calculations
Desired Calculation Required
Continuous Dynamics

?

1st Derivative

?

2nd Derivative

?

Discrete Dynamics

?

1st Derivative

?

2nd Derivative

?

Force.f_ddqddq(q, dq1, dq2)

param q

Configuration variable

type q

Config

param dq1

Configuration variable

type dq1

Config

param dq2

Configuration variable

type dq2

Config

Calculate the second derivative of the force on configuration variable q with respect to the velocity of dq1 and the velocity of q2.

Required for Calculations
Desired Calculation Required
Continuous Dynamics

?

1st Derivative

?

2nd Derivative

?

Discrete Dynamics

?

1st Derivative

?

2nd Derivative

?

Force.f_dudq(q, u1, q2)

param q

Configuration variable

type q

Config

param u1

Input variable

type u1

Input

param q2

Configuration variable

type q2

Config

Calculate the second derivative of the force on configuration variable q with respect to the value of u1 and the value of q2.

Required for Calculations
Desired Calculation Required
Continuous Dynamics

?

1st Derivative

?

2nd Derivative

?

Discrete Dynamics

?

1st Derivative

?

2nd Derivative

?

Force.f_duddq(q, u1, dq2)

param q

Configuration variable

type q

Config

param u1

Input variable

type u1

Input

param dq2

Configuration variable

type dq2

Config

Calculate the second derivative of the force on configuration variable q with respect to the value of u1 and the velocity of q2.

Required for Calculations
Desired Calculation Required
Continuous Dynamics

?

1st Derivative

?

2nd Derivative

?

Discrete Dynamics

?

1st Derivative

?

2nd Derivative

?

Force.f_dudu(q, u1, u2)

param q

Configuration variable

type q

Config

param u1

Input variable

type u1

Input

param u2

Input variable

type u2

Input

Calculate the second derivative of the force on configuration variable q with respect to the value of u1 and the value of u2.

Required for Calculations
Desired Calculation Required
Continuous Dynamics

?

1st Derivative

?

2nd Derivative

?

Discrete Dynamics

?

1st Derivative

?

2nd Derivative

?

Verifying Derivatives of the Force

It is important that the derivatives of f are correct. The easiest way to check their correctness is to approximate each derivative using numeric differentiation. These methods are provided to perform this test. The derivatives are only compared at the current configuration of the system. For improved coverage, try running each test several times at different configurations.

Force.validate_h_dq(delta=1e-6, tolerance=1e-6, verbose=False) Force.validate_h_ddq(delta=1e-6, tolerance=1e-6, verbose=False) Force.validate_h_du(delta=1e-6, tolerance=1e-6, verbose=False) Force.validate_h_dqdq(delta=1e-6, tolerance=1e-6, verbose=False) Force.validate_h_ddqdq(delta=1e-6, tolerance=1e-6, verbose=False) Force.validate_h_ddqddq(delta=1e-6, tolerance=1e-6, verbose=False) Force.validate_h_dudq(delta=1e-6, tolerance=1e-6, verbose=False) Force.validate_h_duddq(delta=1e-6, tolerance=1e-6, verbose=False) Force.validate_h_dudu(delta=1e-6, tolerance=1e-6, verbose=False)

param delta

Amount to add to each configuration, velocity, or input.

param tolerance

Acceptable difference between the calculated and approximate derivatives

param verbose

Boolean to print error and result messages.

rtype

Boolean indicating if all tests passed

Check the derivatives against the approximate numeric derivative calculated from one less derivative (ie, approximate f_dq from f and f_dudq from f_du).

See System.test_derivative_dq, System.test_derivative_ddq, and System.test_derivative_du for details of the approximation and comparison.

Visualization

Force.opengl_draw()

Draw a representation of this force in the current OpenGL context. The OpenGL coordinate frame will be in the System's root coordinate frame.

This function is called by the automatic visualization tools. The default implementation does nothing.