Skip to content

GetTFTransformState tf2 migration #2

@AravindaDP

Description

@AravindaDP

Hi,

I got following exception during a state machine execution which ended up on state machine exiting execution flow due to uncaught exception instead failed outcome at state level. (Note: Looked up transform is an intermittently published TF and failed outcome is the expected outcome when a recent TF publish is not available.)

[INFO] [1597761806.732714, 125.272000]: Getting transform for target = artifact_origin, source = TYPE_HELMET

[ERROR] [1597761824.168765, 129.276000]: InvalidUserCodeError: Could not execute state 'Get_Artifact_Pose' of type '<vigir_flexbe_states.get_tf_transform_state.GetTFTransformState object at 0x7f8e20028e50>': Traceback (most recent call last):
  File "/opt/ros/melodic/lib/python2.7/dist-packages/smach/state_machine.py", line 247, in _update_once
    self._remappings[self._current_label]))
  File "/opt/ros/melodic/lib/python2.7/dist-packages/flexbe_core/core/event_state.py", line 62, in _event_execute
    self.on_enter(*args, **kwargs)
  File "/opt/ros/melodic/lib/python2.7/dist-packages/flexbe_core/state_logger.py", line 105, in event_wrapper
    event_method(*args, **kwargs)
  File "/opt/ros/melodic/lib/python2.7/dist-packages/flexbe_core/state_logger.py", line 167, in on_enter_wrapper
    on_enter_method(userdata)
  File "/home/pramuditha/subt_solution/src/vigir_flexbe_states/src/vigir_flexbe_states/get_tf_transform_state.py", line 63, in on_enter
    listener.waitForTransform(target_frame, source_frame, now, rospy.Duration(4.0))
  File "/opt/ros/melodic/lib/python2.7/dist-packages/tf/listener.py", line 76, in waitForTransform
    raise tf2_ros.TransformException(error_msg or "no such transformation: \"{}\" -> \"{}\"".format(source_frame, target_frame))
TransformException: canTransform: source_frame TYPE_HELMET does not exist.

[ERROR] [1597761824.170464, 129.276000]: Behavior execution failed!

I guess this is due to newer ros versions (melodic in my case) uses tf2 instead tf package. I managed to resolve this by importing tf2_ros package and adding above exception to https://github.com/team-vigir/vigir_behaviors/blob/master/vigir_flexbe_states/src/vigir_flexbe_states/get_tf_transform_state.py#L76.

If it is the correct way to resolve this, I would be more than happy to make a PR for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions