Class FloorCalculatorComponent

java.lang.Object
edu.tufts.hrilab.diarc.DiarcComponent
edu.tufts.hrilab.imu.FloorCalculatorComponent

public class FloorCalculatorComponent extends DiarcComponent
FloorCalculatorComponent Cameron Yuen This class allows any IMU equipped robot to calculate what imu it's traveling to on the elevator. It uses the IMU, vertical linear acceleration data to determine its vertical displacement.
  • Constructor Details

    • FloorCalculatorComponent

      public FloorCalculatorComponent()
      The constructor sets all the variables for calculating the displacement to default values. NOTE: possible issue is the default value of verticalDisplacement; this value depends on the imu the robot starts on, which can get screwed up if the robot ever restarts It also instantiates the nodeMain for ROS, creates a subscriber to /imu, allowing us to obtain acceleration and time stamp information
  • Method Details

    • handleAcceleration

      protected void handleAcceleration(Double currentAcceleration, Double currentTime)
      Handles the running acceleration averages over 0.4 seconds and indicates if we've begun moving; if we've started moving, pass control over to adjustDisplacement()
      Parameters:
      currentAcceleration -
      currentTime -
    • adjustDisplacement

      protected void adjustDisplacement(Double timeFrame)
      Changes the verticalDisplacement based on the acceleration averages through double integration; indicates stop moving when the velocity is virtually 0
      Parameters:
      timeFrame -
    • additionalUsageInfo

      protected List<org.apache.commons.cli.Option> additionalUsageInfo()
      Adds the config parameter to FloorCalculator which takes a .json file.
      Overrides:
      additionalUsageInfo in class DiarcComponent
      Returns:
    • parseArgs

      protected void parseArgs(org.apache.commons.cli.CommandLine cmdLine)
      Parse the arguments in the command line; look for "config" and a valid .json file This .json file should include: gravity, thresholdVelocity, and floorHeights
      Overrides:
      parseArgs in class DiarcComponent
      Parameters:
      cmdLine -
    • getFloorNum

      public int getFloorNum()
      Retrieves what imu the robot is currently on.
      Returns:
    • setFloorNum

      public void setFloorNum(int floorNum)
      Sets the current imu number to the one given as an argument.
      Parameters:
      floorNum -
    • waitForFloor

      public Justification waitForFloor(int targetFloorNum)
      Wait up to timeout for the target floor to be reached.
      Parameters:
      targetFloorNum -
      Returns: