ROS action client sendGoalAndWait error: Java exception occurred: java.lang.NullPointerException
10 次查看(过去 30 天)
显示 更早的评论
My ROS and matlab are both in Ubuntu system. I'm learning sending action goal messages to ROS by matlab. I run example: "Send and Cancel ROS Action Goals" in matlab, but error occurred. It showed "Java exception occurred: java.lang.NullPointerException". I don't know how to solve this problem. So thanks for who can help me.

-----------------------------------------------------------------------------------------------------------------------

回答(1 个)
Ivan Belyaev
2018-5-16
编辑:Ivan Belyaev
2018-5-16
Dear Matlab, I have exact the same problem as Ben Lu except that I use FollowJointTrajectory. I have suspicion that some Java or Matlab ROS update destroyed actionclient in matlab. I tried the simple example from https://de.mathworks.com/help/robotics/ref/sendgoal.html. That works fluently, but with the code below it does not work.
Im working on mac 10.12.6 and have R2017b. Same problem had workmate with windows 10 and R2018.
On sendGoal(youbotClient,youbotGoalMsgs) it throws this:

Here is listing of my matlab program
function kuka_simulink_ros_action
global youbotClient youbotGoalMsgs;
[youbotClient,youbotGoalMsgs] = rosactionclient('/moveit/arm_controller/follow_joint_trajectory', 'control_msgs/FollowJointTrajectory');
waitForServer(youbotClient);
youbotGoalMsgs.Trajectory.JointNames = {'arm_joint_1','arm_joint_2','arm_joint_3','arm_joint_4','arm_joint_5','virtual_theta', 'virtual_x','virtual_y'};
youbotGoalMsgs.GoalTimeTolerance = rosduration(0,500000000);
points = rosmessage('trajectory_msgs/JointTrajectoryPoint');
trajectory = evalin('base', 'youbotTrajectory');
trj = trajectory.Data;
for i=1:length(trajectory.Data)
points(i) = rosmessage('trajectory_msgs/JointTrajectoryPoint');
points(i).Positions = [trj(i,4),trj(i,5),trj(i,6),trj(i,7),trj(i,8),trj(i,1),trj(i,2),trj(i,3)];
points(i).Velocities = [0,0,0,0,0,0,0,0];
points(i).Accelerations = [0,0,0,0,0,0,0,0];
points(i).TimeFromStart = rosduration(trajectory.Time(i));
end
youbotGoalMsgs.Trajectory.Points = points;
sendGoal(youbotClient,youbotGoalMsgs);
%delete(youbotClient);
end
PS One month ago exact the same code did worked!
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Specialized Messages 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!