Plotting multiple inputs with a Simulated TurtleBot
3 views (last 30 days)
I’m working with a Simulated TurtleBot in the Gazebo environment (Get Started with Gazebo and Simulated TurtleBot - MATLAB & Simulink - MathWorks Benelux). I can give commands to this TurtleBot via MATLAB to plot arbitrary trajectories, as shown in Figure ;
I defined a function for each English alphabet in which the output will be the plotted letter. I can call these functions from another script related to the TurtleBot, and it will start to print the desired note, as follows
% function path_A = A
% Start with figure
f = figure();
% letter A
The challenge that I face now, I want to give more than one input;
%Insert a letter:
Usertext = input('Insert a letter:');
it’s important to notice I need to shift the x values of each second letter, third letter, etc., maybe with the following command:
path_O=[1 4;2 3; 3 2;4 1];
path_O = path_O + [2*ones(length(path_O),1),zeros(length(path_O),1)];
To have a meaningful name or word at the end.
- How can I give multiple inputs (in my case, letters representing a list with two columns and multiple rows) with a predefined space between each note?
I do appreciate your consideration,
Sakshay on 1 Dec 2022
As per my understanding, you want to receive multiple inputs from a user to give to the robot.
The "input()" function in MATLAB is capable of taking as input, different kinds of data types. These data types can be, integers, double, vector, matrix, string and so on. For your case, to take multiple character inputs, you can take a string as an input from the user. A string is a vector/list of characters which will act as multiple inputs. After taking this string from the user, you can loop over the alphabets in the string one by one and perform your operations accordingly. A sample code would look like:
% Take input from user
% Sample inputs: 'PATH', 'TURTLE', 'BOT', etc...
uinput = input('Enter string\n');
% Loop over the alphabets of the string
% Other processing for each alphabet
You can refer to the documentation on "input()" for more information on the same: