Skip to content

Commit

Permalink
nuew attributrees
Browse files Browse the repository at this point in the history
  • Loading branch information
pbustos committed Jun 3, 2024
1 parent a8be036 commit e033f2e
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 42 deletions.
13 changes: 13 additions & 0 deletions core/include/dsr/core/types/type_checking/dsr_attr_name.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ REGISTER_TYPE(plan_target_node_id, int, false)
REGISTER_TYPE(current_intention, std::reference_wrapper<const std::string>, false)
REGISTER_TYPE(grid_as_string, std::reference_wrapper<const std::string>, false)
REGISTER_TYPE(arrival_time, float, false)


/*
* World
* */
Expand Down Expand Up @@ -297,6 +299,7 @@ REGISTER_TYPE(corner2, std::reference_wrapper<const std::vector<float>>, false);
REGISTER_TYPE(corner3, std::reference_wrapper<const std::vector<float>>, false);
REGISTER_TYPE(corner4, std::reference_wrapper<const std::vector<float>>, false);


/* * * * * * * * * * *
* MELEX-RODAO ATTR *
* * * * * * * * * * */
Expand Down Expand Up @@ -424,6 +427,16 @@ REGISTER_TYPE(corner_id, int, false)
REGISTER_TYPE(valid, bool, false)


/*
* INTENTION EDGE
* */
/* agent_id and valid are already defined */
REGISTER_TYPE(state, std::string, false) /* State of the intention edge { waiting, in_progress, aborted, failed, completed} */
REGISTER_TYPE(offset_xyz, std::reference_wrapper<const std::vector<float>>, false) /* 3-vector Offset for the edge */
REGISTER_TYPE(orientation, std::reference_wrapper<const std::vector<float>>, false) /* 3-vector Orientation for the offset */
REGISTER_TYPE(tolerance, std::reference_wrapper<const std::vector<float>>, false) /* 6-vector Tolerance for the offset and orientation*/
REGISTER_TYPE(subsystem, std::string, false) /* Subsystem that will execute the intention {base, arm_0, head}*/


/* TESTS
* */
Expand Down
1 change: 1 addition & 0 deletions core/include/dsr/core/types/type_checking/dsr_edge_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ REGISTER_EDGE_TYPE(has_intention)
REGISTER_EDGE_TYPE(collision)
REGISTER_EDGE_TYPE(TARGET)
REGISTER_EDGE_TYPE(testtype_e)
REGISTER_EDGE_TYPE(current)

