ROS action client sendGoalAndWait error: Java exception occurred: java.lang.​​NullPoint​e​rExcepti​on

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
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!
  1 个评论
Ben Lu
Ben Lu 2018-5-17
编辑:Ben Lu 2018-5-17
Hello @Ivan Belyaev, I have solved my issue. This is my solution writed in a Chinese blog Matlab generate ROS action message type from ROS packages . You should generate ROS action message that will be used in matlab by yourself from your ROS packages.
2. Compile your packages in ROS, you will find .msg file, I find the action message generated by matlab was based on these .msg file and package.xml file;
3. Create your message refer to Create Custom Messages from ROS Package

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Specialized Messages 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by