本文主要是简单介绍如何将C代码的模型嵌入到carmaker中运行
一.项目创建与例程生成
在创建项目的时候勾选source选项,勾选后才能在项目目录下生成src的文件夹

在src文件夹下,存在大量IPG的例程,这些例程简单介绍了如何使用了src的接口

编译代码的规则写在Makefile文件夹下:

打开carmaker Windows下的编译工具mys2020,运行Makefile文件对源代码进行编译:

进入路径下,对文件进行编译,生成Carmaker.win64.exe文件:

在应用配置中选择刚刚生成的应用文件并加载:

项目文件夹下的可执行文件后会多一个src:

二.接口文件详解
C接口结构如下:

**IO_In:**外部输入
**User_In:**用户自定义的输入
**Vehicle Control:**感知或规划控制等车辆控制算法写在这个环节
**APO:**计算输出的其他部分
下面是简单的例子:

打开User.c的文件,编写代码如下:

然后再User_cal函数中编写代码,每一千次循环执行一次Log函数:

在User_out中编写代码如下:

LOG函数会将打印的信息输出到上图所示的session Log上:

三.Model Manager例子
将MySteering.c和MySteering.h复制到src文件目录下:

C代码程序接口如下,通过register函数注册一个转向模型:

选择添加模型添加编译后的C代码模型:

最后添加模型参数即可运行:
