【Stateflow入门】任务7.构建扫地机器人

根据Matlab2021a中Stateflow的任务7Project-Robotic Vacuum开始构建扫地机器人

Robotic Vacuum Supervisory Control(机器人真空监控)

Robotic Vacuums(机器人真空吸尘器)

Autonomous, robotic vacuums generally have a few specific operating modes, like vacuuming or charging. In this project, you will model a robotic vacuum that has four modes: off, vacuuming, docking, and charging.
(自动机器人吸尘器通常有一些特定的操作模式,比如吸尘或充电。在这个项目中,你将为一个机器人真空吸尘器建模,他有四种模式:关闭、抽真空、对接和充电。)
扫地机器人四种模式
Certain rules govern how the robot can move between these modes. For example, it can be vacuuming and be turned off, but it cannot go from vacuuming to charging without docking first.
(某些规则控制着机器人如何在这些模式之间移动。例如,它可以抽真空并关闭,但如果先不对接,他就无法从抽真空到充电。)

These modes, and the rules for moving between them, can be modeled using a state machine. In this project, imagine that you are a control engineer, tasked with designing the supervisory logic for the robotic vacuum. You will then connect this Stateflow chart to Simulink subsystems, provided by the plant modeling team, that describe the dynamics of the robot as it performs tasks.
(这些模式以及在它们之间移动的规则可以使用状态机进行建模。在这个项目中,假设你是一名控制工程师,负责设计机器人真空的监控逻辑。然后,您将把这个状态流程图连接到工厂建模团队提供的Simulink子系统,这些子系统描述了机器人执行任务时的动力学。)

Design Requirements(设计要求)

The design requirements for your robotic vacuum are as follows.(您的机器人真空吸尘器的设计要求如下。)

·There will be 4 states: off, vacuuming, docking, and charging.(将有4中状态:关闭、抽真空、对接和充电。)

·The user can manually set the robot to off, vacuuming, or docking.(用户可以手动将机器人设置为关闭、抽真空或对接。)

·Charging begins as soon as docking is complete.(对接完成后立即开始充电。)

·After the robot is charged, it turns off.(机器人充电后,它会关闭。)

·The battery drains at a given rate any time the robot is moving (vacuuming or docking states), and charges at another rate while in the charging state.(每当机器人移动时(抽真空或对接状态),电池都会以给定的速率消耗,并在充电状态下以另一速率充电。)

·The robot automatically moves from vacuuming to docking under two conditions: if the battery drops below 30% charge while vacuuming or when vacuuming is complete.(机器人在两种情况下自动从抽真空移动到对接:如果在抽真空时电池电量降至30%以下或抽真空完成时。)

·Vacuum mode cannot be requested if the battery is low.(如果电池电量不足,则无法请求真空模式。)

接下来开始构建

TASK1(任务1)

Add four states to your model: Off, Vacuum, SeekDock and Charge, with Off as the default state.
(为您的型号添加四种状态:关闭真空SeekDock充电,默认状态为关闭。)

Note: When you run or submit this model, a MATLAB figure window will appear showing the robot and dock positions in the simulated room. Once you connect Stateflow and Simulink in the last task, this figure will animate, showing you the simulated robot vacuum movement.
(注意:当您运行或提交此模型时,将出现一个MATLAB图形窗口,显示机器人和码头在模拟房间中的位置。在上一个任务中连接Stateflow和Simulink后,此图将显示动画,向您显示模拟的机器人真空运动。)
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

TASK2(任务2)

When the user sets the robot to off, vacuum, or dock, this is processed as a numerical signal, requestMode. requestMode has the corresponding values shown.
(当用户将机器人设置为关闭、真空或对接时,这将作为数字信号requestMode进行处理。requestMode显示了相应的值。)

-1 – off
1 – dock
2 – vacuum

The user can(用户可以)
Request Off from either Vacuum or SeekDock,(从Vacuum或SeekDock请求关闭)
Request either Vacuum, or SeekDock from Off and,(从Off请求Vacuum或SeekDock)
Request SeekDock from Vacuum.(从Vacuum中请求SeekDock)

Create the appropriate transitions and add conditions that describe how to transition between the Off, Vacuum and SeekDock states based on the user input.
(创建适当的转换,并添加描述如何根据用户输入在关闭真空SeekDock状态之间转换的条件。)

