Skip to content

Commit

Permalink
UI / Feedback refactor (#51)
Browse files Browse the repository at this point in the history
* FIX-WIP: trying to sqashing to avoid large files

* WIP: tool selection working with pad

* CAP-FIX: solved the toolhead pane

* FIX: switch color for toolhead

* FIX: switch color for toolheadx2

* FIX-CAP: ui pane for ACIM done refactoring

* CAP: refactored ACIM pane + fix #49

* CAP: refactored mapping

* CAP: refactored the drilling feedback

* TEMP-FIX: temporary fix, there still some leftover elements in the space

* FIX: camera not connected solved

---------

Co-authored-by: Andrea Settimi <>
  • Loading branch information
9and3 authored May 31, 2024
1 parent 85227ef commit 67540a6
Show file tree
Hide file tree
Showing 20 changed files with 548 additions and 233 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
assets/tslam-final_eval.tgz filter=lfs diff=lfs merge=lfs -text
assets/ttool-v2.0.0-34-g96053edf.tgz filter=lfs diff=lfs merge=lfs -text
*.mp4 filter=lfs diff=lfs merge=lfs -text
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ option(SILENT_LOGGING "Do not log messages in the terminal if on." ON)
option(TEST_GRAPHICS "Test graphics by launching opengl with glfw window." ON)
option(AC_SYNC_GIT_SUBMODULES "Sync to the latest version of submodules" ON)
mark_as_advanced(AC_SYNC_GIT_SUBMODULES)
# -------------------- DEV UI OPTIONS --------------------------------
# This preprocessor variable is used to enable the dev ui in the application.
# In order to light up the beta tester's experience, the dev ui is disabled by default.
option(ENABLE_DEV_UI "Enable the dev ui in the application" OFF)


# pre-compile variables
Expand All @@ -54,6 +58,9 @@ endif()
if(SILENT_LOGGING)
target_compile_definitions(${PROJECT_NAME} PRIVATE SILENT_LOGGING=true)
endif()
if(ENABLE_DEV_UI)
target_compile_definitions(${PROJECT_NAME} PRIVATE ENABLE_DEV_UI=true)
endif()

#------------------------------------------------------------------------------------------------------------
# GLOBAL 3rd libs (NOT compatible with add_subdirectory())
Expand Down
14 changes: 7 additions & 7 deletions config.ini
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
[AIAC]
ACInfoModel = AC_acims/mybeam.acim
ACInfoModel = /home/localuser/augmented-carpentry/AC_acims/CD07.acim
AlignFlip = 0
AlignOffset = 0
AlignRotation = 8
AlignOffset = 4.21429
AlignRotation = 5
CamID = 0
CamParamsFile = assets/tslam/calibration_orange_B_1280_720_r.yml
CamParamsFile = assets/tslam/calibration_orange_A_1280_720_r.yml
ScaleFactor = 50
ScannedModel = AC_scanned_map/test_beam/map-2024-5-6-11-13-44.ply
ScannedModel = ./scanned_map/map-2024-5-29-13-46-0.ply

[Renderer]
DigitalModelPath = assets/tslam/example3dModel.ply
MeshPaths =
PointCloudMapPath = assets/tslam/examplePointCloud.ply

[TSlam]
MapFile = AC_scanned_map/test_beam/map-2024-5-6-11-13-44.map
MapFile = /home/localuser/augmented-carpentry/scanned_map/map-2024-5-29-13-46-0.map
VocFile = assets/tslam/orb.fbow

[TTool]
CachedToolhead = circular_saw_blade_makita_190
CachedToolhead = auger_drill_bit_20_235
ConfigFile = deps/TTool/assets/config.yml
DatasetDir = deps/TTool/assets/toolheads
TToolRootPath = deps/TTool
Expand Down
24 changes: 20 additions & 4 deletions imgui.ini
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ Size=455,656
Collapsed=0

[Window][augmented_carpentry]
Pos=419,21
Size=379,555
Pos=414,26
Size=384,463
Collapsed=1

[Window][bla]
Expand All @@ -134,7 +134,7 @@ Size=207,206
Collapsed=0

[Window][Scene Viewport]
Pos=6,19
Pos=3,26
Size=403,389
Collapsed=1

Expand Down Expand Up @@ -169,7 +169,7 @@ Size=350,333
Collapsed=0

[Window][Open Vocab##ChooseVocab]
Pos=60,60
Pos=14,72
Size=346,289
Collapsed=0

Expand Down Expand Up @@ -690,3 +690,19 @@ Column 0 Sort=0v
RefScale=14
Column 0 Sort=0v

[Table][0x66BBE681,4]
RefScale=14
Column 0 Sort=0v

[Table][0xEF3A02CC,4]
RefScale=14
Column 0 Sort=0v

[Table][0xC89E969A,4]
RefScale=14
Column 0 Sort=0v

[Table][0xA67CB060,4]
RefScale=14
Column 0 Sort=0v

69 changes: 50 additions & 19 deletions src/AIAC/ACInfoModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,20 @@ namespace AIAC
AIAC_INFO("Set Current Component to Hole #" + m_ID);
m_AxisGO->SetColor(HOLE_AXIS_COLOR[ACIMState::CURRENT]);
m_CylinderGO->SetColor(HOLE_CYLINDER_COLOR[ACIMState::CURRENT]);
m_RadiusLabelGO->SetVisibility(true);
}

void TimberInfo::Hole::SetAsDone() {
TimberInfo::Component::SetAsDone();
AIAC_INFO("Set " + m_ID + " as Done");
m_AxisGO->SetColor(HOLE_AXIS_COLOR[ACIMState::DONE]);
m_CylinderGO->SetColor(HOLE_CYLINDER_COLOR[ACIMState::DONE]);
m_RadiusLabelGO->SetVisibility(false);
}

void TimberInfo::Hole::SetAsNotDone() {
TimberInfo::Component::SetAsNotDone();
AIAC_INFO("Set " + m_ID + " as Not Done");
m_AxisGO->SetColor(HOLE_AXIS_COLOR[ACIMState::NOT_DONE]);
m_CylinderGO->SetColor(HOLE_CYLINDER_COLOR[ACIMState::NOT_DONE]);
m_RadiusLabelGO->SetVisibility(false);
}

void TimberInfo::Hole::SwapStartEnd() {
Expand Down Expand Up @@ -198,8 +195,6 @@ namespace AIAC
}
}



