Class: MSPhysics::Servo

Inherits:
Joint show all
Defined in:
RubyExtension/MSPhysics/joint_servo.rb

Overview

Since:

  • 1.0.0

Constant Summary collapse

DEFAULT_MIN =

Since:

  • 1.0.0

-180.0.degrees
DEFAULT_MAX =

Since:

  • 1.0.0

180.0.degrees
DEFAULT_LIMITS_ENABLED =

Since:

  • 1.0.0

false
DEFAULT_RATE =

Since:

  • 1.0.0

360.degrees
DEFAULT_POWER =

Since:

  • 1.0.0

0.0
DEFAULT_REDUCTION_RATIO =

Since:

  • 1.0.0

0.1
DEFAULT_CONTROLLER =

Since:

  • 1.0.0

nil

Constants inherited from Joint

Joint::DEFAULT_BODIES_COLLIDABLE, Joint::DEFAULT_BREAKING_FORCE, Joint::DEFAULT_SOLVER_MODEL, Joint::DEFAULT_STIFFNESS

Instance Method Summary collapse

Methods inherited from Joint

#address, all_joints, #bodies_collidable=, #bodies_collidable?, #breaking_force, #breaking_force=, #child, #connect, #connected?, #destroy, #disconnect, #dof, #get_pin_matrix, #get_pin_matrix2, #get_tension1, #get_tension2, #group, joint_by_address, #name, #name=, #parent, #set_pin_matrix, #solver_model, #solver_model=, #stiffness, #stiffness=, #type, #valid?, validate, #world

Methods inherited from Entity

#inspect, #to_s

Constructor Details

#initialize(world, parent, pin_tra, group = nil) ⇒ Servo

Create a servo joint.

Parameters:

  • world (MSPhysics::World)
  • parent (MSPhysics::Body, nil)
  • pin_tra (Geom::Transformation, Array<Numeric>)

    Pin transformation in global space. Matrix origin is interpreted as the pin position. Matrix Z-axis is interpreted as the pin direction.

  • group (Sketchup::Group, Sketchup::ComponentInstance, nil) (defaults to: nil)

Since:

  • 1.0.0



21
22
23
24
25
26
27
28
29
30
31
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 21

def initialize(world, parent, pin_tra, group = nil)
  super(world, parent, pin_tra, group)
  MSPhysics::Newton::Servo.create(@address)
  MSPhysics::Newton::Servo.set_min(@address, DEFAULT_MIN)
  MSPhysics::Newton::Servo.set_max(@address, DEFAULT_MAX)
  MSPhysics::Newton::Servo.enable_limits(@address, DEFAULT_LIMITS_ENABLED)
  MSPhysics::Newton::Servo.set_rate(@address, DEFAULT_RATE)
  MSPhysics::Newton::Servo.set_power(@address, DEFAULT_POWER)
  MSPhysics::Newton::Servo.set_reduction_ratio(@address, DEFAULT_REDUCTION_RATIO)
  MSPhysics::Newton::Servo.set_controller(@address, DEFAULT_CONTROLLER)
end

Instance Method Details

#controllerNumeric?

Get servo controller.

Returns:

  • (Numeric, nil)

    Desired angle in radians or nil if servo is turned off.

Since:

  • 1.0.0



144
145
146
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 144

def controller
  MSPhysics::Newton::Servo.get_controller(@address)
end

#controller=(value) ⇒ Object

Set servo controller.

Parameters:

  • value (Numeric, nil)

    Desired angle in radians or nil to turn off the servo.

Since:

  • 1.0.0



151
152
153
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 151

def controller=(value)
  MSPhysics::Newton::Servo.set_controller(@address, value)
end

#cur_alphaNumeric

Get current angular acceleration in radians per second per second.

Returns:

  • (Numeric)

Since:

  • 1.0.0



47
48
49
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 47

def cur_alpha
  MSPhysics::Newton::Servo.get_cur_alpha(@address)
end

#cur_angleNumeric

Get current angle in radians.

Returns:

  • (Numeric)

Since:

  • 1.0.0



35
36
37
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 35

def cur_angle
  MSPhysics::Newton::Servo.get_cur_angle(@address)
end

#cur_omegaNumeric

Get current angular velocity in radians per second.

