-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from DeepBlueRobotics/add-PoweredHinge2Joint
Add PoweredHinge2Joint
- Loading branch information
Showing
14 changed files
with
324 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
plugin/controller/src/webotsFolder/dist/protos/deepbluesim/PoweredHinge2Joint.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#VRML_SIM R2023b utf8 | ||
# license: MIT | ||
# license url: https://github.com/DeepBlueRobotics/DeepBlueSim/blob/master/LICENSE.md | ||
# template language: javascript | ||
# A HingeJoint powered by a DeepBlueSim-compatible motor | ||
|
||
EXTERNPROTO "DBSRotationalMotorBase.proto" | ||
EXTERNPROTO "PreconfiguredDBSRotationalMotor.proto" | ||
|
||
EXTERNPROTO "CANCoder.proto" | ||
EXTERNPROTO "DBSQuadratureEncoder.proto" | ||
EXTERNPROTO "REVBuiltinEncoder.proto" | ||
EXTERNPROTO "SparkMaxAbsoluteEncoder.proto" | ||
EXTERNPROTO "SparkMaxAlternateEncoder.proto" | ||
EXTERNPROTO "SparkMaxAnalogSensor.proto" | ||
|
||
EXTERNPROTO "DBSBrake.proto" | ||
|
||
PROTO PoweredHinge2Joint [ | ||
field MFNode{ | ||
DBSRotationalMotorBase{}, PreconfiguredDBSRotationalMotor{} | ||
CANCoder{}, DBSQuadratureEncoder{}, REVBuiltinEncoder{}, SparkMaxAbsoluteEncoder{}, SparkMaxAlternateEncoder{}, SparkMaxAnalogSensor{}, | ||
DBSBrake{} | ||
} devices [PreconfiguredDBSRotationalMotor{} REVBuiltinEncoder{} DBSBrake{}] | ||
field MFNode{ | ||
DBSRotationalMotorBase{}, PreconfiguredDBSRotationalMotor{} | ||
CANCoder{}, DBSQuadratureEncoder{}, REVBuiltinEncoder{}, SparkMaxAbsoluteEncoder{}, SparkMaxAlternateEncoder{}, SparkMaxAnalogSensor{}, | ||
DBSBrake{} | ||
} devices2 [PreconfiguredDBSRotationalMotor{} REVBuiltinEncoder{} DBSBrake{}] | ||
field SFNode{Solid{}} endPoint Solid{} | ||
field SFNode{HingeJointParameters{}} jointParameters HingeJointParameters{} | ||
field SFNode{JointParameters{}} jointParameters2 JointParameters{} | ||
] | ||
{ | ||
%< | ||
import {assert} from 'wbutility.js'; | ||
let dbsutility = eval(wbfile.readTextFile(`${context.project_path}protos/deepbluesim/dbsutility.js`)); | ||
dbsutility.assertValidPoweredJointDevices(fields.devices.value, "PoweredHinge2Joint.devices", assert); | ||
dbsutility.assertValidPoweredJointDevices(fields.devices2.value, "PoweredHinge2Joint.devices2", assert); | ||
>% | ||
Hinge2Joint { | ||
device IS devices | ||
device2 IS devices2 | ||
endPoint IS endPoint | ||
jointParameters IS jointParameters | ||
jointParameters2 IS jointParameters2 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
plugin/controller/src/webotsFolder/dist/protos/deepbluesim/dbsutility.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
({ | ||
assertValidPoweredJointDevices: function (devices, fieldDesc, assert) { | ||
let hasBrake = false; | ||
let motorDevice = null; | ||
let encoderDevice = null; | ||
for (let i = 0; i < devices.length; i++) { | ||
let node_name = devices[i].node_name; | ||
if (node_name.endsWith("Brake")) { | ||
hasBrake = true; | ||
} else if (node_name.endsWith("Motor")) { | ||
motorDevice = devices[i]; | ||
} else if (node_name.endsWith("Encoder")) { | ||
encoderDevice = devices[i]; | ||
} | ||
} | ||
assert(hasBrake, fieldDesc + " is missing the required DBSBrake device!"); | ||
assert(motorDevice !== null, fieldDesc + " is missing the required motor device!"); | ||
let motorType = motorDevice?.node_name; | ||
let controllerType = motorDevice?.fields.controllerType.value; | ||
if (controllerType?.startsWith("Spark")) { | ||
assert(encoderDevice !== null, fieldDesc + " is using a " + controllerType + " motor controller but is missing the required encoder device! " | ||
+ "Consider adding a REVBuiltinEncoder."); | ||
} else if (controllerType === "PWM") { | ||
let encoderType = encoderDevice?.node_name; | ||
assert(!encoderType?.endsWith("BuiltinEncoder"), fieldDesc + " is using a " + controllerType + " motor controller, so a built-in encoder is not allowed!"); | ||
} | ||
}, | ||
}) |
Binary file modified
BIN
+12.4 KB
(120%)
plugin/controller/src/webotsFolder/dist/worlds/.MotorController.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.