Code covered by the BSD License  

Highlights from
NXT-LTD: Line Tracking Dancing Robot Demo

NXT-LTD: Line Tracking Dancing Robot Demo

by

 

23 May 2013 (Updated )

Modeling Logic for Robot Control with Simulink and Stateflow

allBusObjects()
function allBusObjects() 
% ALLBUSOBJECTS initializes a set of bus objects in the MATLAB base workspace 
%
% Copyright 2013 The MathWorks, Inc.    

% Bus object: CartesianTrajectory 

clear elems;
elems(1) = Simulink.BusElement;
elems(1).Name = 'DesiredSpeed';
elems(1).Dimensions = 1;
elems(1).DimensionsMode = 'Fixed';
elems(1).DataType = 'double';
elems(1).SampleTime = -1;
elems(1).Complexity = 'real';
elems(1).SamplingMode = 'Sample based';
elems(1).Min = [];
elems(1).Max = [];
elems(1).DocUnits = sprintf('meter/sec');
elems(1).Description = '';

elems(2) = Simulink.BusElement;
elems(2).Name = 'DesiredRotationRate';
elems(2).Dimensions = 1;
elems(2).DimensionsMode = 'Fixed';
elems(2).DataType = 'double';
elems(2).SampleTime = -1;
elems(2).Complexity = 'real';
elems(2).SamplingMode = 'Sample based';
elems(2).Min = [];
elems(2).Max = [];
elems(2).DocUnits = sprintf('radian/sec');
elems(2).Description = '';

CartesianTrajectory = Simulink.Bus;
CartesianTrajectory.HeaderFile = '';
CartesianTrajectory.Description = '';
CartesianTrajectory.DataScope = 'Auto';
CartesianTrajectory.Alignment = -1;
CartesianTrajectory.Elements = elems;
assignin('base','CartesianTrajectory', CartesianTrajectory)

% Bus object: MotorBus 
clear elems;
elems(1) = Simulink.BusElement;
elems(1).Name = 'TailMotorA';
elems(1).Dimensions = 1;
elems(1).DimensionsMode = 'Fixed';
elems(1).DataType = 'int8';
elems(1).SampleTime = -1;
elems(1).Complexity = 'real';
elems(1).SamplingMode = 'Sample based';
elems(1).Min = [];
elems(1).Max = [];
elems(1).DocUnits = sprintf('Power (-100 to 100)');
elems(1).Description = sprintf('Power Sent to the Tail Motor A');

elems(2) = Simulink.BusElement;
elems(2).Name = 'RightMotorB';
elems(2).Dimensions = 1;
elems(2).DimensionsMode = 'Fixed';
elems(2).DataType = 'int8';
elems(2).SampleTime = -1;
elems(2).Complexity = 'real';
elems(2).SamplingMode = 'Sample based';
elems(2).Min = [];
elems(2).Max = [];
elems(2).DocUnits = sprintf('Power (-100 to 100)');
elems(2).Description = sprintf('Power Sent to the Right Motor (B)');

elems(3) = Simulink.BusElement;
elems(3).Name = 'LeftMotorC';
elems(3).Dimensions = 1;
elems(3).DimensionsMode = 'Fixed';
elems(3).DataType = 'int8';
elems(3).SampleTime = -1;
elems(3).Complexity = 'real';
elems(3).SamplingMode = 'Sample based';
elems(3).Min = [];
elems(3).Max = [];
elems(3).DocUnits = sprintf('Power (-100 to 100)');
elems(3).Description = sprintf('Power Sent to the Left Motor C');

MotorBus = Simulink.Bus;
MotorBus.HeaderFile = '';
MotorBus.Description = '';
MotorBus.DataScope = 'Auto';
MotorBus.Alignment = -1;
MotorBus.Elements = elems;
assignin('base','MotorBus', MotorBus)

% Bus object: RawSensorBus 
clear elems;
elems(1) = Simulink.BusElement;
elems(1).Name = 'Encoders';
elems(1).Dimensions = 3;
elems(1).DimensionsMode = 'Fixed';
elems(1).DataType = 'uint32';
elems(1).SampleTime = -1;
elems(1).Complexity = 'real';
elems(1).SamplingMode = 'Sample based';
elems(1).Min = [];
elems(1).Max = [];
elems(1).DocUnits = sprintf('degrees');
elems(1).Description = sprintf('Encoder readings for the 3 motors, Tail, Right, Left.');

