ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I feel this is more a problem for the Matlab fora, but having written that: the post you link on Matlab Central seems to provide the solution.
Points
is of type JointTrajectoryPoint
, not whatever the output of zeros(6,1)
is.
The post you link also explains this:
We dig a little deeper an find
>> jointMsg.Trajectory.Points ans = 0×1 ROS JointTrajectoryPoint message array with properties: MessageType TimeFromStart Positions Velocities Accelerations Effort
And:
Ok, so we have a JointTrajectoryPoint object. So, we will make a JointTractoryPoint message:
joint_send = rosmessage('trajectory_msgs/JointTrajectoryPoint') joint_send = ROS JointTrajectoryPoint message with properties: MessageType: 'trajectory_msgs/JointTrajectoryPoint' TimeFromStart: [1×1 Duration] Positions: [0×1 double] Velocities: [0×1 double] Accelerations: [0×1 double] Effort: [0×1 double]
And finally:
Now we plug in Positions and velocities
>> joint_send.Positions = zeros(7,1); >> joint_send.Velocities = zeros(7,1);
Now we set our original message
jointMsg.Trajectory.Points = joint_send;
And finally:
Now that your object is no longer empty you can work with it directly.
>> jointMsg.Trajectory.Points.Positions = [1;1;1;1;1;1;1] >> jointMsg.Trajectory.Points.Positions ans = 1 1 1 1 1 1 1
So in the end you can use the syntax you're trying to use, but that's because jointMsg.Trajectory.Points
has been initialised to be a JointTrajectoryPoint
already.
If this doesn't work for you, I'd advice you to post on Matlab Central yourself, showing the sequence of commands you're using and clearly explaining what doesn't work for you.