std::vector<std::string> TimberInfo::GetAllComponentsIDs() const {
// This is only for C++20, but we're using C++17, I leave it here for future reference
// #include <ranges>
Expand Down Expand Up @@ -237,6 +232,43 @@ namespace AIAC
HideAllComponentsExceptCurrent();
}

std::string TimberInfo::ShortenComponentID(std::string id) {
if(id.find("Hole") != std::string::npos){
return "H" + id.substr(5);
} else if(id.find("Cut") != std::string::npos){
return "C" + id.substr(4);
}
return id;
}

void TimberInfo::SetNextComponentAsCurrent()
{
auto ids = GetAllComponentsIDs();
auto it = std::find(ids.begin(), ids.end(), m_CurrentComponentID);
if(it == ids.end()){
AIAC_ERROR("TimberInfo::SetNextComponentAsCurrent() : Current Component ID not found");
return;
}
if(++it == ids.end()){
it = ids.begin();
}
SetCurrentComponentTo(*it);
}

void TimberInfo::SetPrevComponentAsCurrent()
{
auto ids = GetAllComponentsIDs();
auto it = std::find(ids.begin(), ids.end(), m_CurrentComponentID);
if(it == ids.end()){
AIAC_ERROR("TimberInfo::SetPrevComponentAsCurrent() : Current Component ID not found");
return;
}
if(it == ids.begin()){
it = ids.end();
}
SetCurrentComponentTo(*--it);
}

