strands-project/strands_hri

Error in QTC state predictor

Closed this issue · 14 comments

I am launching Gazebo simulation with simulated output of Bayes People Tracker. Along with the simulation, I am also launching the "move_base.launch" and "hrsi.launch" files.

/robot4/online_qtc_creator/qtc_array ROS topic is giving output.

/robot4/qtc_state_predictor/marker_array ROS topic is also giving output.

/robot4/qtc_state_predictor/prediction_array ROS topic is not giving any output.

Launching the "hrsi.launch" file publishes the output for the ROS topics /robot4/robot_pose and /robot4/robot_poseST, but gives the below error.

I would like to know the reason of the error particularly in line 30 of the code "/opt/ros/kinetic/lib/qsr_prob_rep/qsr_prob_rep_ros_server.py".

[WARN] [1542895239.666073, 2641.568000]: [/robot4/qtc_state_predictor]: None state reported, aborting
[ERROR] [1542895240.107102, 2641.869000]: Error processing request: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
['Traceback (most recent call last):\n', '  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py", line 625, in _handle_request\n    response = convert_return_to_response(self.handler(request), self.response_class)\n', '  File "/opt/ros/kinetic/lib/qsr_prob_rep/qsr_prob_rep_ros_server.py", line 30, in <lambda>\n    self.services[service] = rospy.Service("~"+namespace+"/"+service, QSRProbRep, (lambda a,b: lambda x: self.callback(x, a, b))(namespace,service))\n', '  File "/opt/ros/kinetic/lib/qsr_prob_rep/qsr_prob_rep_ros_server.py", line 34, in callback\n    return QSRProbRepResponse(data=self._lib.request(r).get())\n', '  File "/opt/ros/kinetic/lib/python2.7/dist-packages/qsrrep_lib/rep_lib.py", line 57, in request\n    return request_message.call_function(self.modules[namespace], func_name)\n', '  File "/opt/ros/kinetic/lib/python2.7/dist-packages/qsrrep_lib/rep_io.py", line 39, in call_function\n    return getattr(c, f)(**self.kwargs)\n', '  File "/opt/ros/kinetic/lib/python2.7/dist-packages/qsrrep_lib/rep_io.py", line 71, in wrapper\n    return func(self, *args, **kwargs)\n', '  File "/opt/ros/kinetic/lib/python2.7/dist-packages/qsrrep_lib/rep_pf.py", line 51, in update\n    res = self.pf.update(**z)\n', '  File "/opt/ros/kinetic/lib/python2.7/dist-packages/qsrrep_pf/filter.py", line 63, in update\n    kwargs["filter"].bayes(np.array([kwargs["states"].index(obs), np.nan]))\n', '  File "/opt/ros/kinetic/lib/python2.7/dist-packages/qsrrep_pf/particle_filter_base.py", line 82, in bayes\n    self.emp.weights = np.multiply(self.emp.weights, np.exp(self.p_yt_xt.eval_multiple(yt, self.emp.particles)))\n', '  File "/opt/ros/kinetic/lib/python2.7/dist-packages/qsrrep_pf/probability_density_functions.py", line 116, in eval_multiple\n    o = np.array(self.models[self.models.keys()[m]][self.key])[p.astype(int),x[0]]\n', 'IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices\n']
[ERROR] [1542895240.107797, 2641.869000]: service [/robot4/prob_rep_ros_server/pf/update] responded with an error: error processing request: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

It's been a while since I worked on this. Could you please tell me which files you are running exactly so I can reproduce the error?

Could this happen if the model isn't loaded/found?

I propose that @tejaspp creates a simple rosbag with all our topics that cause this error. If you @cdondrup could have a quick look that would be great.

@cdondrup is there an easy way to not use the HMM model, but only the rule-based model initially. I failed to find the correct place to configure this. The idea is to start with a simple rule-based approach in this.

Following on from this, we looked at

