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

KeyError in localizer #31

Closed dfarrell07 closed 11 years ago

dfarrell07 commented 11 years ago

I'm seeing the following error in localizer, both running from comm and controller.

Traceback (most recent call last):
  File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "../../localizer/localizer.py", line 55, in run
    localizer.update(sensors)
  File "../../localizer/particles.py", line 38, in update
    self.calc_weights(measured)
  File "../../localizer/particles.py", line 74, in calc_weights
    prob[i] *= ngaussian(self.p.sensed[name][i], 5.0, measured[name])
KeyError: 'front'

@napratin and I are working with the bot right now, so I haven't looked into this in detail. At first glance I guess it's a problem indexing into the sensor data, maybe caused by the fact that's front is in a nested dict. Just a guess, haven't even looked at the code.

dfarrell07 commented 11 years ago

Yeah, seeing this on the bot as well.

jschornick commented 11 years ago

That's expected if there is a mismatch between the object you're providing via sensorData and the dict I'm using with the fake IPC channel. If you give me an example of what to expect from sensorData, I can make them consistent. You may want to switch to DumbLocalizer if you don't see a quick fix before I get to it.

napratin commented 11 years ago

The shared Google doc "Serial communication API (text)" should contain the most updated (and final) dict format for sensor data returned (among other things). Look for getAllSensorData() in High-level methods column. Assuming @dfarrell07 preserves this structure when converting sensor values to appropriate units, this is what you should expect.

dfarrell07 commented 11 years ago

Sorry, meant to respond to this earlier. I referenced the document @napratin linked to above, so unless it changed or I made a mistake, it should be the same. Here's an example of the sensor data dict (you can get this by running nav via test cases or controller and then inspecting the log).

2013-04-02 16:46:41,854 | INFO | nav.py | getSensorData | 540 | Sensor data from comm: {'accel': {'x': 0, 'y': 0, 'z': 980},
 'heading': 0,
 'id': 0,
 'msg': 'This is fake',
 'result': True,
 'ultrasonic': {'back': 100, 'front': 100, 'left': 100, 'right': 100}}
2013-04-02 16:46:41,855 | INFO | nav.py | getSensorData | 544 | Converted sensor data: {'accel': {'x': 0, 'y': 0, 'z': 980},
 'heading': 0.0,
 'id': 0,
 'msg': 'This is fake',
 'result': True,
 'ultrasonic': {'back': 1.3385833999999999,
                'front': 1.3385833999999999,
                'left': 1.3385833999999999,
                'right': 1.3385833999999999}}
jschornick commented 11 years ago

@napratin -- thank you for the (now, in hindsight, obvious) pointers to the documentation. I should have looked there right away.

@dfarrell07 -- I'll fix this right now so that it (at least) works with the sample data you provided. I'll update here when it's pushed.

jschornick commented 11 years ago

Quick fix pushed in SHA: e563a6af7e02f5986557ff02cfe832106468abe5

Please confirm that the new SensorData handling works on your end.

dfarrell07 commented 11 years ago

Seems to work.