elems(2) = Simulink.BusElement;
elems(2).Name = 'TouchSensor';
elems(2).Dimensions = 1;
elems(2).DimensionsMode = 'Fixed';
elems(2).DataType = 'uint16';
elems(2).SampleTime = -1;
elems(2).Complexity = 'real';
elems(2).SamplingMode = 'Sample based';
elems(2).Min = [];
elems(2).Max = [];
elems(2).DocUnits = sprintf('degrees');
elems(2).Description = sprintf('Touch Sensor');

RawSensorBus = Simulink.Bus;
RawSensorBus.HeaderFile = '';
RawSensorBus.Description = '';
RawSensorBus.DataScope = 'Auto';
RawSensorBus.Alignment = -1;
RawSensorBus.Elements = elems;
assignin('base','RawSensorBus', RawSensorBus)

% % Bus object: SensorBus 
% clear elems;
% elems(1) = Simulink.BusElement;
% elems(1).Name = 'TailPosition';
% elems(1).Dimensions = 1;
% elems(1).DimensionsMode = 'Fixed';
% elems(1).DataType = 'double';
% elems(1).SampleTime = -1;
% elems(1).Complexity = 'real';
% elems(1).SamplingMode = 'Sample based';
% elems(1).Min = [];
% elems(1).Max = [];
% elems(1).DocUnits = sprintf('radians');
% elems(1).Description = '';
% 
% elems(2) = Simulink.BusElement;
% elems(2).Name = 'RightWheelPosition';
% elems(2).Dimensions = 1;
% elems(2).DimensionsMode = 'Fixed';
% elems(2).DataType = 'double';
% elems(2).SampleTime = -1;
% elems(2).Complexity = 'real';
% elems(2).SamplingMode = 'Sample based';
% elems(2).Min = [];
% elems(2).Max = [];
% elems(2).DocUnits = sprintf('radians');
% elems(2).Description = '';
% 
% elems(3) = Simulink.BusElement;
% elems(3).Name = 'LeftWheelPosition';
% elems(3).Dimensions = 1;
% elems(3).DimensionsMode = 'Fixed';
% elems(3).DataType = 'double';
% elems(3).SampleTime = -1;
% elems(3).Complexity = 'real';
% elems(3).SamplingMode = 'Sample based';
% elems(3).Min = [];
% elems(3).Max = [];
% elems(3).DocUnits = sprintf('radians');
% elems(3).Description = '';
% 
% SensorBus = Simulink.Bus;
% SensorBus.HeaderFile = '';
% SensorBus.Description = '';
% SensorBus.DataScope = 'Auto';
% SensorBus.Alignment = -1;
% SensorBus.Elements = elems;
% assignin('base','SensorBus', SensorBus)

% Bus object: TrajectoriesBus 
clear elems;
elems(1) = Simulink.BusElement;
elems(1).Name = 'TailDesiredPosition';
elems(1).Dimensions = 1;
elems(1).DimensionsMode = 'Fixed';
elems(1).DataType = 'double';
elems(1).SampleTime = -1;
elems(1).Complexity = 'real';
elems(1).SamplingMode = 'Sample based';
elems(1).Min = [];
elems(1).Max = [];
elems(1).DocUnits = sprintf('degrees');
elems(1).Description = '';

elems(2) = Simulink.BusElement;
elems(2).Name = 'RightMotorDesiredVelocity';
elems(2).Dimensions = 1;
elems(2).DimensionsMode = 'Fixed';
elems(2).DataType = 'double';
elems(2).SampleTime = -1;
elems(2).Complexity = 'real';
elems(2).SamplingMode = 'Sample based';
elems(2).Min = [];
elems(2).Max = [];
elems(2).DocUnits = sprintf('degrees/second');
elems(2).Description = '';

elems(3) = Simulink.BusElement;
elems(3).Name = 'LeftMotorDesiredVelocity';
elems(3).Dimensions = 1;
elems(3).DimensionsMode = 'Fixed';
elems(3).DataType = 'double';
elems(3).SampleTime = -1;
elems(3).Complexity = 'real';
elems(3).SamplingMode = 'Sample based';
elems(3).Min = [];
elems(3).Max = [];
elems(3).DocUnits = sprintf('degrees/second');
elems(3).Description = '';

TrajectoriesBus = Simulink.Bus;
TrajectoriesBus.HeaderFile = '';
TrajectoriesBus.Description = '';
TrajectoriesBus.DataScope = 'Auto';
TrajectoriesBus.Alignment = -1;
TrajectoriesBus.Elements = elems;
assignin('base','TrajectoriesBus', TrajectoriesBus)

load data.mat

Contact us