CS684: Embedded System Course
Lab 6: Case Study - Adaptive Cruise Control (Lustre/Heptagon)
Solution
Solution code for this task is available here.
Use integrate.sh from heptagon directory to compile and copy the reactive kernel code into project folder.
Additional Tips
- Automatons are great and an exclusive feature. Use them whenever you should. Common scenarios are, you need a while like behaviour, you have a big if else ladder conditioned on multiple variables (compare move and moveAut in the solution) and nested states/multiple modes.
- Heptagon examples on how to integrate external C code with heptagon.
AIM
In this task, you will learn to implement Adaptive Cruise Control using Synchronous Dataflow programming language Heptagon.
- The arena provided to you is made up of curved, zig-zag, and straight paths with a START and GOAL position for the robot as shown in following figure.
- Arena also consists of obstacles randomly placed.
- You have to program the robot which will begin from START position, follow the path avoiding obstacles and stop at the GOAL position.

The project folder can be imported as Eclipse or CMake project.
PROCEDURE
Step-1: Download lab6_line_follower_robot zip folder. Right-click on the hyperlinks and select Save Link As... option to download. Extract the zip file. Start Eclipse, click on File > Open Projects From File System > Directory and browse for lab6_line_follower_robot folder to open the project.
Step-2: In src/supervisor.cpp, traverse_line_to_goal function performs the sense, step and actuate in a loop. You have to complete Heptagon program inside heptagon directory which when compiled gives you a reactive kernel implementing the step part. Your Heptagon program implement the following:
- Robot starts from START position.
- Follows the line and checks for obstacles.
- If obstacle is found on a path, avoids it and plans the next shortest path.
- Stops at GOAL position.
Note: You can write parts of the program in C/C++ if you must. While completing, you have to use the functions defined in eBot_Sim_Predef.h header file.
There is an integrate.sh file in heptagon directory which you can run each time you change heptagon code to integrate it in the C/C++ project.
Step-3: Build the project (click on Project --> Build Project). If there are no errors present in your program, the project will get built successfully and you will get the message (on console at bottom pane) as shown below,
**======== Build Finished. 0 errors, 0 warnings ========**
Note: The default path to Heptagon C headers is /usr/local/lib/heptagon/c/. If you get build errors please include path in Eclipse, specific to your installation.
Step-4: Check the behaviour of the robot on CoppeliaSim.
- Use the lab6_line_follower_robot.ttt scene found in the project folder. Start CoppeliaSim, click on File --> Open Scene and browse for lab6_line_follower_robot.ttt file to open the scene (shown in Expected Output - CoppeliaSim video).
- In Eclipse, right click on lab6_line_follower_robot folder (Project Explorer - left pane) and select Run As --> Local C/C++ Application. If no errors are encountered, following message will be displayed onto the console (bottom pane):
Connection Success ...
0
0
0
Please Enter Y to Start Simulation: Y
Enter 'Y' on console. This will start the simulation in CoppeliaSim.
Simulation: EXPECTED OUTPUT
Software required: CoppeliaSim and Eclipse (refer Installation_Instructions provided to you)
Note: Do not hardcode the path in program. Your code should be generic and it should work for any obstacle positions. During evaluation, your code will be tested for different scene - in which arena will be same but obstacles will be placed at different positions.
Following rules will be followed for obstacle placement:
-
No obstacle will be placed on curved or zig-zag path.
-
Obstacle will always be placed on a line and between two nodes.
-
Only three colored (red, green and blue) obstacles will be used.
-
Any number of obstacles can be present on the arena.