Package edu.tufts.hrilab.imu
Class FloorCalculatorComponent
java.lang.Object
edu.tufts.hrilab.diarc.DiarcComponent
edu.tufts.hrilab.imu.FloorCalculatorComponent
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.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class edu.tufts.hrilab.diarc.DiarcComponent
executionLoopCycleTime, log, shouldRunExecutionLoop
-
Constructor Summary
ConstructorsConstructorDescriptionThe constructor sets all the variables for calculating the displacement to default values. -
Method Summary
Modifier and TypeMethodDescriptionprotected List<org.apache.commons.cli.Option>
Adds the config parameter to FloorCalculator which takes a .json file.protected void
adjustDisplacement
(Double timeFrame) Changes the verticalDisplacement based on the acceleration averages through double integration; indicates stop moving when the velocity is virtually 0int
Retrieves what imu the robot is currently on.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()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 floorHeightsvoid
setFloorNum
(int floorNum) Sets the current imu number to the one given as an argument.waitForFloor
(int targetFloorNum) Wait up to timeout for the target floor to be reached.Methods inherited from class edu.tufts.hrilab.diarc.DiarcComponent
createInstance, createInstance, createInstance, createInstance, executionLoop, getMyGroupConstraints, getMyGroups, getMyService, getMyServices, init, main, shutdown, shutdownComponent
-
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
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
Changes the verticalDisplacement based on the acceleration averages through double integration; indicates stop moving when the velocity is virtually 0- Parameters:
timeFrame
-
-
additionalUsageInfo
Adds the config parameter to FloorCalculator which takes a .json file.- Overrides:
additionalUsageInfo
in classDiarcComponent
- 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 classDiarcComponent
- 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
Wait up to timeout for the target floor to be reached.- Parameters:
targetFloorNum
-- Returns:
-