parameters: (sensor,T,link=None)
docstring: Given a link-mounted sensor (e.g., CameraSensor or ForceSensor), sets 
      its link-local transform to T.
  
      Args:
          sensor (SimRobotSensor)
          T (se3 element or coordinates.Frame): desired local coordinates of the sensor
              on its link.
          link (int or RobotModelLink, optional): if provided, the link of the
              sensor is modified. 
  
      Another way to set a sensor is to give a coordinates.Frame object.  This
      frame must either be associated with a RobotModelLink or its parent should
      be associated with  one.
  
      (the reason why you should use this is that the Tsensor attribute has a
      particular format using the loader.writeSe3 function.)
docstring_summary: Given a link-mounted sensor (e.g., CameraSensor or ForceSensor), sets 
      its link-local transform to T.
docstring_tokens: Given a link - mounted sensor ( e . g . CameraSensor or ForceSensor ) sets its link - local transform to T .
function: def set_sensor_xform(sensor,T,link=None):
      """Given a link-mounted sensor (e.g., CameraSensor or ForceSensor), sets 
      its link-local transform to T.
  
      Args:
          sensor (SimRobotSensor)
          T (se3 element or coordinates.Frame): desired local coordinates of the sensor
              on its link.
          link (int or RobotModelLink, optional): if provided, the link of the
              sensor is modified. 
  
      Another way to set a sensor is to give a coordinates.Frame object.  This
      frame must either be associated with a RobotModelLink or its parent should
      be associated with  one.
  
      (the reason why you should use this is that the Tsensor attribute has a
      particular format using the loader.writeSe3 function.)
      """
      if isinstance(T,coordinates.Frame):
          if isinstance(T._data,RobotModelLink):
              #attach it directly to the link
              return set_sensor_xform(sensor,se3.identity(),T._data)
          parent = None
          if T.parent() is None:
              parent = -1
          else:
              #assume its parent is a link?
              parent = T.parent()._data
          return set_sensor_xform(sensor,T.relativeCoordinates(),parent)
      try:
          s = sensor.getSetting("Tsensor")
      except Exception:
          raise ValueError("Sensor does not have a Tsensor attribute")
      sensor.setSetting("Tsensor",loader.writeSe3(T))
      if link != None:
          if isinstance(link,RobotModelLink):
              sensor.setSetting("link",str(link.index))
          else:
              assert isinstance(link,int),"Can only set a sensor transform to a RobotModelLink or an integer link index"
              sensor.setSetting("link",str(link))
function_tokens: def set_sensor_xform ( sensor , T , link = None ) : if isinstance ( T , coordinates . Frame ) : if isinstance ( T . _data , RobotModelLink ) : #attach it directly to the link return set_sensor_xform ( sensor , se3 . identity ( ) , T . _data ) parent = None if T . parent ( ) is None : parent = - 1 else : #assume its parent is a link? parent = T . parent ( ) . _data return set_sensor_xform ( sensor , T . relativeCoordinates ( ) , parent ) try : s = sensor . getSetting ( "Tsensor" ) except Exception : raise ValueError ( "Sensor does not have a Tsensor attribute" ) sensor . setSetting ( "Tsensor" , loader . writeSe3 ( T ) ) if link != None : if isinstance ( link , RobotModelLink ) : sensor . setSetting ( "link" , str ( link . index ) ) else : assert isinstance ( link , int ) , "Can only set a sensor transform to a RobotModelLink or an integer link index" sensor . setSetting ( "link" , str ( link ) )