ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Ok, I figured out whats wrong. The problem is trivial, but because of the exception handling it was quite complicated to figure out whats wrong there.

Orientation values are completely OK, exception rises when grasp_quality value is serialized. I'm returning std_msgs/Float32 as a grasp_quality value. Fix is very easy:

g.grasp_quality = grasps[0].score #WRONG! returns std_msgs/Float32
g.grasp_quality = grasps[0].score.data #returns float

Now interesting part. Why exception returns orientation values? Lets look how that data is serialized in _PickupActionGoal.py (autogenerated code :/):

_v14 = _v12.orientation
_x = _v14 
buff.write(_get_struct_4d().pack(_x.x, _x.y, _x.z, _x.w))
buff.write(_get_struct_d().pack(val1.grasp_quality)

#and part where exception is handled
except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))

Simply error printing uses _x to provide information where exception occured, but before writing grasp_quality value to buff _x is not updated, so it still contains orientation values, and those values are printed...

For me that looks like a bug, IMO _x should be updated before every buff.write(...).

Ok, I figured out whats wrong. The problem is trivial, but because of the exception handling it was quite complicated to figure out whats wrong there.

Orientation values are completely OK, exception rises when grasp_quality value is serialized. I'm returning std_msgs/Float32 as a grasp_quality value. Fix is very easy:

g.grasp_quality = grasps[0].score #WRONG! returns std_msgs/Float32
g.grasp_quality = grasps[0].score.data #returns float

Now interesting part. Why exception returns orientation values? Lets look how that data is serialized in _PickupActionGoal.py (autogenerated code :/):

_v14 = _v12.orientation
_x = _v14 
buff.write(_get_struct_4d().pack(_x.x, _x.y, _x.z, _x.w))
buff.write(_get_struct_d().pack(val1.grasp_quality)
buff.write(_get_struct_d().pack(val1.grasp_quality) #bum, error

#and part where exception is handled
except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))

Simply error printing uses _x to provide information where exception occured, but before writing grasp_quality value to buff _x is not updated, so it still contains orientation values, and those values are printed...

For me that looks like a bug, IMO _x should be updated before every buff.write(...).

Ok, I figured out whats wrong. The problem is trivial, but because of the exception handling it was quite complicated to figure out whats wrong there.

Orientation values are completely OK, exception rises when grasp_quality value is serialized. I'm returning std_msgs/Float32 as a grasp_quality value. Fix is very easy:

g.grasp_quality = grasps[0].score #WRONG! returns std_msgs/Float32
g.grasp_quality = grasps[0].score.data #returns float

Now interesting part. Why exception returns orientation values? Lets look how that data is serialized in _PickupActionGoal.py (autogenerated code :/):

_v14 = _v12.orientation
_x = _v14 
buff.write(_get_struct_4d().pack(_x.x, _x.y, _x.z, _x.w))
buff.write(_get_struct_d().pack(val1.grasp_quality) #bum, #boom, error

#and part where exception is handled
except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))

Simply error printing uses _x to provide information where exception occured, but before writing grasp_quality value to buff _x is not updated, so it still contains orientation values, and those values are printed...

For me that looks like a bug, IMO _x should be updated before every buff.write(...).