Search in sources :

Example 1 with DHParameterKinematics

use of com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics in project BowlerStudio by CommonWealthRobotics.

the class ParallelWidget method setupAddReferenceSection.

private void setupAddReferenceSection() {
    base.getParallelGroup(groupName.getText()).setupReferencedLimbStartup(dh, null, "", 0);
    Platform.runLater(() -> relativeName.getItems().clear());
    for (DHParameterKinematics l : base.getAllDHChains()) {
        if (!l.getScriptingName().contentEquals(dh.getScriptingName())) {
            Platform.runLater(() -> relativeName.getItems().add(l.getScriptingName()));
        }
    }
    relIndex.setDisable(true);
    e.setDisable(true);
}
Also used : DHParameterKinematics(com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics)

Example 2 with DHParameterKinematics

use of com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics in project BowlerStudio by CommonWealthRobotics.

the class CreatureLab method finishLoading.

private void finishLoading(MobileBase device) {
    TreeView<String> tree = null;
    TreeItem<String> rootItem = null;
    TreeItem<String> mainBase = null;
    int count = 1;
    for (DHParameterKinematics kin : device.getAllDHChains()) {
        for (int i = 0; i < kin.getNumberOfLinks(); i++) {
            DHLink dhLink = kin.getDhLink(i);
            if (dhLink.getSlaveMobileBase() != null) {
                count++;
            }
        }
    }
    try {
        rootItem = new TreeItem<String>("Mobile Bases", AssetFactory.loadIcon("creature.png"));
        mainBase = new TreeItem<String>(device.getScriptingName(), AssetFactory.loadIcon("creature.png"));
    } catch (Exception e) {
        rootItem = new TreeItem<String>(device.getScriptingName());
    }
    if (count == 1) {
        rootItem = mainBase;
    } else {
        rootItem.getChildren().add(mainBase);
    }
    tree = new TreeView<>(rootItem);
    AnchorPane treebox1 = tab.getTreeBox();
    treebox1.getChildren().clear();
    treebox1.getChildren().add(tree);
    AnchorPane.setTopAnchor(tree, 0.0);
    AnchorPane.setLeftAnchor(tree, 0.0);
    AnchorPane.setRightAnchor(tree, 0.0);
    AnchorPane.setBottomAnchor(tree, 0.0);
    HashMap<TreeItem<String>, Runnable> callbackMapForTreeitems = new HashMap<>();
    HashMap<TreeItem<String>, Group> widgetMapForTreeitems = new HashMap<>();
    File source;
    boolean creatureIsOwnedByUser = false;
    try {
        source = ScriptingEngine.fileFromGit(device.getGitSelfSource()[0], device.getGitSelfSource()[1]);
        creatureIsOwnedByUser = ScriptingEngine.checkOwner(source);
    } catch (GitAPIException | IOException e) {
        // TODO Auto-generated catch block
        new IssueReportingExceptionHandler().uncaughtException(Thread.currentThread(), e);
    }
    rootItem.setExpanded(true);
    MobileBaseCadManager.get(device, BowlerStudioController.getMobileBaseUI());
    MobleBaseMenueFactory.load(device, tree, mainBase, callbackMapForTreeitems, widgetMapForTreeitems, this, true, creatureIsOwnedByUser);
    for (DHParameterKinematics kin : device.getAllDHChains()) {
        for (int i = 0; i < kin.getNumberOfLinks(); i++) {
            DHLink dhLink = kin.getDhLink(i);
            String linkName = kin.getLinkConfiguration(i).getName();
            if (dhLink.getSlaveMobileBase() != null) {
                TreeItem<String> mobile = new TreeItem<>(kin.getScriptingName() + " ->\n " + linkName + " link " + i + " ->\n  " + dhLink.getSlaveMobileBase().getScriptingName(), AssetFactory.loadIcon("creature.png"));
                MobleBaseMenueFactory.load(dhLink.getSlaveMobileBase(), tree, mobile, callbackMapForTreeitems, widgetMapForTreeitems, this, false, creatureIsOwnedByUser);
                rootItem.getChildren().add(mobile);
            }
        }
    }
    tree.setPrefWidth(325);
    tree.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    JogMobileBase walkWidget = new JogMobileBase(device);
    tree.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Object>() {

        @Override
        public void changed(ObservableValue<?> observable, Object oldValue, Object newValue) {
            @SuppressWarnings("unchecked") TreeItem<String> treeItem = (TreeItem<String>) newValue;
            new Thread() {

                public void run() {
                    if (callbackMapForTreeitems.get(treeItem) != null) {
                        callbackMapForTreeitems.get(treeItem).run();
                    }
                    if (widgetMapForTreeitems.get(treeItem) != null) {
                        Platform.runLater(() -> {
                            tab.getControlsBox().getChildren().clear();
                            Group g = widgetMapForTreeitems.get(treeItem);
                            tab.getControlsBox().getChildren().add(g);
                            AnchorPane.setTopAnchor(g, 0.0);
                            AnchorPane.setLeftAnchor(g, 0.0);
                            AnchorPane.setRightAnchor(g, 0.0);
                            AnchorPane.setBottomAnchor(g, 0.0);
                        });
                    } else {
                        Platform.runLater(() -> {
                            tab.getControlsBox().getChildren().clear();
                        });
                    }
                }
            }.start();
        }
    });
    VBox progress = new VBox(10);
    final ToggleGroup group = new ToggleGroup();
    RadioButton rb1 = new RadioButton();
    rb1.setToggleGroup(group);
    rb1.setSelected(true);
    rb1.setOnAction(event -> {
        setCadMode(false);
    });
    RadioButton rb2 = new RadioButton();
    rb2.setToggleGroup(group);
    rb2.fire();
    rb2.setOnAction(event -> {
        setCadMode(true);
    });
    HBox radioOptions = new HBox(10);
    radioOptions.getChildren().addAll(new Label("Cad"), rb1, rb2, new Label("Config"));
    pi = new ProgressIndicator(0);
    baseManager = MobileBaseCadManager.get(device, BowlerStudioController.getMobileBaseUI());
    pi.progressProperty().bindBidirectional(baseManager.getProcesIndictor());
    HBox progressIndicatorPanel = new HBox(10);
    progressIndicatorPanel.getChildren().addAll(new Label("Cad Progress:"), pi);
    progress.getChildren().addAll(progressIndicatorPanel, autoRegen, radioOptions);
    progress.setStyle("-fx-background-color: #FFFFFF;");
    progress.setOpacity(.7);
    progress.setMinHeight(100);
    progress.setPrefSize(325, 150);
    tab.setOverlayTop(progress);
    tab.setOverlayTopRight(walkWidget);
    BowlerStudioModularFrame.getBowlerStudioModularFrame().showCreatureLab();
    // start the UI in config mode
    setCadMode(true);
    generateCad();
    setContent(root);
}
Also used : Group(javafx.scene.Group) HBox(javafx.scene.layout.HBox) HashMap(java.util.HashMap) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) AnchorPane(javafx.scene.layout.AnchorPane) IOException(java.io.IOException) IssueReportingExceptionHandler(com.neuronrobotics.bowlerstudio.IssueReportingExceptionHandler) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) IOException(java.io.IOException) TransportException(org.eclipse.jgit.api.errors.TransportException) InvalidRemoteException(org.eclipse.jgit.api.errors.InvalidRemoteException) DHLink(com.neuronrobotics.sdk.addons.kinematics.DHLink) DHParameterKinematics(com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics) File(java.io.File) VBox(javafx.scene.layout.VBox)

