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

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개)

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

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

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Specialized Messages에 대해 자세히 알아보기

질문:

2018년 1월 21일

편집:

2018년 5월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by