Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Framework for Mechanisms (Active/Passive) #105

Open
zhiquanyeo opened this issue Jul 15, 2020 · 4 comments
Open

Framework for Mechanisms (Active/Passive) #105

zhiquanyeo opened this issue Jul 15, 2020 · 4 comments

Comments

@zhiquanyeo
Copy link
Collaborator

We'll need some way to specify mechanisms (either active or passive) and where they are mounted on a robot. Additionally, there needs to be some sort of API that allows us to interact with an active mechanism

@zhiquanyeo
Copy link
Collaborator Author

Rough Spec:
A SimMechanism object should be created, similar in style to the SimBasicSensor

A spec for a SimMechanism (the base class) should be look like this:

interface IMechanismSpec {
  type: string;
  mountFace: SensorMountingFace;
  ioMap: IMechanismIOConfig[]; // 1 entry for each IO that is needed

  // Getters and setters for the various IO channels
}

interface IMechanismIOConfig {
  id:  string; // Identifier for this IO channel
  ioType: string; // Could also be an enum of "PWM" | "DIGITAL_IN" | "DIGITAL_OUT" | "ANALOG_IN"
  ioChannel: number;
}

// Rough sketch of the SimMechanism base class
// Very incomplete, and this should save the spec properties somewhere
abstract class SimMechanism extends SimObject {
  public abstract getValue(ioIdentifier: string): number | boolean; // Get a value from an input IO device
  public abstract setValue(ioIdentifier: string, value: number | boolean): void; // Set a value to an output IO device
  
}

General concepts:

  • A SimMechanism is made up of some 1 or more physical bodies that can be controlled via 0 or more IO devices
    • e.g. a passive mechanism can simply define itself as a plow (or similar), with no IO devices
  • Each IO device in a mechanism represents a sensor or actuator that is integral to that mechanism
    • e.g. A gripper mechanism should have at least 1 PWM IO device that represents a servo controlling the gripper
  • All actual mechanisms are subclasses of the SimMechanism class
  • Similar to sensors, there should be a MechanismManager that handles interaction with the mechanism
    • The manager should also verify that all channel type/channel number combinations for IO devices are unique (i.e. there should only be 1 Digital channel 0 defined)

@zhiquanyeo
Copy link
Collaborator Author

Basic Gripper Mechanism

For the purposes of the FTC Sim, we can define a basic gripper that is made up of a set of parallel jaws, controlled by a single DIGITAL_OUT device (if this is set to LOW, the jaw is open, and if HIGH, the jaw is closed).

|              |   ^
| <-width->    |   |  depth
|______________|   v
interface IGripperMechanismSpec extends IMechanismSpec {
  type: "gripper";
  depth: number; // see crude drawing above
  maxWidth: number; // see crude drawing above
  minWidth: number;
}

class GripperMechanism extends SimMechanism {
  constructor(.........., spec: IGripperMechanismSpec) {
       // instantiate this. Should take in a single DIGITAL_OUT device
  }

  setValue(ioIdentifier: string, value: number | boolean): void {
    // This should update the open/closed state of the jaws
    // When transitioning state, check to see if there is an object within the jaws and act accordingly
  }

  update() {
    // This function should manage the behavior of the gripper
    // e.g. set flags/manipulate object position if the jaws are closed
    // This should get called every update cycle
  }
}

@JamesWP
Copy link
Contributor

JamesWP commented Oct 2, 2020

i would guess that we need a way to see if the mechanism had grabbed something or not.
Would that be a different sensor or instead could it be returned in a getValue call?

i.e.

setValue(close grip)
wait(1 second)
if(getValue() == close grip)
print(we grabbed something)
else
print(we didnt get anything)

@zhiquanyeo
Copy link
Collaborator Author

Ah yes, we could have another DIGITAL_IN device act as a "is there an object" sensor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants