Class: MSPhysics::Servo
- Defined in:
- RubyExtension/MSPhysics/joint_servo.rb
Overview
Constant Summary collapse
- DEFAULT_MIN =
-180.0.degrees
- DEFAULT_MAX =
180.0.degrees
- DEFAULT_LIMITS_ENABLED =
false
- DEFAULT_RATE =
360.degrees
- DEFAULT_POWER =
0.0
- DEFAULT_REDUCTION_RATIO =
0.1
- DEFAULT_CONTROLLER =
nil
Constants inherited from Joint
Joint::DEFAULT_BODIES_COLLIDABLE, Joint::DEFAULT_BREAKING_FORCE, Joint::DEFAULT_SOLVER_MODEL, Joint::DEFAULT_STIFFNESS
Instance Method Summary collapse
-
#controller ⇒ Numeric?
Get servo controller.
-
#controller=(value) ⇒ Object
Set servo controller.
-
#cur_alpha ⇒ Numeric
Get current angular acceleration in radians per second per second.
-
#cur_angle ⇒ Numeric
Get current angle in radians.
-
#cur_omega ⇒ Numeric
Get current angular velocity in radians per second.
-
#initialize(world, parent, pin_tra, group = nil) ⇒ Servo
constructor
Create a servo joint.
-
#limits_enabled=(state) ⇒ Object
Enable/disable min & max angle limits.
-
#limits_enabled? ⇒ Boolean
Determine whether min & max angle limits are enabled.
-
#max ⇒ Numeric
Get maximum angle in radians.
-
#max=(value) ⇒ Object
Set maximum angle in radians.
-
#min ⇒ Numeric
Get minimum angle in radians.
-
#min=(value) ⇒ Object
Set minimum angle in radians.
-
#power ⇒ Numeric
Get rotational power in Watts.
-
#power=(value) ⇒ Object
Set rotational power in Watts.
-
#rate ⇒ Numeric
Get maximum angular rate in radians per second.
-
#rate=(value) ⇒ Object
Set maximum angular rate in radians per second.
-
#reduction_ratio ⇒ Numeric
Get angular reduction ratio.
-
#reduction_ratio=(value) ⇒ Object
Set angular reduction ratio.
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
Constructor Details
#initialize(world, parent, pin_tra, group = nil) ⇒ Servo
Create a servo joint.
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
#controller ⇒ Numeric?
Get servo controller.
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.
151 152 153 |
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 151 def controller=(value) MSPhysics::Newton::Servo.set_controller(@address, value) end |
#cur_alpha ⇒ Numeric
Get current angular acceleration in radians per second per second.
47 48 49 |
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 47 def cur_alpha MSPhysics::Newton::Servo.get_cur_alpha(@address) end |
#cur_angle ⇒ Numeric
Get current angle in radians.
35 36 37 |
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 35 def cur_angle MSPhysics::Newton::Servo.get_cur_angle(@address) end |
#cur_omega ⇒ Numeric
Get current angular velocity in radians per second.
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
This option has no effect if SP mode is enabled.
Enable/disable min & max angle limits.
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
This option has no effect if SP mode is enabled.
Determine whether min & max angle limits are enabled.
78 79 80 |
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 78 def limits_enabled? MSPhysics::Newton::Servo.limits_enabled?(@address) end |
#max ⇒ Numeric
Get maximum angle in radians.
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.
71 72 73 |
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 71 def max=(value) MSPhysics::Newton::Servo.set_max(@address, value) end |
#min ⇒ Numeric
Get minimum angle in radians.
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.
59 60 61 |
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 59 def min=(value) MSPhysics::Newton::Servo.set_min(@address, value) end |
#power ⇒ Numeric
A power value of zero represents maximum power.
Get rotational power in Watts.
104 105 106 |
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 104 def power MSPhysics::Newton::Servo.get_power(@address) end |
#power=(value) ⇒ Object
A power value of zero represents maximum power.
Set rotational power in Watts.
111 112 113 |
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 111 def power=(value) MSPhysics::Newton::Servo.set_power(@address, value) end |
#rate ⇒ Numeric
Get maximum angular rate in radians per second.
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.
97 98 99 |
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 97 def rate=(value) MSPhysics::Newton::Servo.set_rate(@address, value) end |
#reduction_ratio ⇒ Numeric
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.
A reduction ratio of zero disables the reduction feature.
A typical reduction ratio value is 0.1.
Get angular reduction ratio.
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
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.
A reduction ratio of zero disables the reduction feature.
A typical reduction ratio value is 0.1.
Set angular reduction ratio.
137 138 139 |
# File 'RubyExtension/MSPhysics/joint_servo.rb', line 137 def reduction_ratio=(value) MSPhysics::Newton::Servo.set_reduction_ratio(@address, value) end |