Subscripted Assignment to Create Array Element
Show older comments
Hi,
I am using MATLAB with Robotics System Toolbox. I am running a Gazebo simulation in ROS that I want MATLAB to talk to. In particular, I want to make a node for a given topic related to that simulation. The way to do this is following (as I understood from the tutorials and examples):
pub_cmd=rospublisher('<any topic that receives commands>');
pub_cmd_msg=rosmessage(pub_cmd)
Now, pub_cmd_msg returns the following:
pub_cmd_msg =
ROS JointTrajectory message with properties:
MessageType: 'trajectory_msgs/JointTrajectory'
Header: [1x1 Header]
JointNames: {0x1 cell}
Points: [0x1 JointTrajectoryPoint]
Use showdetails to show the contents of the message.
Now as I try to assign some values to different fields in this pub_cmd_msg, I get the following error:
pub_cmd_msg.Points
ans =
0x1 ROS JointTrajectoryPoint message array with properties:
MessageType
TimeFromStart
Positions
Velocities
Accelerations
Effort
>> pub_cmd_msg.Points.Positions=ones(1,7)
Property assignment is not allowed when the object is empty. Use subscripted assignment to create an array element.
I have no idea what the error means and how can subscripted assignment help? Kindly guide how can I solve this problem.
Accepted Answer
More Answers (2)
Yinai Fan
on 31 Oct 2016
0 votes
Hi I got the same problem, did you solve it? Thank you.
Umer Huzaifa
on 26 Apr 2017
0 votes
Categories
Find more on Publishers and Subscribers in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!