For example, the machine should transition from Off to Vacuum if requestMode == 2.
(例如,如果requestMode==2,则机器应从**“关闭”转换为“真空”**。)

Use the Symbols Pane to Resolved undefined symbols and define requestMode as Input Data.
(使用符号窗格解析未定义的符号,并将requestMode定义为输入数据。)
在这里插入图片描述

TASK3(任务3)

The user input is stored as requestMode. However, the Simulink subsystem that describes the dynamics needs the current operating mode. (The current mode can differ from the user request if, for example, the battery is too low to continue vacuuming.) Thus, you will set the value of an Output Data symbol using state entry actions.
(用户输入存储为requestMode。然而,描述动力学的Simulink子系统需要当前的操作模式。(例如,如果电池电量过低,无法继续抽真空,则当前模式可能与用户请求不同。)因此,您将使用状态输入操作设置输出数据符号的值。)

Add state entry actions to each of the states to set a Symbol, driveMode, as described below.
(将状态输入操作添加到每个状态,以设置符号driveMode,如下所述。)

Off/Charge driveMode = 0;
SeekDock driveMode = 1;
Vacuum driveMode = 2;

Define driveMode as Output Data.
在这里插入图片描述

TASK4(任务4)

In addition to the user requested modes, the robot will also automatically change modes when the given task is complete. Simulink sends a “complete” flag when the physical model of the robot has finished vacuuming or found the dock.
(除了用户请求的模式外,机器人还将在给定任务完成时自动更改模式。当机器人的物理模型完成真空吸尘或找到码头时,Simulink会发送“完成”标志。)

Add the condition complete == 1 to transition from Vacuum to SeekDock and from SeekDock to Charge. You will need to add a new transition from SeekDock to Charge.
(添加条件complete=1,以从Vacuum转换到SeekDock状态,并从Seek Dock状态转换到Charge。您需要添加一个从SeekDock到Charge的新转换。)

Define complete as Input Data.
(将complete定义为输入数据。)
在这里插入图片描述

TASK5(任务5)

The battery drains whenever the robot is driving. This includes the Vacuum and SeekDock states. In the Charge state, the battery charges.
( 每当机器人行驶时,电池就会耗尽。这包括真空和SeekDock状态。在充电状态下,电池充电。)

For this project, you will use a naïve model of linear battery drain and charge and account for the state of charge (SOC) using Local Data.
(对于这个项目,您将使用一个天真的线性电池消耗和充电模型,并使用本地数据说明充电状态(SOC)。)

Add the following during actions to the appropriate states to model the battery state.
(将操作过程中的以下内容添加到适当的状态中,以对电池状态进行建模。)

Battery drain: SOC = SOC - 1e-5;(蓄电池电量:SOC=SOC-1e-5;)
Battery charge: SOC = SOC + 2e-5;(电池电量:SOC=SOC+2e-5;)

Define SOC as Local Data. Assign it an initial value of 100 (percent).
(将SOC定义为本地数据。为其指定一个初始值100(百分比)。)
在这里插入图片描述

TASK6(任务6)

The status of the battery also affects the robot’s behavior.
(电池的状态也会影响机器人的行为。)

First, the robot automatically begins seeking the dock if the battery drops below 30% charge while vacuuming.
(首先,如果在吸尘时电池电量降至30%以下,机器人会自动开始寻找充电座。)

Second, charging is considered complete when the battery is 97% full. When charging is complete, the robot turns off.
(其次,当电池电量达到97%时,充电即视为完成。充电完成后,机器人关闭。)

Add the following conditions to the appropriate transitions (you will need to both create new and modify existing transitions).
(将以下条件添加到适当的转换中(您需要创建新的转换和修改现有的转换)。)

Battery is less than 30% full: SOC < 30.(电池电量不足30%:SOC<30。)
Charging is complete: SOC >= 97.(充电完成:SOC>=97。)
在这里插入图片描述

TASK7(任务7)

The final step is to integrate your logic with the Simulink model of the robot behavior.
(最后一步是将您的逻辑与机器人行为的Simulink模型集成。)

Navigate to the Simulink model and connect the signals to their appropriate ports.
(导航到Simulink模型,并将信号连接到相应的端口。)
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/J_WangJiang/article/details/129688515
今日推荐