I am struggling to modify the “Highway lane change” example.
I am trying to implement the "Highway lane change" example with my own controller. Initially I designed my controller such that if I can provide the controller a reference path ( in the form of a N*2 matrix) the controller will be able to follow that path. Now I want to extend my project such that the reference path will be generated autonomously with the help of sensor fusion. I can see the similar thing has been done in the "Highway lane change" project. But for my controller I need to extract the reference X and Y values. But I am struggling to find those 2 values. I have tries with a matlab function block with the following code –
function [X_ref, Y_ref] = extractWaypoints(TrajectoryInfo)
% Extract X and Y waypoints from the planned trajectory
optimalTrajIndex = TrajectoryInfo.OptimalTrajectoryIndex;
trajectory = TrajectoryInfo.GlobalTrajectory(optimalTrajIndex).Trajectory;
% Extract X and Y positions
X_ref = trajectory(:, 1);
Y_ref = trajectory(:, 2);
end
But with this I am getting the error, "Error:’Input Port 1′ of ‘MotionPlanner/Ref_waypoints’ expects a bus but receives a nonbus signal from ‘Output Port 1’ of ‘MotionPlanner/MATLAB Function2’."
I am not sure how to work on this example.I am trying to implement the "Highway lane change" example with my own controller. Initially I designed my controller such that if I can provide the controller a reference path ( in the form of a N*2 matrix) the controller will be able to follow that path. Now I want to extend my project such that the reference path will be generated autonomously with the help of sensor fusion. I can see the similar thing has been done in the "Highway lane change" project. But for my controller I need to extract the reference X and Y values. But I am struggling to find those 2 values. I have tries with a matlab function block with the following code –
function [X_ref, Y_ref] = extractWaypoints(TrajectoryInfo)
% Extract X and Y waypoints from the planned trajectory
optimalTrajIndex = TrajectoryInfo.OptimalTrajectoryIndex;
trajectory = TrajectoryInfo.GlobalTrajectory(optimalTrajIndex).Trajectory;
% Extract X and Y positions
X_ref = trajectory(:, 1);
Y_ref = trajectory(:, 2);
end
But with this I am getting the error, "Error:’Input Port 1′ of ‘MotionPlanner/Ref_waypoints’ expects a bus but receives a nonbus signal from ‘Output Port 1’ of ‘MotionPlanner/MATLAB Function2’."
I am not sure how to work on this example. I am trying to implement the "Highway lane change" example with my own controller. Initially I designed my controller such that if I can provide the controller a reference path ( in the form of a N*2 matrix) the controller will be able to follow that path. Now I want to extend my project such that the reference path will be generated autonomously with the help of sensor fusion. I can see the similar thing has been done in the "Highway lane change" project. But for my controller I need to extract the reference X and Y values. But I am struggling to find those 2 values. I have tries with a matlab function block with the following code –
function [X_ref, Y_ref] = extractWaypoints(TrajectoryInfo)
% Extract X and Y waypoints from the planned trajectory
optimalTrajIndex = TrajectoryInfo.OptimalTrajectoryIndex;
trajectory = TrajectoryInfo.GlobalTrajectory(optimalTrajIndex).Trajectory;
% Extract X and Y positions
X_ref = trajectory(:, 1);
Y_ref = trajectory(:, 2);
end
But with this I am getting the error, "Error:’Input Port 1′ of ‘MotionPlanner/Ref_waypoints’ expects a bus but receives a nonbus signal from ‘Output Port 1’ of ‘MotionPlanner/MATLAB Function2’."
I am not sure how to work on this example. highway lane change controller modification MATLAB Answers — New Questions