Code covered by the BSD License  

Highlights from
NXT Ballbot (Self-Balancing Robot On A Ball) Controller Design

image thumbnail

NXT Ballbot (Self-Balancing Robot On A Ball) Controller Design

by

 

NXT Ballbot Model-Based Design based on Embedded Coder Robot NXT.

post_sdo_codegen.m
% Post-Processing of Code Generation with Simulink Data Object
% Recover the variables and signal resolutions to pre-code generation.

% clear signal objects
cmd = 'clear';
for n = 1:length(sig.name)
	cmd = [cmd, ' ', sig.name{n}];
end
eval(cmd)

% reset signal resolution
for n = 1:length(sig.handle.Signals)
	set_param(sig.handle.Signals(n), 'MustResolveToSignalObject', 'off')
end
for n = 1:length(sig.handle.States)
	set_param(sig.handle.States(n), 'StateMustResolveToSignalObject', 'off')
end

% clear parameter objects
cmd = 'clear';
for m = 1:length(param)
	for n = 1:param{m}.num
		cmd = [cmd, ' ', param{m}.name{n}];
	end
end
eval(cmd)

% make parameter data
cmd = [];
for m = 1:length(param)
	for n = 1:param{m}.num
		cmd = [cmd, param{m}.name{n}, ' = param{', num2str(m), '}.value{', num2str(n), '};'];
	end
end
eval(cmd)

% restore [Function-Call source] parameter of
% the Exported Function-Calls Scheduler block
set_param(scheduler{1}, 'fctrigger', '[0, ts1, ts2, ts3]')

clear m n cmd sig param scheduler

Contact us