Part 3 (Pipeline Setup)
We still need to build the overall pipeline in C++, and then add the Python stage as a ark::python::PythonStage
with an appropriate configuration.
Let’s create the pipeline in ${APP_ROOT}/tutorial/tutorial_pipeline.cc
:
#include "ark/python/stages/python_stage.hh"
#include "ark/main/main_offboard.hh"
#include "ark/comms/stages/http_server_stage.hh"
#include <iostream>
using namespace ark;
int main(int argc, const char **argv)
{
try
{
//
// Create the pipeline with our stages...
//
pipeline::Pipeline pipeline;
pipeline.add_stage<comms::HttpServerStage>();
pipeline.add_stage<python::PythonStage>("ImageDetectorStage");
//
// Exeucte the pipeline.
//
main::MainOffboardConfiguration config;
config.pipeline_config_path = "tutorial/tutorial_pipeline.yml";
config.add_log_playback_options = true;
return main::execute_simclock_pipeline(argc, argv, std::move(pipeline), config);
}
catch (const std::exception &exception)
{
std::cerr << "FATAL: " << exception.what() << std::endl;
return 1;
}
}
We’ll also need to update our CMakeLists.txt
file to build the pipeline. Add these lines to
the bottom of it:
add_executable(
tutorial_pipeline
tutorial_pipeline.cc)
target_link_libraries(
tutorial_pipeline
PRIVATE
ark::pipeline
ark::main_offboard
ark::python_stage
ark::http_server_stage)
add_dependencies(
tutorial_pipeline
tutorial_venv)
This will create a tutorial_pipeline
, and link it against the appropriate Ark C++ libraries, along
with the ark::python_stage
library. Note that we have to explicitly add a dependency to the venv to
make sure that it is built for the pipeline.
Finally, we need a configuration file suitable for running the stage. Let’s make on in
${APP_ROOT}/tutorial/tutorial_pipeline.yml
:
package:
configs:
ImageDetectorStage:
overrides:
module_name: "tutorial_stage"
virtualenv_name: "tutorial_venv"
python_path: "tutorial"
This will tell the Python stage to use the detection_stage
module for the stage, and also setup
the PYTHONPATH
to point at our venv and the path to our tutorial.
You should now be able to build with make.sh
and get a build/tutorial_pipeline
target.
Let’s try to run the pipeline:
./make.sh
./build/tutorial_pipeline
It should complain about a missing log file. Let’s download one in the next section, in Step 4.