{"-1,1,1,1": {"0,0": 1.0}, "1,0,-1,9": {"-1,9": 1.0}, "-1,0,1,0": {"-1,1": 1.0}, "-1,-1,-1,1": {"-1,-1": 0.36403508771929827, "-1,0": 0.039473684210526314, "0,0": 0.5964912280701754}, "0,-1,0,1": {"-1,1": 0.09302325581395349, "-1,0": 0.18604651162790697, "0,0": 0.7209302325581395}, "-1,-1,-1,9": {"1,9": 0.0051813471502590676, "0,9": 0.10880829015544041, "-1,9": 0.8860103626943006}, "0,-1,-1,9": {"0,9": 0.34615384615384615, "-1,9": 0.6538461538461539}, "0,-1,1,-1": {"-1,1": 0.1111111111111111, "1,1": 0.8888888888888888}, "0,-1,0,9": {"0,9": 0.2222222222222222, "1,9": 0.7777777777777778}, "0,1,-1,9": {"1,9": 1.0}, "0,-1,1,1": {"0,0": 0.1497326203208556, "-1,0": 0.06951871657754011, "0,1": 0.016042780748663103, "-1,1": 0.7647058823529411}, "0,-1,1,0": {"-1,1": 0.5555555555555556, "0,1": 0.3888888888888889, "1,1": 0.05555555555555555}, "1,-1,-1,0": {"-1,-1": 0.4, "0,0": 0.4, "-1,1": 0.2}, "1,-1,-1,1": {"-1,-1": 0.0759493670886076, "-1,1": 0.02531645569620253, "-1,0": 0.15822784810126583, "0,0": 0.740506329113924}, "0,-1,1,9": {"0,9": 0.21052631578947367, "1,9": 0.7894736842105263}, "1,-1,-1,-1": {"-1,-1": 0.5, "0,0": 0.5}, "1,-1,-1,9": {"0,9": 0.375, "-1,9": 0.625}, "1,1,1,9": {"0,9": 0.75, "-1,9": 0.25}, "1,1,0,9": {"0,9": 0.5, "1,9": 0.5}, "-1,1,-1,9": {"1,9": 0.5, "0,9": 0.25, "-1,9": 0.25}, "-1,-1,1,0": {"-1,1": 1.0}, "-1,-1,1,1": {"-1,-1": 0.008333333333333333, "0,0": 0.10833333333333334, "-1,0": 0.1, "-1,1": 0.7833333333333333}, "0,-1,-1,1": {"-1,-1": 0.21019108280254778, "-1,1": 0.006369426751592357, "-1,0": 0.03821656050955414, "0,0": 0.7452229299363057}, "0,1,0,9": {"0,9": 0.6666666666666666, "1,9": 0.3333333333333333}, "-1,-1,0,1": {"-1,-1": 0.125, "-1,0": 0.1875, "0,0": 0.6875}, "-1,-1,1,9": {"1,9": 1.0}, "0,1,1,9": {"0,9": 0.5, "-1,9": 0.5}, "1,-1,1,-1": {"1,1": 0.4827586206896552, "0,1": 0.43103448275862066, "-1,1": 0.08620689655172414}, "1,1,-1,-1": {"-1,-1": 1.0}, "-1,0,0,9": {"1,9": 1.0}, "-1,0,-1,9": {"0,9": 0.2, "1,9": 0.8}, "1,-1,0,1": {"-1,1": 0.08695652173913043, "-1,0": 0.21739130434782608, "0,0": 0.6956521739130435}, "1,0,1,9": {"0,9": 0.625, "1,9": 0.375}, "-1,-1,0,9": {"1,9": 0.7777777777777778, "0,9": 0.1111111111111111, "-1,9": 0.1111111111111111}, "1,-1,1,0": {"-1,1": 0.11392405063291139, "0,1": 0.6455696202531646, "1,1": 0.24050632911392406}, "1,-1,1,1": {"1,1": 0.0136986301369863, "0,0": 0.0410958904109589, "-1,0": 0.0136986301369863, "0,1": 0.2054794520547945, "-1,1": 0.726027397260274}, "1,-1,1,9": {"-1,9": 0.002652519893899204, "0,9": 0.1724137931034483, "1,9": 0.8249336870026526}, "0,0,0,9": {"0,9": 0.35714285714285715, "1,9": 0.6428571428571429}, "-1,-1,1,-1": {"0,1": 0.25, "1,1": 0.75}}
Is the format of the rules described somewhere?

It seems to have a problem here: https://github.com/strands-project/strands_qsr_lib/blob/f1e4e5b910c830a7bcb10e9d76722fefd9f3a385/qsr_prob_rep/scripts/qsr_prob_rep_ros_server.py#L30

I'm not sure I fully grasp what this does, @cdondrup What is it supposed to do?

This just creates services that call the functions. It might be that the error happens if a model cannot be found yes. As you said, if you can record a rosbag for me so I can have a look, that would be good.

Following on from this, we looked at

strands_hri/hrsi_state_prediction/models/crossing.rules

Line 1 in 63ff284