Example 3 with DHParameterKinematics

use of com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics in project java-bowler by NeuronRobotics.

the class Jfx3dManager method attachArm.

public void attachArm(DyIO master, String xml) {
    for (int i = 0; i < master.getPIDChannelCount(); i++) {
        // disable PID controller, default PID and dypid configurations are
        // disabled.
        master.ConfigureDynamicPIDChannels(new DyPIDConfiguration(i));
        master.ConfigurePIDController(new PIDConfiguration());
    }
    attachArm(new DHParameterKinematics(master, xml));
}
Also used : DyPIDConfiguration(com.neuronrobotics.sdk.dyio.dypid.DyPIDConfiguration) PIDConfiguration(com.neuronrobotics.sdk.pid.PIDConfiguration) DHParameterKinematics(com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics) DyPIDConfiguration(com.neuronrobotics.sdk.dyio.dypid.DyPIDConfiguration)

Example 4 with DHParameterKinematics

use of com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics in project java-bowler by NeuronRobotics.

the class DHKinematicsViewer method main.

public static void main(String[] args) {
    System.setProperty("prism.dirtyopts", "false");
    JFrame frame = new JFrame();
    DyIO.disableFWCheck();
    // Log.enableInfoPrint();
    // Create the references for my known DyIOs
    DyIO master = new DyIO(ConnectionDialog.promptConnection());
    master.connect();
    if (master.isAvailable()) {
        DHParameterKinematics model = new DHParameterKinematics(master, "TrobotMaster.xml");
        frame.setContentPane(new DHKinematicsViewer(model));
        frame.setSize(1024, 1024);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    Log.enableSystemPrint(false);
    while (true) {
        ThreadUtil.wait(1);
        master.getAllChannelValues();
    }
}
Also used : JFrame(javax.swing.JFrame) DyIO(com.neuronrobotics.sdk.dyio.DyIO) DHParameterKinematics(com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics)

Example 5 with DHParameterKinematics

use of com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics in project bowler-script-kernel by CommonWealthRobotics.

the class MobileBaseCadManager method set.

private void set(MobileBase base, int limb, int link) {
    ArrayList<DHParameterKinematics> limbs = base.getAllDHChains();
    double numLimbs = limbs.size();
    DHParameterKinematics dh = limbs.get(limb);
    double partsTotal = numLimbs * dh.getNumberOfLinks();
    double progress = ((double) ((limb * dh.getNumberOfLinks()) + link)) / partsTotal;
    // System.out.println("Cad progress " + progress + " limb " + limb + " link " + link + " total parts " + partsTotal);
    getProcesIndictor().set(0.333 + (2 * (progress / 3)));
}
Also used : DHParameterKinematics(com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics)

Aggregations

DHParameterKinematics (com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics)13 CSG (eu.mihosoft.vrl.v3d.CSG)4 IOException (java.io.IOException)4 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)4 InvalidRemoteException (org.eclipse.jgit.api.errors.InvalidRemoteException)4 TransportException (org.eclipse.jgit.api.errors.TransportException)4 LinkConfiguration (com.neuronrobotics.sdk.addons.kinematics.LinkConfiguration)3 MobileBase (com.neuronrobotics.sdk.addons.kinematics.MobileBase)3 IssueReportingExceptionHandler (com.neuronrobotics.bowlerstudio.IssueReportingExceptionHandler)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Group (javafx.scene.Group)2 VBox (javafx.scene.layout.VBox)2 LinkConfigurationWidget (com.neuronrobotics.bowlerstudio.creature.LinkConfigurationWidget)1 LinkSliderWidget (com.neuronrobotics.bowlerstudio.creature.LinkSliderWidget)1 AbstractLink (com.neuronrobotics.sdk.addons.kinematics.AbstractLink)1 DHLink (com.neuronrobotics.sdk.addons.kinematics.DHLink)1 ILinkListener (com.neuronrobotics.sdk.addons.kinematics.ILinkListener)1 TransformNR (com.neuronrobotics.sdk.addons.kinematics.math.TransformNR)1 BowlerAbstractDevice (com.neuronrobotics.sdk.common.BowlerAbstractDevice)1