-
Notifications
You must be signed in to change notification settings - Fork 0
Toolhead
This page describes how tool heads are imported and stored in AC. The AIAC::LayerToolhead
is responsible for managing them.
flowchart TD
A[LayerToolhead]
B(ACInfoToolheadManager)
B2(std::map)
C1(01 ACInfoToolhead)
C2(02 ACInfoToolhead)
C3(03 ACInfoToolhead)
C4(.. ACInfoToolhead)
A -- "ACInfoToolheadManager.ACInfoToolheadManager" --> B -.-> B2
B2 --> C1
B2 --> C2
B2 --> C3
B2 --> C4
Da(DrillBitData)
E1((ptr\n ToolbaseGO))
E2((ptr\n TooltipGO))
E3((ptr\n EattipG0))
E4((ptr\n ChucktipGO))
C1 -- "GetData()" --> Da
Da --> E1
Da --> E2
Da --> E3
Da --> E4
The most important member of the class LayerToolhead
is the public property:
std::shared_ptr<AIAC::ACInfoToolheadManager> ACInfoToolheadManager;
This manager object ACInfoToolheadManager
loads all the ACInfoToolhead
objects and it is used to switch on/off the visibility of each one of them and set the current one as active. For more info see the following chapter.
This is the manager object for all the ACInfoToolhead
objects in AC. IS responsible for:
- loading the tool heads objects from the local folder in
deps/TTool/assets/dataset
- set the current one by deactivating the visibility of the rest of the tool heads
This manager is a simple utility class wrapping a std::map
containing the tool heads as such:
std::map<std::string, std::shared_ptr<ACInfoToolhead>> m_ACInfoToolheadMap;
The current active (or selected) tool head is stored in the smart pointer member:
std::shared_ptr<ACInfoToolhead> m_ActiveACInfoToolhead;
⚠️ Note that when we call the getter of the active tool headinline std::shared_ptr<ACInfoToolhead> GetActiveToolhead() const { return this->m_ActiveACInfoToolhead; }
only a copy asstd::shared_ptr
of the active tool will be returned. Hence, Changing anything to this object will modify the current object.
The way we designed the class object for the tool heads is a bit particular. Let's have a look at the header ACInfoToolhead.h
. This file contains 3 important elements:
- a) the class
ACInfoToolhead
- b) the class
ToolheadData
- c) the structs
DrillBitData
,CircularSawData
,ChainSawData
,SaberSawData
To make it brief, ACInfoToolhead
is a big utility class that contains the ToolheadData
. This data is where the geometries and other metadata relative to each imported tool head are created and stored.
The ToolheadData
holds 4 different private members which are the data corresponding to each type of tool:
/// @brief struct contains info from .acit data for drillbit
DrillBitData m_DrillBitD;
/// @brief struct contains info from .acit data for circularsaw
CircularSawData m_CircularSawD;
/// @brief struct contains info from .acit data for chainsaw
ChainSawData m_ChainSawD;
/// @brief struct contains info from .acit data for sabersaw
SaberSawData m_SaberSawD;
Each one of them has specific data depending on which type of control points is contained in the tool head's .acit
file. These are files from the TTool
dependency that set control point coordinates for each tool head. These control points are relevant positions of interest in each toolhead, e.g. for a drillbit the tip point. These files are loaded and parsed (ToolHeadData::LoacACIT()
) into our AC geometry objects (GOPoint
) and stored in each custom ToolheadData
. E.g. for the DrillBitData
:
struct DrillBitData
{
...
std::shared_ptr<GOPoint> ToolbaseGO;
std::shared_ptr<GOPoint> TooltipGO;
std::shared_ptr<GOPoint> EattipGO;
std::shared_ptr<GOPoint> ChucktipGO;
DrillBitData() { ... }
};
In each loop, at void LayerToolhead::OnFrameStart()
in LayerToolhead.cpp
these GO
control points are transformed in respect to the SLAM transform and the TTOOL detection and positioned correctly in the 3D space.
These GOPoint
are the same that the LayerFeedback
is accessing to compute distances, and angles and produce visual feedback for guiding any augmented operations. To access one control point this would be the way:
std::shared_ptr<GOPoint> ToolbaseGOCopy = AIAC_APP.GetLayer<AIAC::LayerToolhead>()->ACInfoToolheadManager->GetActiveToolhead()->GetData().ToolbaseGO
⚠️ ⚠️ ⚠️ Beware that you need to know in advance which type ofToolheadData
you are retrieving!