void TimberInfo::HideAllComponentsExceptCurrent() {
for (const auto& [_, component] : m_Components) {
if(component->m_ID != m_CurrentComponentID){
Expand Down Expand Up @@ -264,6 +296,14 @@ namespace AIAC
AIAC_ERROR("ACInfoModel::Load() file does not exist");
return false;
}
if (std::filesystem::is_directory(path)){
AIAC_ERROR("ACInfoModel::Load() path is a directory");
return false;
}
if (path.find(".acim") == std::string::npos){
AIAC_ERROR("ACInfoModel::Load() file is not .acim");
return false;
}

m_FilePath = path;

Expand Down Expand Up @@ -305,7 +345,7 @@ namespace AIAC
holeInfo.m_StartExposed = StringToBool(hole.child("start").child("exposed").child_value());
holeInfo.m_End = StringToVec3(hole.child("end").child("coordinates").child_value()) * m_Scale;
holeInfo.m_EndExposed = StringToBool(hole.child("end").child("exposed").child_value());
holeInfo.m_Radius = std::stof(hole.child("radius").child_value()) * m_Scale;
holeInfo.m_Radius = std::stof(hole.child("radius").child_value());

// build GOPrimitive
holeInfo.m_AxisGO = GOLine::Add(holeInfo.m_Start, holeInfo.m_End, 2.0f);
Expand All @@ -315,18 +355,14 @@ namespace AIAC
holeInfo.m_StartPointGO = GOPoint::Add(holeInfo.m_Start, 2.0f);
holeInfo.m_EndPointGO = GOPoint::Add(holeInfo.m_End, 2.0f);
auto centerPoint = (holeInfo.m_Start + holeInfo.m_End) * 0.5f;
holeInfo.m_IDLabelGO = GOText::Add(holeInfo.m_ID, centerPoint, m_LabelSize);
auto radiusText = std::to_string(holeInfo.m_Radius);
radiusText = radiusText.substr(0, radiusText.find(".") + 3);
holeInfo.m_RadiusLabelGO = GOText::Add(radiusText, holeInfo.m_Start, m_LabelSize);
holeInfo.m_RadiusLabelGO->SetVisibility(false);
std::string shortenHoleID = m_TimberInfo.ShortenComponentID(holeInfo.m_ID);
holeInfo.m_IDLabelGO = GOText::Add(shortenHoleID, centerPoint, m_LabelSize);

holeInfo.m_GOPrimitives.push_back(holeInfo.m_AxisGO);
holeInfo.m_GOPrimitives.push_back(holeInfo.m_CylinderGO);
holeInfo.m_GOPrimitives.push_back(holeInfo.m_StartPointGO);
holeInfo.m_GOPrimitives.push_back(holeInfo.m_EndPointGO);
holeInfo.m_GOPrimitives.push_back(holeInfo.m_IDLabelGO);
holeInfo.m_GOPrimitives.push_back(holeInfo.m_RadiusLabelGO);

m_TimberInfo.m_Holes[holeInfo.m_ID] = holeInfo;
m_TimberInfo.m_Components[holeInfo.m_ID] = &m_TimberInfo.m_Holes[holeInfo.m_ID];
Expand All @@ -340,7 +376,8 @@ namespace AIAC
cutInfo.m_State = StringToState(cut.child("state").child_value());
cutInfo.IsMarkedDone = cutInfo.m_State == ACIMState::DONE;
cutInfo.m_Center = StringToVec3(cut.child("center").child_value()) * m_Scale;
cutInfo.m_IDLabelGO = GOText::Add(cutInfo.m_ID, cutInfo.m_Center, m_LabelSize);
std::string shortenCutID = m_TimberInfo.ShortenComponentID(cutInfo.m_ID);
cutInfo.m_IDLabelGO = GOText::Add(shortenCutID, cutInfo.m_Center, m_LabelSize);
cutInfo.m_GOPrimitives.push_back(cutInfo.m_IDLabelGO);

auto faces = cut.child("faces");
Expand Down Expand Up @@ -397,12 +434,6 @@ namespace AIAC
}
}

// for(auto const& [faceID, faceInfo]: cutInfo.m_Faces){
// cout << faceID << faceInfo.m_Exposed << endl;
// cout << glm::to_string(faceInfo.GetNormal()) << endl;
// cout << glm::to_string(faceInfo.GetCenter()) << endl;
// }

