Skip to content

Commit

Permalink
Merge branch 'develop' of github.com-myrobotlab:MyRobotLab/myrobotlab…
Browse files Browse the repository at this point in the history
… into inmoov2-heart
  • Loading branch information
supertick committed Mar 7, 2024
2 parents 45d7f8b + 49dc3e5 commit 419b6f7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 46 deletions.
8 changes: 8 additions & 0 deletions src/main/java/org/myrobotlab/service/Random.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ public void addRandom(long minIntervalMs, long maxIntervalMs, String name, Strin
public void addRandom(long minIntervalMs, long maxIntervalMs, String name, String method) {
addRandom(minIntervalMs, maxIntervalMs, name, method, toRanges((Object[]) null));
}

/**
* Global check for enabled
* @return
*/
public boolean isEnabled() {
return enabled;
}

public Range intRange(int min, int max) {
return new Range(min, max);
Expand Down
59 changes: 14 additions & 45 deletions src/main/java/org/myrobotlab/service/Servo.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
/**
*
* @author GroG (at) myrobotlab.org
*
* This file is part of MyRobotLab (http://myrobotlab.org).
*
* MyRobotLab is free software: you can redistribute it and/or modify
* it under the terms of the Apache License 2.0 as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version (subject to the "Classpath" exception
* as provided in the LICENSE.txt file that accompanied this code).
*
* MyRobotLab is distributed in the hope that it will be useful or fun,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Apache License 2.0 for more details.
*
* All libraries in thirdParty bundle are subject to their own license
* requirements - please refer to http://myrobotlab.org/libraries for
* details.
*
* Enjoy !
*
* */

package org.myrobotlab.service;

import java.util.Set;
Expand All @@ -35,32 +10,27 @@
import org.myrobotlab.service.config.ServiceConfig;
import org.myrobotlab.service.config.ServoConfig;
import org.myrobotlab.service.data.ServoMove;
import org.myrobotlab.service.interfaces.ServiceLifeCycleListener;
import org.slf4j.Logger;

/**
* @author GroG
* Servos have both input and output. Input is usually of the range of integers
* between 0.0 - 180.0, and output can relay those values directly to the
* servo's firmware (Arduino ServoLib, I2C controller, etc)
*
* Servos have both input and output. Input is usually of the range of
* integers between 0.0 - 180.0, and output can relay those values
* directly to the servo's firmware (Arduino ServoLib, I2C controller,
* etc)
* However there can be the occasion that the input comes from a system which
* does not have the same range. Such that input can vary from 0.0 to 1.0. For
* example, OpenCV coordinates are often returned in this range. When a mapping
* is needed Servo.map can be used. For this mapping Servo.map(0.0, 1.0, 0, 180)
* might be desired. Reversing input would be done with Servo.map(180, 0, 0,
* 180)
*
* However there can be the occasion that the input comes from a system
* which does not have the same range. Such that input can vary from 0.0
* to 1.0. For example, OpenCV coordinates are often returned in this
* range. When a mapping is needed Servo.map can be used. For this
* mapping Servo.map(0.0, 1.0, 0, 180) might be desired. Reversing input
* would be done with Servo.map(180, 0, 0, 180)
* outputY - is the values sent to the firmware, and should not necessarily be
* confused with the inputX which is the input values sent to the servo
*
* outputY - is the values sent to the firmware, and should not
* necessarily be confused with the inputX which is the input values
* sent to the servo
*
* FIXME - inherit from AbstractMotor ..
* FIXME - inherit from AbstractMotor ..
*
* @author GroG
*/

public class Servo extends AbstractServo<ServoConfig> {

private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -92,7 +62,7 @@ protected boolean processMove(Double newPos, boolean blocking, Long timeoutMs) {
double maxLimit = Math.max(mapper.minX, mapper.maxX);
newPos = (newPos < minLimit) ? minLimit : newPos;
newPos = (newPos > maxLimit) ? maxLimit : newPos;

log.debug("{} processMove {}", getName(), newPos);

// This is to allow attaching disabled
Expand Down Expand Up @@ -259,7 +229,6 @@ public static void main(String[] args) throws InterruptedException {
return;
}


} catch (Exception e) {
log.error("main threw", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public Plan getDefault(Plan plan, String name) {
addDefaultPeerConfig(plan, name, "forheadLeft", "Servo", false);
addDefaultPeerConfig(plan, name, "eyelidLeftUpper", "Servo", false);
addDefaultPeerConfig(plan, name, "eyelidLeftLower", "Servo", false);
addDefaultPeerConfig(plan, name, "rothead", "Servo", false);
addDefaultPeerConfig(plan, name, "upperLip", "Servo", false);

addDefaultPeerConfig(plan, name, "eyeLeftLR", "Servo", false);
Expand Down

0 comments on commit 419b6f7

Please sign in to comment.