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

I solved it now.

Thank you dornhege for your help and effort, this ".append()" was really the important part. Still, what I missed was the concrete access to affect sub-objects of "points". The problem was solved with the following code:

        # Define the goal for the ActionServer
        goal1=FollowJointTrajectoryGoal()  #create an empty goal
        goal1.trajectory.points.append(trajectory_msgs.msg.JointTrajectoryPoint(positions = [296.82, 294.143, 523.638, -46.3056, 71.3728, -137.832]) )   #append a JointTrajectoryPoint with specified positions which becomes goal1.trajectory.points[0]

        # Add a state to the container
        smach.StateMachine.add('PTP1',
            smach_ros.SimpleActionState('SiliaAction_TrajServer', 
                                     FollowJointTrajectoryAction, 
                                     goal = goal1
                                   ),
            transitions={'succeeded':'NextState'})

The appended point automatically got the entry "positions" with the instantiation (with the above line). This is not visible however, if no point is appended to it, as in my original case.

Now if I print out goal1:

trajectory: 
  header: 
    seq: 0
    stamp: 
      secs: 0
      nsecs: 0
    frame_id: ''
  joint_names: []
  points: 
    - 
      positions: [296.82, 294.143, 523.638, -46.3056, 71.3728, -137.832]
      velocities: []
      accelerations: []
      time_from_start: 
        secs: 0
        nsecs: 0
path_tolerance: []
goal_tolerance: []
goal_time_tolerance: 
  secs: 0
  nsecs: 0

I solved it now.

Thank you dornhege for your help and effort, this ".append()" was really the important part. Still, what I missed was the concrete access to affect sub-objects of "points". The problem was solved with the following code:

        # Define the goal for the ActionServer
        goal1=FollowJointTrajectoryGoal()  #create an empty goal
        goal1.trajectory.points.append(trajectory_msgs.msg.JointTrajectoryPoint(positions = [296.82, 294.143, 523.638, -46.3056, 71.3728, -137.832]) )   #append a JointTrajectoryPoint with specified positions which becomes goal1.trajectory.points[0]

        # Add a state to the container
        smach.StateMachine.add('PTP1',
            smach_ros.SimpleActionState('SiliaAction_TrajServer', 
                                     FollowJointTrajectoryAction, 
                                     goal = goal1
                                   ),
            transitions={'succeeded':'NextState'})

The appended point automatically got the entry "positions" with the instantiation (with the above line). This is not visible however, if no point is appended to it, as in my original case.

Now if I print out goal1:

trajectory: 
  header: 
    seq: 0
    stamp: 
      secs: 0
      nsecs: 0
    frame_id: ''
  joint_names: []
  points:   # here it is
    - 
      positions: [296.82, 294.143, 523.638, -46.3056, 71.3728, -137.832]
      velocities: []
      accelerations: []
      time_from_start: 
        secs: 0
        nsecs: 0
path_tolerance: []
goal_tolerance: []
goal_time_tolerance: 
  secs: 0
  nsecs: 0