parameters: (ros_traj,robot=None,joint_link_indices=None)
docstring: Returns a Klamp't Trajectory or RobotTrajectory for a JointTrajectory
      message.
  
      Args:
          ros_traj (sensor_msgs.msg.JointTrajectory): the JointTrajectory object
          robot (RobotModel): the robot, optional
          joint_link_indices (dict, optional): if given, maps ROS joint names to
              Klampt link indices.  Default uses the Klamp't link names.
docstring_summary: Returns a Klamp't Trajectory or RobotTrajectory for a JointTrajectory
      message.
docstring_tokens: Returns a Klamp t Trajectory or RobotTrajectory for a JointTrajectory message .
function: def from_JointTrajectory(ros_traj,robot=None,joint_link_indices=None):
      """Returns a Klamp't Trajectory or RobotTrajectory for a JointTrajectory
      message.
  
      Args:
          ros_traj (sensor_msgs.msg.JointTrajectory): the JointTrajectory object
          robot (RobotModel): the robot, optional
          joint_link_indices (dict, optional): if given, maps ROS joint names to
              Klampt link indices.  Default uses the Klamp't link names.
  
      """
      from klampt.model.trajectory import Trajectory,RobotTrajectory
      if robot is None:
          res = Trajectory()
          for i in range(len(ros_traj.points)):
              res.times.append(ros_traj.points[i].time_from_start.toSec())
              res.milestones.append([v for v in ros_traj.points[i].positions])
          return res
      else:
          res = RobotTrajectory(robot)
          q0 = robot.getConfig()
          if joint_link_indices is None:
              joint_link_indices = dict()
              for i in xrange(robot.numLinks()):
                  joint_link_indices[robot.link(i).getName()] = i
          indices = []
          if len(ros_traj.joint_names) > 0:
              for n in ros_traj.joint_names:
                  if n not in joint_link_indices:
                      raise ValueError("ROS joint name %s is invalid"%(n,))
                  indices = joint_link_indices[n]
          for i in range(len(ros_traj.points)):
              res.times.append(ros_traj.points[i].time_from_start.toSec())
              for j,k in enumerate(indices):
                  q0[k] = ros_traj.points[i].positions[j]
              res.milestones.append([v for v in q0])
          return res
function_tokens: def from_JointTrajectory ( ros_traj , robot = None , joint_link_indices = None ) : from klampt . model . trajectory import Trajectory , RobotTrajectory if robot is None : res = Trajectory ( ) for i in range ( len ( ros_traj . points ) ) : res . times . append ( ros_traj . points [ i ] . time_from_start . toSec ( ) ) res . milestones . append ( [ v for v in ros_traj . points [ i ] . positions ] ) return res else : res = RobotTrajectory ( robot ) q0 = robot . getConfig ( ) if joint_link_indices is None : joint_link_indices = dict ( ) for i in xrange ( robot . numLinks ( ) ) : joint_link_indices [ robot . link ( i ) . getName ( ) ] = i indices = [ ] if len ( ros_traj . joint_names ) > 0 : for n in ros_traj . joint_names : if n not in joint_link_indices : raise ValueError ( "ROS joint name %s is invalid" % ( n , ) ) indices = joint_link_indices [ n ] for i in range ( len ( ros_traj . points ) ) : res . times . append ( ros_traj . points [ i ] . time_from_start . toSec ( ) ) for j , k in enumerate ( indices ) : q0 [ k ] = ros_traj . points [ i ] . positions [ j ] res . milestones . append ( [ v for v in q0 ] ) return res