IEEERobotics / high-level

CV, localization, mapping, planning, and generally anything that will run on the PandaBoard
BSD 2-Clause "Simplified" License
2 stars 1 forks source link

Need sensor code #7

Closed dfarrell07 closed 11 years ago

dfarrell07 commented 11 years ago

Currently, there is no sensor code. Someone should pick this up.

dfarrell07 commented 11 years ago

Each process now receives a serial interface object at process spawn, which can be used to poll any sensor. Nav will handle collecting, packaging and passing sensor values, along with the results of a move returned by comm from the low-level code, to localizer after each move command returns from comm. Given these architectural changes, is there any need for dedicated sensor code @napratin @jschornick @rlsnow @rsrinath85? Can we close this issue and delete the sensor package?

dfarrell07 commented 11 years ago

The following functions in comm.SerialCommand handle this use case. Therefore, we don't need sensor code and this issue can be closed.

  def getAllSensorData(self):
    return self.runCommand("sensors")  # return the entire dict full of sensor data

  def getSensorData(self, sensorId):
    """Fetches current value of a sensor. Handles only scalar sensors, i.e. ones that return a single int value."""
    response = self.runCommand("sensor {sensorId}".format(sensorId=sensorId))
    # TODO timestamp sensor data here?
    return int(response.get('data', -1))  # NOTE this only handles single-value data

  def getSensorDataByName(self, sensorName):
    sensorId = sensors.get(sensorName, None)
    if sensorId is not None:
      return self.getSensorValue(sensorId)
    else:
      return -1