Returns:

  • (Numeric)

Since:

  • 1.0.0



41
42
43
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 41

def cur_omega
  MSPhysics::Newton::Servo.get_cur_omega(@address)
end

#limits_enabled=(state) ⇒ Object

Note:

This option has no effect if SP mode is enabled.

Enable/disable min & max angle limits.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



85
86
87
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 85

def limits_enabled=(state)
  MSPhysics::Newton::Servo.enable_limits(@address, state)
end

#limits_enabled?Boolean

Note:

This option has no effect if SP mode is enabled.

Determine whether min & max angle limits are enabled.

Returns:

  • (Boolean)

Since:

  • 1.0.0



78
79
80
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 78

def limits_enabled?
  MSPhysics::Newton::Servo.limits_enabled?(@address)
end

#maxNumeric

Get maximum angle in radians.

Returns:

  • (Numeric)

Since:

  • 1.0.0



65
66
67
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 65

def max
  MSPhysics::Newton::Servo.get_max(@address)
end

#max=(value) ⇒ Object

Set maximum angle in radians.

Parameters:

  • value (Numeric)

Since:

  • 1.0.0



71
72
73
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 71

def max=(value)
  MSPhysics::Newton::Servo.set_max(@address, value)
end

#minNumeric

Get minimum angle in radians.

Returns:

  • (Numeric)

Since:

  • 1.0.0



53
54
55
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 53

def min
  MSPhysics::Newton::Servo.get_min(@address)
end

#min=(value) ⇒ Object

Set minimum angle in radians.

Parameters:

  • value (Numeric)

Since:

  • 1.0.0



59
60
61
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 59

def min=(value)
  MSPhysics::Newton::Servo.set_min(@address, value)
end

#powerNumeric

Note:

A power value of zero represents maximum power.

Get rotational power in Watts.

Returns:

  • (Numeric)

Since:

  • 1.0.0



104
105
106
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 104

def power
  MSPhysics::Newton::Servo.get_power(@address)
end

#power=(value) ⇒ Object

Note:

A power value of zero represents maximum power.

Set rotational power in Watts.

Parameters:

  • value (Numeric)

    A value greater than or equal to zero.

Since:

  • 1.0.0



111
112
113
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 111

def power=(value)
  MSPhysics::Newton::Servo.set_power(@address, value)
end

#rateNumeric

Get maximum angular rate in radians per second.

Returns:

  • (Numeric)

Since:

  • 1.0.0



91
92
93
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 91

def rate
  MSPhysics::Newton::Servo.get_rate(@address)
end

#rate=(value) ⇒ Object

Set maximum angular rate in radians per second.

Parameters:

  • value (Numeric)

    A value greater than or equal to zero.

Since:

  • 1.0.0



97
98
99
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 97

def rate=(value)
  MSPhysics::Newton::Servo.set_rate(@address, value)
end

#reduction_ratioNumeric

Note:

Reduction ratio is a feature that reduces angular rate of the joint when its current angle nears its desired angle. Angular reduction ratio starts acting upon the angular rate of the joint when the difference between the current angle and the desired angle of the joint is less than rate * reduction_ratio radians.

Note:

A reduction ratio of zero disables the reduction feature.

Note:

A typical reduction ratio value is 0.1.

Get angular reduction ratio.

Returns:

  • (Numeric)

    A value between 0.0 and 1.0.

Since:

  • 1.0.0



124
125
126
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 124

def reduction_ratio
  MSPhysics::Newton::Servo.get_reduction_ratio(@address)
end

#reduction_ratio=(value) ⇒ Object

Note:

Reduction ratio is a feature that reduces angular rate of the joint when its current angle nears its desired angle. Angular reduction ratio starts acting upon the angular rate of the joint when the difference between the current angle and the desired angle of the joint is less than rate * reduction_ratio radians.

Note:

A reduction ratio of zero disables the reduction feature.

Note:

A typical reduction ratio value is 0.1.

Set angular reduction ratio.

Parameters:

  • value (Numeric)

    A value between 0.0 and 1.0.

Since:

  • 1.0.0



137
138
139
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 137

def reduction_ratio=(value)
  MSPhysics::Newton::Servo.set_reduction_ratio(@address, value)
end