Commit 5e97564c authored by TASTE User's avatar TASTE User

Example of accessing the IMU data on-board

parent c38276af
This diff is collapsed.
TASTE-Dataview DEFINITIONS ::=
BEGIN
IMPORTS T-Int32, T-UInt32, T-Int8, T-UInt8, T-Boolean FROM TASTE-BasicTypes;
-- A few simple types to start with ASN.1
MyInteger ::= T-UInt8
MyReal ::= REAL (0.0 .. 1000.0)
MyBool ::= BOOLEAN
MyEnum ::= ENUMERATED { hello, world, howareyou }
MySeq ::= SEQUENCE {
input-data MyInteger,
output-data MyInteger,
validity ENUMERATED { valid, invalid }
}
MyChoice ::= CHOICE {
a BOOLEAN,
b MySeq
}
MySeqOf ::= SEQUENCE (SIZE (2)) OF MyEnum
MyOctStr ::= OCTET STRING (SIZE (3))
-- You can also declare constants
myVar MySeqOf ::= { hello, world }
-- Gyroscope
MyGyroVal ::= REAL (-100000.0 .. 100000.0)
-- Acceleration
MyAccVal ::= REAL (-16.0 .. 16.0)
END
---------------------------------------------------
-- AADL2.0
-- TASTE
--
--
---------------------------------------------------
PACKAGE deploymentview::DV::Node1
PUBLIC
WITH Taste;
WITH Deployment;
WITH TASTE_DV_Properties;
PROCESS cortex_m_partition
END cortex_m_partition;
PROCESS IMPLEMENTATION cortex_m_partition.others
END cortex_m_partition.others;
END deploymentview::DV::Node1;
PACKAGE deploymentview::DV
PUBLIC
WITH ocarina_processors_arm;
WITH deploymentview::DV::Node1;
WITH Taste;
WITH Deployment;
WITH interfaceview::IV;
WITH TASTE_DV_Properties;
SYSTEM Node1
END Node1;
SYSTEM IMPLEMENTATION Node1.others
SUBCOMPONENTS
IV_Control_Laws : SYSTEM interfaceview::IV::Control_Laws.others {
Taste::coordinates => "1123 199 1165 254";
Taste::FunctionName => "Control_Laws";
};
IV_Copter_IMU : SYSTEM interfaceview::IV::Copter_IMU.others {
Taste::coordinates => "1030 194 1095 268";
Taste::FunctionName => "Copter_IMU";
};
cortex_m_partition : PROCESS deploymentview::DV::Node1::cortex_m_partition.others {
Taste::coordinates => "980 137 1190 292";
Deployment::Port_Number => 0;
};
cortex_m_i : PROCESSOR ocarina_processors_arm::cortex_m.i {
Taste::coordinates => "972 106 1213 301";
};
PROPERTIES
Taste::APLC_Binding => (reference (cortex_m_partition)) APPLIES TO IV_Control_Laws;
Taste::APLC_Binding => (reference (cortex_m_partition)) APPLIES TO IV_Copter_IMU;
Actual_Processor_Binding => (reference (cortex_m_i)) APPLIES TO cortex_m_partition;
END Node1.others;
SYSTEM deploymentview
END deploymentview;
SYSTEM IMPLEMENTATION deploymentview.others
SUBCOMPONENTS
Node1 : SYSTEM Node1.others {
Taste::coordinates => "882 80 1235 333";
};
interfaceview : SYSTEM interfaceview::IV::interfaceview.others;
END deploymentview.others;
PROPERTIES
Taste::coordinates => "0 0 2970 2100";
Taste::version => "1.3.19";
Taste::interfaceView => "InterfaceView.aadl";
Taste::HWLibraries => ("../../tool-inst/share/ocarina/AADLv2/ocarina_components.aadl");
END deploymentview::DV;
---------------------------------------------------
-- AADL2.0
-- TASTE
--
--
---------------------------------------------------
PACKAGE interfaceview::FV::Copter_IMU
PUBLIC
WITH Taste;
WITH DataView;
WITH TASTE_IV_Properties;
SUBPROGRAM PI_Pulse
PROPERTIES
Taste::Associated_Queue_Size => 1;
END PI_Pulse;
SUBPROGRAM IMPLEMENTATION PI_Pulse.others
END PI_Pulse.others;
SUBPROGRAM RI_Get_IMU_Data
FEATURES
gyro_X : IN PARAMETER DataView::MyGyroVal {
Taste::encoding => NATIVE;
};
gyro_Y : IN PARAMETER DataView::MyGyroVal {
Taste::encoding => NATIVE;
};
gyro_Z : IN PARAMETER DataView::MyGyroVal {
Taste::encoding => NATIVE;
};
acc_X : IN PARAMETER DataView::MyAccVal {
Taste::encoding => NATIVE;
};
acc_Y : IN PARAMETER DataView::MyAccVal {
Taste::encoding => NATIVE;
};
acc_Z : IN PARAMETER DataView::MyAccVal {
Taste::encoding => NATIVE;
};
END RI_Get_IMU_Data;
SUBPROGRAM IMPLEMENTATION RI_Get_IMU_Data.others
END RI_Get_IMU_Data.others;
END interfaceview::FV::Copter_IMU;
PACKAGE interfaceview::FV::Control_Laws
PUBLIC
WITH Taste;
WITH DataView;
WITH TASTE_IV_Properties;
SUBPROGRAM PI_Get_IMU_Data
FEATURES
gyro_X : IN PARAMETER DataView::MyGyroVal {
Taste::encoding => NATIVE;
};
gyro_Y : IN PARAMETER DataView::MyGyroVal {
Taste::encoding => NATIVE;
};
gyro_Z : IN PARAMETER DataView::MyGyroVal {
Taste::encoding => NATIVE;
};
acc_X : IN PARAMETER DataView::MyAccVal {
Taste::encoding => NATIVE;
};
acc_Y : IN PARAMETER DataView::MyAccVal {
Taste::encoding => NATIVE;
};
acc_Z : IN PARAMETER DataView::MyAccVal {
Taste::encoding => NATIVE;
};
PROPERTIES
Taste::Associated_Queue_Size => 1;
END PI_Get_IMU_Data;
SUBPROGRAM IMPLEMENTATION PI_Get_IMU_Data.others
END PI_Get_IMU_Data.others;
END interfaceview::FV::Control_Laws;
PACKAGE interfaceview::IV
PUBLIC
WITH interfaceview::FV::Copter_IMU;
WITH interfaceview::FV::Control_Laws;
WITH interfaceview::FV;
WITH Taste;
WITH DataView;
WITH TASTE_IV_Properties;
SYSTEM Copter_IMU
FEATURES
PI_Pulse : PROVIDES SUBPROGRAM ACCESS interfaceview::FV::Copter_IMU::PI_Pulse.others {
Taste::coordinates => "815 554";
Taste::RCMoperationKind => cyclic;
Taste::RCMperiod => 50 ms;
Taste::Deadline => 0 ms;
Taste::InterfaceName => "Pulse";
};
RI_Get_IMU_Data : REQUIRES SUBPROGRAM ACCESS interfaceview::FV::Control_Laws::PI_Get_IMU_Data.others {
Taste::coordinates => "1175 770";
Taste::RCMoperationKind => any;
Taste::InterfaceName => "Get_IMU_Data";
Taste::labelInheritance => "true";
};
PROPERTIES
Source_Language => (Ada);
END Copter_IMU;
SYSTEM IMPLEMENTATION Copter_IMU.others
SUBCOMPONENTS
Pulse_impl : SUBPROGRAM interfaceview::FV::Copter_IMU::PI_Pulse.others {
Compute_Execution_Time => 0 ms .. 0 ms;
};
CONNECTIONS
OpToPICnx_Pulse_impl : SUBPROGRAM ACCESS Pulse_impl -> PI_Pulse;
END Copter_IMU.others;
SYSTEM Control_Laws
FEATURES
PI_Get_IMU_Data : PROVIDES SUBPROGRAM ACCESS interfaceview::FV::Control_Laws::PI_Get_IMU_Data.others {
Taste::coordinates => "1652 749";
Taste::RCMoperationKind => unprotected;
Taste::RCMperiod => 0 ms;
Taste::Deadline => 0 ms;
Taste::InterfaceName => "Get_IMU_Data";
};
PROPERTIES
Source_Language => (C);
END Control_Laws;
SYSTEM IMPLEMENTATION Control_Laws.others
SUBCOMPONENTS
Get_IMU_Data_impl : SUBPROGRAM interfaceview::FV::Control_Laws::PI_Get_IMU_Data.others {
Compute_Execution_Time => 0 ms .. 0 ms;
};
CONNECTIONS
OpToPICnx_Get_IMU_Data_impl : SUBPROGRAM ACCESS Get_IMU_Data_impl -> PI_Get_IMU_Data;
END Control_Laws.others;
SYSTEM interfaceview
END interfaceview;
SYSTEM IMPLEMENTATION interfaceview.others
SUBCOMPONENTS
Copter_IMU : SYSTEM interfaceview::IV::Copter_IMU.others {
Taste::coordinates => "477 554 1175 1288";
};
Control_Laws : SYSTEM interfaceview::IV::Control_Laws.others {
Taste::coordinates => "1652 641 2242 1216";
};
CONNECTIONS
Control_Laws_Get_IMU_Data_Copter_IMU_Get_IMU_Data : SUBPROGRAM ACCESS Control_Laws.PI_Get_IMU_Data -> Copter_IMU.RI_Get_IMU_Data {
Taste::coordinates => "1175 770 1413 770 1413 749 1652 749";
};
END interfaceview.others;
PROPERTIES
Taste::dataView => ("DataView");
Taste::dataViewPath => ("DataView.aadl");
Taste::coordinates => "0 0 2970 2100";
Taste::version => "1.3.19";
END interfaceview::IV;
PACKAGE interfaceview::FV
PUBLIC
WITH Taste;
WITH DataView;
WITH TASTE_IV_Properties;
END interfaceview::FV;
1a581aa60db79a447f265befdf5d7465 InterfaceView.aadl
#!/bin/bash
# This script will build your TASTE system (by default with the C runtime).
# You should not change this file as it was automatically generated.
# If you need additional preprocessing, create a file named 'user_init_pre.sh'
# and/or 'user_init_post.sh - They will never get overwritten.'
# Inside these files you may set some environment variables:
# C_INCLUDE_PATH=/usr/include/xenomai/analogy/:${C_INCLUDE_PATH}
unset USE_POHIC
unset USE_POHIADA
CWD=$(pwd)
[ -z "$ADA_PROJECT_PATH" ] && \
export ADA_PROJECT_PATH=$HOME/GitHub/Certyflie/Ada_Drivers_Library/boards
if [ -t 0 ] ; then
COLORON="\e[1m\e[32m"
COLOROFF="\e[0m"
else
COLORON=""
COLOROFF=""
fi
INFO="${COLORON}[INFO]${COLOROFF}"
if [ -f user_init_pre.sh ]
then
echo -e "${INFO} Executing user-defined init script"
source user_init_pre.sh
fi
# Detect models from Ellidiss tools v2, and convert them to 1.3
INTERFACEVIEW=InterfaceView.aadl
grep "version => \"2" InterfaceView.aadl >/dev/null && {
echo -e "${INFO} Converting interface view from V2 to V1.3"
TASTE --load-interface-view InterfaceView.aadl --export-interface-view-to-1_3 __iv_1_3.aadl
INTERFACEVIEW=__iv_1_3.aadl
};
if [ -z "$DEPLOYMENTVIEW" ]
then
DEPLOYMENTVIEW=DeploymentView.aadl
fi
# Detect models from Ellidiss tools v2, and convert them to 1.3
grep "version => \"2" "$DEPLOYMENTVIEW" >/dev/null && {
echo -e "${INFO} Converting deployment view from V2 to V1.3"
TASTE --load-deployment-view "$DEPLOYMENTVIEW" --export-deployment-view-to-1_3 __dv_1_3.aadl
DEPLOYMENTVIEW=__dv_1_3.aadl
};
SKELS="./"
# Update the data view with local paths
taste-update-data-view
cd "$SKELS" && rm -f copter_imu.zip && zip copter_imu copter_imu/* && cd $OLDPWD
cd "$SKELS" && rm -f control_laws.zip && zip control_laws control_laws/* && cd $OLDPWD
[ ! -z "$CLEANUP" ] && rm -rf binary*
if [ -f ConcurrencyView.pro ]
then
ORCHESTRATOR_OPTIONS+=" -w ConcurrencyView.pro "
fi
if [ ! -z "$USE_POHIC" ]
then
OUTPUTDIR=binary.c
ORCHESTRATOR_OPTIONS+=" -p "
elif [ ! -z "$USE_POHIADA" ]
then
OUTPUTDIR=binary.ada
else
OUTPUTDIR=binary
fi
if [ -f user_init_post.sh ]
then
echo -e "${INFO} Executing user-defined init script"
source user_init_post.sh
fi
cd "$CWD" && assert-builder-ocarina.py \
--fast \
--debug \
--aadlv2 \
--keep-case \
--interfaceView "$INTERFACEVIEW" \
--deploymentView "$DEPLOYMENTVIEW" \
-o "$OUTPUTDIR" \
--subAda copter_imu:"$SKELS"/copter_imu.zip \
--subC control_laws:"$SKELS"/control_laws.zip \
--with-extra-Ada-code cortex_m_partition:$HOME/GitHub/Certyflie/config \
--with-extra-Ada-code cortex_m_partition:$HOME/GitHub/Certyflie/drivers \
--with-extra-Ada-code cortex_m_partition:$HOME/GitHub/Certyflie/hal \
--with-extra-Ada-code cortex_m_partition:$HOME/GitHub/Certyflie/lib \
--with-extra-Ada-code cortex_m_partition:$HOME/GitHub/Certyflie/modules \
--with-extra-Ada-code cortex_m_partition:$HOME/GitHub/Certyflie/modules/mahony \
--with-extra-Ada-code cortex_m_partition:$HOME/GitHub/Certyflie/types \
--with-extra-Ada-code cortex_m_partition:$HOME/GitHub/Certyflie/utils \
$ORCHESTRATOR_OPTIONS || exit 1
arm-eabi-objcopy -O binary binary/binaries/cortex_m_partition binary/binaries/cortex_m_partition.flash_image
echo -e "\nNow burn the new image with:\n"
echo " sudo dfu-util -d 0483:df11 -a 0 -s 0x08000000 \\"
echo " -D binary/binaries/cortex_m_partition.flash_image"
MyBool = Simulink.AliasType;
MyBool.BaseType = 'boolean';
MyBool.Description = 'A simple BOOLEAN';
T_Int8 = Simulink.AliasType;
T_Int8.BaseType = 'int8';
T_Int8.Description = 'range is (-128, 127)';
T_UInt32 = Simulink.AliasType;
T_UInt32.BaseType = 'uint32';
T_UInt32.Description = 'range is (0, 4294967295)';
% Values for MyEnum:
MyEnum_value_hello = 0;
MyEnum_value_world = 1;
MyEnum_value_howareyou = 2;
MyEnum = Simulink.AliasType;
MyEnum.BaseType = 'int32';
MyEnum.Description = 'values of ENUMERATED MyEnum';
T_UInt8 = Simulink.AliasType;
T_UInt8.BaseType = 'uint8';
T_UInt8.Description = 'range is (0, 255)';
MyInteger = Simulink.AliasType;
MyInteger.BaseType = 'uint8';
MyInteger.Description = 'range is (0, 255)';
% Values for MySeq-validity:
MySeq_validity_value_valid = 0;
MySeq_validity_value_invalid = 1;
MySeq_validity = Simulink.AliasType;
MySeq_validity.BaseType = 'int32';
MySeq_validity.Description = 'values of ENUMERATED MySeq-validity';
MySeq_elem01=Simulink.BusElement;
MySeq_elem01.name='input_data';
MySeq_elem01.DataType='uint8';
MySeq_elem01.dimensions=1;
MySeq_elem02=Simulink.BusElement;
MySeq_elem02.name='output_data';
MySeq_elem02.DataType='uint8';
MySeq_elem02.dimensions=1;
MySeq_elem03=Simulink.BusElement;
MySeq_elem03.name='validity';
MySeq_elem03.DataType='int32';
MySeq_elem03.dimensions=1;
MySeq = Simulink.Bus;
MySeq.Elements = [MySeq_elem01 MySeq_elem02 MySeq_elem03 ];
MyChoice_elem01=Simulink.BusElement;
MyChoice_elem01.name='choiceIdx';
MyChoice_elem01.DataType='uint8';
MyChoice_elem01.dimensions=1;
MyChoice_elem02=Simulink.BusElement;
MyChoice_elem02.name='a';
MyChoice_elem02.DataType='boolean';
MyChoice_elem02.dimensions=1;
MyChoice_elem03=Simulink.BusElement;
MyChoice_elem03.name='b';
MyChoice_elem03.DataType='MySeq';
MyChoice_elem03.dimensions=1;
MyChoice = Simulink.Bus;
MyChoice.Elements = [MyChoice_elem01 MyChoice_elem02 MyChoice_elem03 ];
MyOctStr_member_data=Simulink.BusElement;
MyOctStr_member_data.name='element_data';
MyOctStr_member_data.DataType='uint8';
MyOctStr_member_data.dimensions=3;
MyOctStr=Simulink.Bus;
MyOctStr.Elements = [MyOctStr_member_data ];
MySeqOf_member_data=Simulink.BusElement;
MySeqOf_member_data.name='element_data';
MySeqOf_member_data.DataType='int32';
MySeqOf_member_data.dimensions=2;
MySeqOf=Simulink.Bus;
MySeqOf.Elements = [MySeqOf_member_data ];
MyGyroVal = Simulink.AliasType;
MyGyroVal.BaseType = 'double';
MyGyroVal.Description = 'range is (-100000.0, 100000.0)';
T_Boolean = Simulink.AliasType;
T_Boolean.BaseType = 'boolean';
T_Boolean.Description = 'A simple BOOLEAN';
MyAccVal = Simulink.AliasType;
MyAccVal.BaseType = 'double';
MyAccVal.Description = 'range is (-16.0, 16.0)';
T_Int32 = Simulink.AliasType;
T_Int32.BaseType = 'int32';
T_Int32.Description = 'range is (-2147483648, 2147483647)';
MyReal = Simulink.AliasType;
MyReal.BaseType = 'double';
MyReal.Description = 'range is (0.0, 1000.0)';
/* User code: This file will not be overwritten by TASTE. */
#include "control_laws.h"
void control_laws_startup()
{
/* Write your initialization code here,
but do not make any call to a required interface. */
}
void control_laws_PI_Get_IMU_Data(const asn1SccMyGyroVal *IN_gyro_X,
const asn1SccMyGyroVal *IN_gyro_Y,
const asn1SccMyGyroVal *IN_gyro_Z,
const asn1SccMyAccVal *IN_acc_X,
const asn1SccMyAccVal *IN_acc_Y,
const asn1SccMyAccVal *IN_acc_Z)
{
/* Write your code here! */
asn1SccMyGyroVal gyro_x = *IN_gyro_X;
asn1SccMyGyroVal gyro_y = *IN_gyro_Y;
asn1SccMyGyroVal gyro_z = *IN_gyro_Z;
asn1SccMyGyroVal acc_x = *IN_acc_X;
asn1SccMyGyroVal acc_y = *IN_acc_Y;
asn1SccMyGyroVal acc_z = *IN_acc_Z;
}
/* This file was generated automatically: DO NOT MODIFY IT ! */
/* Declaration of the functions that have to be provided by the user */
#ifndef __USER_CODE_H_control_laws__
#define __USER_CODE_H_control_laws__
#include "C_ASN1_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
void control_laws_startup();
void control_laws_PI_Get_IMU_Data(const asn1SccMyGyroVal *,
const asn1SccMyGyroVal *,
const asn1SccMyGyroVal *,
const asn1SccMyAccVal *,
const asn1SccMyAccVal *,
const asn1SccMyAccVal *);
#ifdef __cplusplus
}
#endif
#endif
run Simulink_DataView_asn;
inports_positions = zeros(6, 4);
bussel_positions = zeros(6, 4);
outports_positions = zeros(0, 4);
buscre_positions = zeros(0, 4);
if (exist('Get_IMU_Data') == 4),
simulink('open');
load_system('Get_IMU_Data');
open_system('Get_IMU_Data');
inportHan = find_system('Get_IMU_Data','FindAll','on', 'SearchDepth', 1, 'BlockType','Inport');
outportHan = find_system('Get_IMU_Data','FindAll','on', 'SearchDepth', 1, 'BlockType','Outport');
% ---------------------------------------------------------------------------------
% start by removing the Bus Selectors / then lines / finally ports
% ---------------------------------------------------------------------------------
% get the handles of all the lines connected to inports
for i=1:length(inportHan)
inports_positions(i,:) = get_param(inportHan(i),'Position'); % remember Inport's position
line_structsIn(i)=get_param(inportHan(i),'LineHandles'); % get the structures
inLinesHan(i)=line_structsIn(i).Outport; % get the line connected to the block's Outport
if (inLinesHan(i) ~= -1) % if exists
dstBlock = get_param(inLinesHan(i),'DstBlockHandle'); % get the destination block's handle
if (strcmp(get_param(dstBlock,'BlockType'),'BusSelector'))
bussel_positions(i,:) = get_param(dstBlock,'Position'); % remember Bus Selector's position
blockLineStructs = get_param(dstBlock,'LineHandles'); % get the line connected structures
blockLineHandles = blockLineStructs.Outport; % get the line handlers connected to the bus's outports
for j=1:length(blockLineHandles)
if (blockLineHandles(j) ~= -1)
delete(blockLineHandles(j));
end
end
delete_block(dstBlock); % delete it if it is a Bus Selector Block
end
delete(inLinesHan(i)); % delete the respective line
end
delete_block(inportHan(i)); % delete the outdated inport block
end
% now remove the outports
for i=1:length(outportHan)
outports_positions(i,:) = get_param(outportHan(i),'Position'); % remember Outport's position
line_structsOut(i)=get_param(outportHan(i),'LineHandles'); % get the structures
outLinesHan(i)=line_structsOut(i).Inport; % get the line connected to the block's Inport
if (outLinesHan(i) ~= -1) % if exists
srcBlock = get_param(outLinesHan(i),'SrcBlockHandle'); % get the source block's handle
if (strcmp(get_param(srcBlock,'BlockType'),'BusCreator'))
buscre_positions(i,:) = get_param(srcBlock,'Position'); % remember Bus Creator's position
blockLineStructs = get_param(srcBlock,'LineHandles'); % get the line connected structures
blockLineHandles = blockLineStructs.Inport; % get the line handlers connected to the bus's outports
for j=1:length(blockLineHandles)
if (blockLineHandles(j) ~= -1)
delete(blockLineHandles(j));
end
end
delete_block(srcBlock); % delete it if it is a Bus Creator Block
end
delete(outLinesHan(i)); % delete the respective line
end