#endif //DSR_EDGE_TYPE_H
2 changes: 1 addition & 1 deletion gui/dsr_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ DSRViewer::DSRViewer(QMainWindow *widget, std::shared_ptr<DSR::DSRGraph> G_, int
create_status_bar();
timer = new QTimer();
alive_timer.start();
timer->start(500);
timer->start(1000);
init(); //intialize processor number
connect(timer, SIGNAL(timeout()), this, SLOT(compute()));
connect(G.get(), &DSR::DSRGraph::update_node_signal, this, &DSRViewer::add_or_assign_node_SLOT,
Expand Down
3 changes: 1 addition & 2 deletions gui/viewers/_abstract_graphic_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ AbstractGraphicViewer::AbstractGraphicViewer(QWidget* parent) : QGraphicsView(p
this->fitInView(scene.sceneRect(), Qt::KeepAspectRatio);
this->setMouseTracking(true);
this->viewport()->setMouseTracking(true);

this->adjustSize();
}


//////////////////////////////////////////////////////////////////////////////////////
///// EVENTS
//////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -51,6 +49,7 @@ void AbstractGraphicViewer::wheelEvent(QWheelEvent* event)
this->scale(factor, factor);
auto delta = this->mapToScene(view_pos) - this->mapToScene(this->viewport()->rect().center());
this->centerOn(scene_pos - delta);
//qInfo()<< "wheel_event" << event->angleDelta().y() << factor << event->position().toPoint();
}

void AbstractGraphicViewer::resizeEvent(QResizeEvent *e)
Expand Down
74 changes: 35 additions & 39 deletions gui/viewers/qscene_2d_viewer/qscene_2d_viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,37 @@ QScene2dViewer::QScene2dViewer(std::shared_ptr<DSR::DSRGraph> G_, QWidget *paren
G = std::move(G_);
this->setMinimumSize(400,400);
scene.setItemIndexMethod(QGraphicsScene::NoIndex);
this->setSceneRect(-5000, -5000, 10000, 10000);
this->scale(1, -1);
this->fitInView(scene.sceneRect(), Qt::KeepAspectRatio);
this->adjustSize();

//context menu
contextMenu = new QMenu(this);
showMenu = contextMenu->addMenu(tr("&Show:"));
QAction *action = new QAction("Laser");
action->setCheckable(true);
action->setChecked(false);
showMenu->addAction(action);
connect(action, &QAction::toggled, this, [this](bool checked){
this->set_draw_laser(checked);
this->draw_laser();
});
QAction *action2 = new QAction("Person polyline");
action2->setCheckable(true);
action2->setChecked(false);
showMenu->addAction(action2);
connect(action2, &QAction::toggled, this, [this](bool checked){
this->set_draw_people_spaces(checked);
});
QAction *action3 = new QAction("Axis");
action3->setCheckable(true);
action3->setChecked(false);
showMenu->addAction(action3);
connect(action3, &QAction::toggled, this, [this](bool checked){
this->set_draw_axis(checked);
this->draw_axis();
});
// contextMenu = new QMenu(this);
// showMenu = contextMenu->addMenu(tr("&Show:"));
// QAction *action = new QAction("Laser");
// action->setCheckable(true);
// action->setChecked(false);
// showMenu->addAction(action);
// connect(action, &QAction::toggled, this, [this](bool checked){
// this->set_draw_laser(checked);
// this->draw_laser();
// });
// QAction *action2 = new QAction("Person polyline");
// action2->setCheckable(true);
// action2->setChecked(false);
// showMenu->addAction(action2);
// connect(action2, &QAction::toggled, this, [this](bool checked){
// this->set_draw_people_spaces(checked);
// });
// QAction *action3 = new QAction("Axis");
// action3->setCheckable(true);
// action3->setChecked(false);
// showMenu->addAction(action3);
// connect(action3, &QAction::toggled, this, [this](bool checked){
// this->set_draw_axis(checked);
// this->draw_axis();
// });
//AXIS
//center position
axis_center = new QGraphicsRectItem(-100, -100, 200, 200);
Expand All @@ -60,11 +61,11 @@ QScene2dViewer::QScene2dViewer(std::shared_ptr<DSR::DSRGraph> G_, QWidget *paren
create_graph();

//update signals
connect(G.get(), &DSR::DSRGraph::update_node_signal, this, &QScene2dViewer::add_or_assign_node_slot, Qt::QueuedConnection);
connect(G.get(), &DSR::DSRGraph::update_edge_signal, this, &QScene2dViewer::add_or_assign_edge_slot, Qt::QueuedConnection);

connect(G.get(), &DSR::DSRGraph::del_edge_signal, this, &QScene2dViewer::del_edge_slot, Qt::QueuedConnection);
connect(G.get(), &DSR::DSRGraph::del_node_signal, this, &QScene2dViewer::del_node_slot, Qt::QueuedConnection);
// connect(G.get(), &DSR::DSRGraph::update_node_signal, this, &QScene2dViewer::add_or_assign_node_slot, Qt::QueuedConnection);
// connect(G.get(), &DSR::DSRGraph::update_edge_signal, this, &QScene2dViewer::add_or_assign_edge_slot, Qt::QueuedConnection);
//
// connect(G.get(), &DSR::DSRGraph::del_edge_signal, this, &QScene2dViewer::del_edge_slot, Qt::QueuedConnection);
// connect(G.get(), &DSR::DSRGraph::del_node_signal, this, &QScene2dViewer::del_node_slot, Qt::QueuedConnection);
qDebug()<<"***************END QScene2dViewer********************";
}

Expand All @@ -81,7 +82,6 @@ void QScene2dViewer::create_graph()
{
std::cout << e.what() << " Error accessing "<< __FUNCTION__<<":"<<__LINE__<< std::endl;
}

}

//////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -464,10 +464,8 @@ void QScene2dViewer::update_scene_object_pose(std::uint64_t node_id)
item->setPos(pose.value().x() - item->boundingRect().center().x(), pose.value().y() - item->boundingRect().center().y());
item->setRotation(qRadiansToDegrees(pose.value()[5]));
}
else
{
else
qDebug()<<"Error getting transformation from person"<<QString::fromStdString(node.value().name())<<"to world";
}
}
}

Expand All @@ -491,10 +489,8 @@ void QScene2dViewer::del_node_slot(std::uint64_t id)
}

//remove from ignored just to keep consistency
if (ignore_nodes.find(id) != ignore_nodes.end())
{
if (ignore_nodes.find(id) != ignore_nodes.end())
ignore_nodes.erase(id);
}

//TODO: check what happens with rt edges
}
Expand All @@ -510,8 +506,8 @@ void QScene2dViewer::del_edge_slot(std::uint64_t from, std::uint64_t to, const
}
}

void QScene2dViewer::reload(QWidget* widget) {

void QScene2dViewer::reload(QWidget* widget)
{
if(qobject_cast<QScene2dViewer*>(widget) == this)
{
std::cout<<"Reloading 2D viewer"<<std::endl;
Expand Down

0 comments on commit e033f2e

Please sign in to comment.