How to reorientate the orientation of a mobile robot to a specific angle.

Hi there, I wanted to reoreintate my mobile robot to 90 degree angle (point to North side), given that the initial orientation of the mobile robot is randomly generated, how can I do that? Thanks.
target_angle = pi/2;
orientation = 2*pi*rand(1);
angular_velocity = 0.1;
- Shin -

Antworten (1)

Torsten
Torsten am 31 Jan. 2023
Bearbeitet: Torsten am 31 Jan. 2023
You mean change
orientation_old = [2*pi*rand(1),0]
orientation_old = 1×2
1.3872 0
to
orientation_new = fliplr(orientation_old)
orientation_new = 1×2
0 1.3872
?

3 Kommentare

Hi Torsten, I mean changing the pointing direction. For example 1.3872 is the initial orientation, and I want it to rotate to the 90 degree position which pointing upwards. Thanks
So far I have somethig like this,
target_angle = pi/2; % target orientation angle
current_angle = 2*pi*rand(1);; % current orientation angle
angular_velocity = 0.1;
angle_difference = target_angle - current_angle;
% Calculate the time needed to complete the rotation
rotation_time = abs(angle_difference) / angular_velocity;
Yes, the vector "orientation_old" points to the right and the vector "orientation_new" points upwards, thus rotated by 90 degrees.
Like this ?
But it's not clear if the rotation should be clockwise or counter-clockwise, I guess.
rng("default")
target_angle = pi/2; % target orientation angle
current_angle = 2*pi*rand(1); % current orientation angle
omega = 0.1;
angle = @(t) current_angle + omega*t*(target_angle - current_angle)/abs(target_angle - current_angle);
t = linspace(0,abs(target_angle - current_angle)/omega,100);
plot(t,angle(t))

Melden Sie sich an, um zu kommentieren.

Produkte

Version

R2022b

Gefragt:

am 31 Jan. 2023

Kommentiert:

am 31 Jan. 2023

Community Treasure Hunt

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

Start Hunting!

Translated by