{"-1,1,1,1": {"0,0": 1.0}, "1,0,-1,9": {"-1,9": 1.0}, "-1,0,1,0": {"-1,1": 1.0}, "-1,-1,-1,1": {"-1,-1": 0.36403508771929827, "-1,0": 0.039473684210526314, "0,0": 0.5964912280701754}, "0,-1,0,1": {"-1,1": 0.09302325581395349, "-1,0": 0.18604651162790697, "0,0": 0.7209302325581395}, "-1,-1,-1,9": {"1,9": 0.0051813471502590676, "0,9": 0.10880829015544041, "-1,9": 0.8860103626943006}, "0,-1,-1,9": {"0,9": 0.34615384615384615, "-1,9": 0.6538461538461539}, "0,-1,1,-1": {"-1,1": 0.1111111111111111, "1,1": 0.8888888888888888}, "0,-1,0,9": {"0,9": 0.2222222222222222, "1,9": 0.7777777777777778}, "0,1,-1,9": {"1,9": 1.0}, "0,-1,1,1": {"0,0": 0.1497326203208556, "-1,0": 0.06951871657754011, "0,1": 0.016042780748663103, "-1,1": 0.7647058823529411}, "0,-1,1,0": {"-1,1": 0.5555555555555556, "0,1": 0.3888888888888889, "1,1": 0.05555555555555555}, "1,-1,-1,0": {"-1,-1": 0.4, "0,0": 0.4, "-1,1": 0.2}, "1,-1,-1,1": {"-1,-1": 0.0759493670886076, "-1,1": 0.02531645569620253, "-1,0": 0.15822784810126583, "0,0": 0.740506329113924}, "0,-1,1,9": {"0,9": 0.21052631578947367, "1,9": 0.7894736842105263}, "1,-1,-1,-1": {"-1,-1": 0.5, "0,0": 0.5}, "1,-1,-1,9": {"0,9": 0.375, "-1,9": 0.625}, "1,1,1,9": {"0,9": 0.75, "-1,9": 0.25}, "1,1,0,9": {"0,9": 0.5, "1,9": 0.5}, "-1,1,-1,9": {"1,9": 0.5, "0,9": 0.25, "-1,9": 0.25}, "-1,-1,1,0": {"-1,1": 1.0}, "-1,-1,1,1": {"-1,-1": 0.008333333333333333, "0,0": 0.10833333333333334, "-1,0": 0.1, "-1,1": 0.7833333333333333}, "0,-1,-1,1": {"-1,-1": 0.21019108280254778, "-1,1": 0.006369426751592357, "-1,0": 0.03821656050955414, "0,0": 0.7452229299363057}, "0,1,0,9": {"0,9": 0.6666666666666666, "1,9": 0.3333333333333333}, "-1,-1,0,1": {"-1,-1": 0.125, "-1,0": 0.1875, "0,0": 0.6875}, "-1,-1,1,9": {"1,9": 1.0}, "0,1,1,9": {"0,9": 0.5, "-1,9": 0.5}, "1,-1,1,-1": {"1,1": 0.4827586206896552, "0,1": 0.43103448275862066, "-1,1": 0.08620689655172414}, "1,1,-1,-1": {"-1,-1": 1.0}, "-1,0,0,9": {"1,9": 1.0}, "-1,0,-1,9": {"0,9": 0.2, "1,9": 0.8}, "1,-1,0,1": {"-1,1": 0.08695652173913043, "-1,0": 0.21739130434782608, "0,0": 0.6956521739130435}, "1,0,1,9": {"0,9": 0.625, "1,9": 0.375}, "-1,-1,0,9": {"1,9": 0.7777777777777778, "0,9": 0.1111111111111111, "-1,9": 0.1111111111111111}, "1,-1,1,0": {"-1,1": 0.11392405063291139, "0,1": 0.6455696202531646, "1,1": 0.24050632911392406}, "1,-1,1,1": {"1,1": 0.0136986301369863, "0,0": 0.0410958904109589, "-1,0": 0.0136986301369863, "0,1": 0.2054794520547945, "-1,1": 0.726027397260274}, "1,-1,1,9": {"-1,9": 0.002652519893899204, "0,9": 0.1724137931034483, "1,9": 0.8249336870026526}, "0,0,0,9": {"0,9": 0.35714285714285715, "1,9": 0.6428571428571429}, "-1,-1,1,-1": {"0,1": 0.25, "1,1": 0.75}}
Is the format of the rules described somewhere?

These models are created using this script. I am not sure if you still have the data somewhere (which should be qtc state chain files). I will have a look at my HDD at home.

The model describes the look-up table that maps from observation to action:

{
   qtc_state_obs: {qtc_state_act: prob, ...}
   ...
}

where the qtc description is -1 = -, 0 = 0, and 1 = +. The 9 is a special symbol that just means, use the current qtc symbol observed in that position. So this a placeholder for the symbol to be ignored for decision making and just copied for action execution.
However, I am not sure these rules still work because they use QTC_BC and don't seem to use QTC_H. As I said above, if you send me a ros bag, I can look into this.

Running out of time to finish your PhD is never good. Documentation is the first thing you drop ;)

@cdondrup is this all you need? Any idea yet?

Yesterday, I launched the entire simulation without any human being. Therefore, no "spencer_tracked_persons", no "bayes_people_tracker_position", no "qtc_array". When I launched "hrsi.launch" file, the big error is not there. It is launched fine.

Right now looking at these 4 files. Could be error in either of them:

  1. /opt/ros/kinetic/share/hrsi_state_prediction/models/crossing.rules
  2. /opt/ros/kinetic/share/hrsi_state_prediction/models/passby.rules
  3. /opt/ros/kinetic/share/hrsi_state_prediction/models/passby.hmm
  4. /opt/ros/kinetic/share/hrsi_state_prediction/models/crossing.hmm

Sorry, @cdondrup can you comment? It's perfectly fine to say you haven't got a clue and not time to look into in ;-)

It was a ROS version issue. Originally the code generating prediction models was designed for ROS-Indigo. It was updated to ROS-Kinetic and now it works. Many Thanks to @MFernandezCarmona for resolving it.