I have to make a 2D Map of an outline around which I moved my robot

3 visualizaciones (últimos 30 días)
Muhammad
Muhammad el 8 de Dic. de 2022
Respondida: Ayush el 5 de Sept. de 2023
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.

Respuestas (1)

Ayush
Ayush el 5 de Sept. de 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

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by