mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 01:20:25 +08:00
Labels shown in the GUI (added also "Label current location..." action in Detection menu)
This commit is contained in:
@@ -77,7 +77,8 @@ public:
|
||||
kCmdTriggerNewMap,
|
||||
kCmdPause,
|
||||
kCmdGoal, // params: label or location ID
|
||||
kCmdCancelGoal};
|
||||
kCmdCancelGoal,
|
||||
kCmdLabel}; // // params: label or location ID
|
||||
public:
|
||||
RtabmapEventCmd(Cmd cmd, const std::string & strValue = "", int intValue = 0, const ParametersMap & parameters = ParametersMap()) :
|
||||
UEvent(0),
|
||||
@@ -190,6 +191,22 @@ private:
|
||||
std::vector<std::pair<int, Transform> > _poses;
|
||||
};
|
||||
|
||||
class RtabmapLabelErrorEvent : public UEvent
|
||||
{
|
||||
public:
|
||||
RtabmapLabelErrorEvent(int id, const std::string & label):
|
||||
UEvent(id),
|
||||
_label(label){}
|
||||
|
||||
virtual ~RtabmapLabelErrorEvent() {}
|
||||
int id() const {return this->getCode();}
|
||||
const std::string & label() const {return _label;}
|
||||
virtual std::string getClassName() const {return std::string("RtabmapLabelErrorEvent");}
|
||||
|
||||
private:
|
||||
std::string _label;
|
||||
};
|
||||
|
||||
} // namespace rtabmap
|
||||
|
||||
#endif /* RTABMAPEVENT_H_ */
|
||||
|
||||
@@ -75,7 +75,8 @@ public:
|
||||
kStateTriggeringMap,
|
||||
kStateAddingUserData,
|
||||
kStateSettingGoal,
|
||||
kStateCancellingGoal
|
||||
kStateCancellingGoal,
|
||||
kStateLabelling
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
@@ -289,6 +289,12 @@ void RtabmapThread::mainLoop()
|
||||
case kStateCancellingGoal:
|
||||
_rtabmap->clearPath();
|
||||
break;
|
||||
case kStateLabelling:
|
||||
if(!_rtabmap->labelLocation(atoi(parameters.at("id").c_str()), parameters.at("label").c_str()))
|
||||
{
|
||||
this->post(new RtabmapLabelErrorEvent(atoi(parameters.at("id").c_str()), parameters.at("label").c_str()));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
UFATAL("Invalid state !?!?");
|
||||
break;
|
||||
@@ -500,6 +506,14 @@ void RtabmapThread::handleEvent(UEvent* event)
|
||||
ULOGGER_DEBUG("CMD_CANCEL_GOAL");
|
||||
pushNewState(kStateCancellingGoal);
|
||||
}
|
||||
else if(cmd == RtabmapEventCmd::kCmdLabel)
|
||||
{
|
||||
ULOGGER_DEBUG("CMD_LABEL");
|
||||
ParametersMap param;
|
||||
param.insert(ParametersPair("label", rtabmapEvent->getStr()));
|
||||
param.insert(ParametersPair("id", uNumber2Str(rtabmapEvent->getInt())));
|
||||
pushNewState(kStateLabelling, param);
|
||||
}
|
||||
else
|
||||
{
|
||||
UWARN("Cmd %d unknown!", cmd);
|
||||
|
||||
Reference in New Issue
Block a user