-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.m
95 lines (63 loc) · 2.35 KB
/
setup.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
%% setup enviroment
% This matlab scrip is meant to create enviroment where you can
% extract information from the simulation and tinker around while developing
% your solution of the challenge.
clear, clc, close all
addpath("utils")
%% Robot properties
% the robot and simulation parameters for the competition are set
% acording to the especification guide. However exploring how this parameters
% affect the performance of your solution is encourage in the hope of
% developing robust algorithms in the face of a variaty of enviroments
axis_width=0.5; %[m]
wheel_radius=0.1; %[m]
encoder_ticks=180;
P_R=[0.18 -0.18]; % rigth sensor position [m]
P_L=[0.18 0.18]; % left sensor position [m]
T_max=4; % Maximum Torque [N m]
% wheel friction coefficient
F_s=3; % static friction [adimensional]
F_b=0.7; % dynamic friction [s/m]
% Mechanic explorer point of view position
camera_angle=0;
camera_displacement= [-1.2 0 0.25];
%% Simulation parameters
obstacles=csvread('obstacles.csv');
model='UNrobot_intermediate/';
% -- IF YOU ARE COMPITING IN PROFESIONAL CATEGORY UNCOMENT THE FOLOWING
% model='UNrobot_pro/';
% load binaryMap
% show(binaryMap)
load_system( model )
get_param([model 'Obstacle Environment'],'obstacles')
Ts=0.1;
t_end=30;
mode='on'; % on/off
paramNameValStruct.SimMechanicsOpenEditorOnUpdate = mode;
my_model=sim(model,paramNameValStruct);
%% information log from simulation
t=my_model.sensors.time;
sensors=my_model.sensors.signals.values;
actuators=my_model.actuators.signals.values;
positions=my_model.positions.signals.values+20;
real_pos=my_model.real_pos.signals.values;
angle=my_model.theta.signals.values;
contact=squeeze( my_model.contact.signals.values);
%lidar=squeeze( my_model.lidar.signals.values);
penalty_contact=sum(abs(diff(contact)))/2;
%% view environment
figure()
hold on
% estimated position:
plot(positions(:,1), positions(:,2))
% This values
plot(real_pos(:,1), real_pos(:,2),"--")
for k=1:size(obstacles,1)
rectangle('Position',obstacles(k,:),'FaceColor',[0 .5 .5 .5])
end
axis equal
xlim([0,40])
ylim([0,40])
xline(0:40,'Color',[0.75 0.75 0.75]), yline(0:1:40,'Color',[0.75 0.75 0.75])
xline(0), yline(0)
title("position")