I currently have a robot arm model simulated in Gazebo that uses ROS for controls. I have verified that the communication pipeline works using a small ROS publisher I wrote in Python. Now I want to write a Simulink interface to control the robot.
I have been following the nested message tutorial (Task 3), since the JointTrajectory type message is fairly complex and consists of multiple arrays. I created a Matlab function block in Simulink to properly format and prepare my message.
Unfortunately I ran into two problems.
1. I am having issues publishing string arrays, specifically for the trajectory_msgs/JointTrajectory/joint_names field. I have tried various methods such as:
msg.JointNames(1) = 'joint_base_1'
msg.JointNames(1) = rosString('joint_base_1');
where rosString is a short function that does the following:
function msg = rosString(string)
msg = rosmessage('std_msgs/String');
msg.Data = string;
n1 = transpose(uint8('joint_base_1'));
n1 = vertcat(n1, zeros(128-size(n1,1),1));
Does anyone know a way to properly transmit string arrays?
2. After ignoring the joint_names field, I tried just publishing the goal position and velocities. My code for creating the message is as follows:
msg.Points(1).Positions(1) = p1;
msg.Points(1).Velocities(1) = v1;
After creating the message, I also made a Matlab Function Block Parser that seems to correctly retrieve the values. However, after publishing the message, I echo'ed the topic I published the message to and saw the following message being repeated:
rostopic echo /my_robot/joint_trajectory_controller/commands
It seems like my message is not correctly parsed and I am having trouble figuring out the underlying cause.
Thank you for anyone who can provide any hints in debugging.