I have to make a 2D Map of an outline around which I moved my robot
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have the x coordinates, the y coordinates from the starting point. I also have the angle and the distance from the obstacle from the left side of the robot using an IR sensor. I have the formula on how tto do it + what the expected result might look like. I am not very experienced in Matlab so am not able to write the code. Like I have to take sin of a whole table of values which results in an error. The graph is supposed to be localized from the starting point as the origin which also I do not understand how to do. The sample output and the reading are attached below if they help.
0 Kommentare
Antworten (1)
Ayush
am 5 Sep. 2023
Hi Muhammad,
I understand that you would like to create a 2D map for your robot’s movement.
It can be done in the following manner:
1. After importing the table from the .xlsx file as a matrix, extract the columns individually for “x”, “y”, “theta” and “r”.
2. With the given equation, use the “sin” and “cos” function to calculate the values with the theta column. You can refer to the below documentation to know more about the “sin” and “cos” function:
3. Solve for “x1” and “y1” by doing symbolic array multiplication using the “.*” operation. You can refer to the below documentation to know more about symbolic array multiplication:
Here is the code snippet for the same:
x1=x+xr.*theta_vec_cos-yr.*theta_vec_sin;
y1=y+xr.*theta_vec_sin+yr.*theta_vec_cos;
4. Use the “scatter” function to plot the resulting “x1” and “y1” vectors. You can refer to the below documentation to know more about the “scatter” function:
Hope it helps,
Regards,
Ayush Misra
0 Kommentare
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!