auto edges = cut.child("edges");
for(auto edge = edges.child("edge"); edge; edge=edge.next_sibling("edge")){
auto id = edge.attribute("id").as_string();
Expand Down
34 changes: 33 additions & 1 deletion src/AIAC/ACInfoModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ class TimberInfo{
std::shared_ptr<GOPoint> GetStartPointGO() { return m_StartPointGO; }
std::shared_ptr<GOPoint> GetEndPointGO() { return m_EndPointGO; }

public: __always_inline
double GetRadius() const { return m_Radius; }

private:
// These values uses original coordinate in xml file
// i.e. not transformation (rotation / translation) is applied
Expand All @@ -137,7 +140,6 @@ class TimberInfo{
std::shared_ptr<GOCylinder> m_CylinderGO;
std::shared_ptr<GOPoint> m_StartPointGO;
std::shared_ptr<GOPoint> m_EndPointGO;
std::shared_ptr<GOText> m_RadiusLabelGO;
std::shared_ptr<GOText> m_IDLabelGO;

friend class ACInfoModel;
Expand Down Expand Up @@ -220,6 +222,7 @@ class TimberInfo{

inline std::string GetID() const { return m_ID; }
std::vector<std::string> GetAllComponentsIDs() const;

inline Component* GetComponent(const std::string& id) { return m_Components[id]; }
inline Component* GetCurrentComponent() {
if(m_Components.find(m_CurrentComponentID) == m_Components.end())
Expand All @@ -228,13 +231,42 @@ class TimberInfo{
}
std::string GetCurrentComponentID() { return m_CurrentComponentID; }
void SetCurrentComponentTo(std::string id);
void SetNextComponentAsCurrent();
void SetPrevComponentAsCurrent();

inline std::vector<glm::vec3> GetBoundingBox() const { return m_Bbox; }
inline std::vector<std::pair<int, int> > GetBboxEdgesIndices() const { return m_BboxEdgesIndices; }

void HideAllComponentsExceptCurrent();
void ShowAllComponents();

public: ///< small utilities to calculate the progress of fabrication
/// @brief Get the number of fabricate components
inline int GetFabricatedComponents() {
int count = 0;
for(auto& comp : m_Components){
if(comp.second->m_State == ACIMState::DONE)
count++;
}
return count;
}
/// @brief Get the total number of components
inline int GetTotalComponents() { return m_Components.size(); }
/// @brief Get the progress of fabrication in percentage
inline float GetFabricationProgress() {
return (float)GetFabricatedComponents() / GetTotalComponents() * 100;
}

private: ///< utils for visualization
/**
* @brief Transform the notation from .acim into more lightweight notation
* for visuals (e.g. "Hole#1" -> "H1" and "Cut#1" -> "C1")
*
* @param id the original id of the component
* @return std::string the shortened id for visualization
*/
std::string ShortenComponentID(std::string id);

public:
bool IsShowingAllComponents = false;

Expand Down
7 changes: 6 additions & 1 deletion src/AIAC/ACInfoToolheadManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ namespace AIAC
void SetActiveToolhead(const std::string& toolheadName);
/// @brief Get the active toolhead model
inline std::shared_ptr<ACInfoToolhead> GetActiveToolhead() const { return this->m_ActiveACInfoToolhead; }
/// @brief Get the toolhead model by its name
inline std::shared_ptr<ACInfoToolhead> GetToolhead(const std::string& toolheadName) const { return this->m_ACInfoToolheadMap.at(toolheadName); }
/// @brief Get the active toolhead model's name
inline std::string GetActiveToolheadName() const { return this->m_ActiveACInfoToolhead->GetName(); }

/// @brief Get the toolhead's type by its name
inline ACToolHeadType GetToolheadType(const std::string& toolheadName) const { return this->m_ACInfoToolheadMap.at(toolheadName)->GetType(); }


/// @brief Return the list of names of the toolheads loaded
inline std::vector<std::string> GetToolheadNames() const
{
Expand Down
14 changes: 13 additions & 1 deletion src/AIAC/Feedback/CutCircularSawFeedback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ namespace AIAC
this->m_LineDistStart->SetColor(GOColor::YELLOW);
this->m_TxtDistStart->SetColor(GOColor::WHITE);

this->m_TxtDistStart->SetTextSize(GOTextSize::ExtraSmall);

this->m_AllPrimitives.push_back(m_LineDistStart);
this->m_AllPrimitives.push_back(m_TxtDistStart);

Expand Down Expand Up @@ -47,8 +49,14 @@ namespace AIAC
m_LinePitchFeed->SetColor(GOColor::RED);
m_GuideTxtRollPitch->SetColor(GOColor::WHITE);

m_GuideTxtRollPitch->SetTextSize(GOTextSize::ExtraSmall);

m_AllPrimitives.push_back(m_LineFaceNormal);
m_AllPrimitives.push_back(m_LineBladeNormal);
m_AllPrimitives.push_back(m_LinePitchFeed);
m_AllPrimitives.push_back(m_GuideTxtRollPitch);

Deactivate();
}

CutCircularSawFeedbackVisualizer::CutCircularSawFeedbackVisualizer()
Expand All @@ -65,6 +73,8 @@ namespace AIAC
m_ProjLineOfBlade->SetColor(GOColor::CYAN);
m_TxtBottomDist->SetColor(GOColor::WHITE);

m_TxtBottomDist->SetTextSize(GOTextSize::ExtraSmall);

m_AllPrimitives.push_back(m_BottomPoint);
m_AllPrimitives.push_back(m_LineToBottomPt);
m_AllPrimitives.push_back(m_ProjLineOnFace);
Expand All @@ -86,8 +96,10 @@ namespace AIAC
}

void CutCircularSawFeedback::Deactivate() {
m_CutPlaneVisualizer.Deactivate();
m_GeneralVisualizer.Deactivate();
m_CutPlaneVisualizer.Deactivate();
m_OrientationVisualizer.Deactivate();
m_PositionStartVisualizer.Deactivate();
}

void CutCircularSawFeedback::updateToolPosition() {
Expand Down
Loading

0 comments on commit 67540a6

Please sign in to comment.