1#include "pluginexample.h"
2#include "robodktools.h"
6#include "formrobotpilot.h"
17#include <QDesktopServices>
23 return "Example Plugin";
32 qDebug() <<
"Using settings: " << settings;
35 qDebug() <<
"Setting up the status bar";
39 Q_INIT_RESOURCE(resources1);
42 action_information =
new QAction(QIcon(
":/resources/information.png"), tr(
"Plugin Speed Information"));
43 action_robotpilot =
new QAction(QIcon(
":/resources/code.png"), tr(
"Robot Pilot Form"));
44 action_help =
new QAction(QIcon(
":/resources/help.png"), tr(
"RoboDK Plugins - Help"));
51 menu1 = menubar->addMenu(
"Plugin Example Menu");
52 qDebug() <<
"Setting up the menu bar";
68 qDebug() <<
"Unloading plugin " <<
PluginName();
84 Q_CLEANUP_RESOURCE(resources1);
89 toolbar1 = mw->addToolBar(
"Plugin Example Toolbar");
90 toolbar1->setIconSize(QSize(icon_size, icon_size));
103 qDebug() <<
"Selected item: " << item->
Name() <<
" of type " << item->
Type() <<
" click type: " << click_type;
120 qDebug() <<
"Sent command: " << command <<
" With value: " << value;
121 if (command.compare(
"Information", Qt::CaseInsensitive) == 0){
124 }
else if (command.compare(
"RobotPilot", Qt::CaseInsensitive) == 0){
158 qDebug() <<
"==== EventChanged ====";
165 qDebug() <<
"==== EventChangedStation ====";
174 qDebug() <<
"==== EventAbout2Save ====";
182 qDebug() <<
"==== EventAbout2ChangeStation ====";
192 qDebug() <<
"==== EventAbout2CloseStation ====";
202 qDebug() <<
"==== EventTrajectoryStep ====";
207 qDebug() <<
"Unknown/future event: " << event_type;
222 case EVENT_SELECTIONTREE_CHANGED:
223 qDebug() <<
"EVENT_SELECTIONTREE_CHANGED";
227 qDebug() <<
"EVENT_ITEM_MOVED";
230 case EVENT_REFERENCE_PICKED:
231 qDebug() <<
"EVENT_REFERENCE_PICKED";
234 case EVENT_REFERENCE_RELEASED:
235 qDebug() <<
"EVENT_REFERENCE_RELEASED";
238 case EVENT_TOOL_MODIFIED:
239 qDebug() <<
"EVENT_TOOL_MODIFIED";
242 case EVENT_CREATED_ISOCUBE:
243 qDebug() <<
"EVENT_CREATED_ISOCUBE";
246 case EVENT_SELECTION3D_CHANGED:
247 qDebug() <<
"EVENT_SELECTION3D_CHANGED";
250 case EVENT_VIEWPOSE_CHANGED:
251 qDebug() <<
"EVENT_VIEWPOSE_CHANGED";
254 case EVENT_ROBOT_MOVED:
255 qDebug() <<
"EVENT_ROBOT_MOVED";
259 qDebug() <<
"EVENT_KEY";
262 case EVENT_ITEM_MOVED_POSE:
263 qDebug() <<
"EVENT_ITEM_MOVED_POSE";
266 case EVENT_COLLISIONMAP_RESET:
267 qDebug() <<
"EVENT_COLLISIONMAP_RESET";
270 case EVENT_COLLISIONMAP_TOO_LARGE:
271 qDebug() <<
"EVENT_COLLISIONMAP_TOO_LARGE";
274 case EVENT_CALIB_MEASUREMENT:
275 qDebug() <<
"EVENT_CALIB_MEASUREMENT";
279 qDebug() <<
"EVENT_SELECTION3D_CLICK";
283 qDebug() <<
"EVENT_CHANGED";
287 qDebug() <<
"EVENT_RENAME";
291 qDebug() <<
"EVENT_SETVISIBLE";
295 qDebug() <<
"EVENT_STATIONCHANGED";
299 qDebug() <<
"EVENT_PROGSLIDER_CHANGED";
303 qDebug() <<
"EVENT_PROGSLIDER_SET";
307 qDebug() <<
"Unknown/future API event: " << apiEvent;
319 QString text_message_html(
"<strong>Plugin Timing Tests Summary on " + QDateTime::currentDateTime().toString() +
":</strong><br>");
324 if (ItemValid(robot)){
327 QList<tJoints> joints_ik_all;
331 text_message_html += +
"<br>" + QString(
"Using robot %1").arg(robot->
Name());
334 tstart = QDateTime::currentMSecsSinceEpoch();
335 for (
int i=0; i<ntests; i++){
338 tend = QDateTime::currentMSecsSinceEpoch();
339 text_message_html += +
"<br>" + QString(
"Forward Kinematics: %1 micro seconds").arg(((
double)(tend-tstart)*1000)/ntests, 0,
'f', 2);
342 tstart = QDateTime::currentMSecsSinceEpoch();
343 for (
int i=0; i<ntests; i++){
344 joints_ik = robot->
SolveIK(pose_fk);
346 tend = QDateTime::currentMSecsSinceEpoch();
347 text_message_html +=
"<br>" + QString(
"Inverse Kinematics: %1 micro seconds").arg(((
double)(tend-tstart)*1000)/ntests, 0,
'f', 2);
350 tstart = QDateTime::currentMSecsSinceEpoch();
351 for (
int i=0; i<ntests; i++){
354 tend = QDateTime::currentMSecsSinceEpoch();
355 text_message_html +=
"<br>" + QString(
"Inverse Kinematics: %1 micro seconds (all solutions)").arg(((
double)(tend-tstart)*1000)/ntests, 0,
'f', 2);
357 text_message_html += +
"<br>No robot available to run Kinematic tests";
362 qDebug() << text_message_html;
367 qDebug() <<
"Available items in the current station: " << item_list_names;
372 text_message_html += QString(
"<br>Open station <strong>%1</strong> items:").arg(
RDK->
getActiveStation()->
Name());
373 foreach (
Item itm, item_list){
375 if (!ItemValid(item_parent)){
377 text_message_html += QString(
"<br>%1 (station)").arg(itm->
Name());
379 text_message_html += QString(
"<br>%1 -> <i>parent: %2</i>").arg(itm->
Name()).arg(item_parent->
Name());
385 QTextEdit *text_editor =
new QTextEdit(
"Plugin timing summary");
386 text_editor->setHtml(text_message_html);
388 AddDockWidget(
MainWindow, text_editor,
"Dock Plugin timing summary");
409 QDesktopServices::openUrl(QUrl(
"https://robodk.com/CreatePlugin"));
@ EVENT_PROGSLIDER_CHANGED
A program slider was opened, changed, or closed (RoboDK 5.6.4 required).
@ EVENT_ITEM_MOVED
Obsolete after RoboDK 4.2.0. Use EVENT_ITEM_MOVED_POSE instead.
@ EVENT_PROGSLIDER_SET
The index of a program slider changed (RoboDK 5.6.4 required).
@ EVENT_RENAME
The name of an item changed (RoboDK 5.6.3 required).
@ EVENT_STATIONCHANGED
A new robodk station was loaded (RoboDK 5.6.3 required).
@ EVENT_SETVISIBLE
The visibility state of an item changed (RoboDK 5.6.3 required).
@ EVENT_SELECTION3D_CLICK
An object in the 3D view was clicked on (right click, left click or double click),...
TypeEvent
Event types for PluginEvent function.
@ EventAbout2ChangeStation
The current RoboDK station is about to loose focus because the user requested to open a new station (...
@ EventAbout2CloseStation
@ EventChangedStation
This event is triggered when we change the active station and a new station gains focus (IRoboDK::get...
@ EventMoved
Moved event: Something has moved, such as a robot, reference frame, object or tool....
TypeClick
Types of clicks for PluginItemClick function.
The Item class represents an item in RoboDK station. An item can be a robot, a frame,...
virtual int Type()=0
Item type (object, robot, tool, reference, robot machining project, ...)
virtual tJoints SolveIK(const Mat &pose, const tJoints *joints_close=nullptr, const Mat *tool_pose=nullptr, const Mat *reference_pose=nullptr)=0
Computes the inverse kinematics for the specified robot and pose. The joints returned are the closest...
@ ITEM_TYPE_ROBOT
Item of type robot (.robot file)
@ ITEM_TYPE_OBJECT
Item of type object (.stl, .step or .iges for example)
virtual QString Name()=0
Returns the name of an item. The name of the item is always displayed in the RoboDK station tree.
virtual Mat SolveFK(const tJoints &joints, const Mat *tool_pose=nullptr, const Mat *reference_pose=nullptr)=0
Computes the forward kinematics of the robot for the provided joints. The tool and the reference fram...
virtual Item Parent()=0
Return the parent item of this item.
virtual QList< tJoints > SolveIK_All(const Mat &pose, const Mat *tool_pose=nullptr, const Mat *reference_pose=nullptr)=0
Computes the inverse kinematics for the specified robot and pose. The function returns all available ...
virtual tJoints Joints()=0
Returns the current joints of a robot or the joints of a target. If the item is a cartesian target,...
This class is the iterface to the RoboDK API. With the RoboDK API you can automate certain tasks and ...
virtual Item ItemUserPick(const QString &message="Pick one item", int itemtype=-1)=0
Shows a RoboDK popup to select one object from the open RoboDK station. An item type can be specified...
virtual void ShowMessage(const QString &message, bool popup=true)=0
Show a message in RoboDK (it can be blocking or non blocking in the status bar)
virtual Item getActiveStation()=0
Returns the active station item (station currently visible).
virtual QStringList getItemListNames(int filter=-1)=0
Returns a list of items (list of names or Items) of all available items in the currently open station...
virtual QList< Item > getItemList(int filter=-1)=0
Returns a list of items (list of names or pointers) of all available items in the currently open stat...
virtual void PluginEvent(TypeEvent event_type) override
This function is called every time there is a new RoboDK event such as rendering the screen,...
void callback_information()
Called when the information button/action is selected.
QDockWidget * dock_robotpilot
Pointer to the docked window.
void callback_robotpilot()
Called when the robot pilot button/action is selected.
FormRobotPilot * form_robotpilot
Pointer to the robot pilot form.
QToolBar * toolbar1
Pointer to the customized toolbar.
void callback_help()
Called when the user select the button/action for help.
virtual void PluginUnload() override
This function is called once only when the plugin is being unloaded.
QString PluginName(void) override
Return the plugin name. Try to be creative and make sure the name is unique.
QMainWindow * MainWindow
RoboDK's main window pointer.
QStatusBar * StatusBar
RoboDK's main status bar pointer.
void callback_robotpilot_closed()
Called when the robot pilot window is closed (event triggered by the dock window)
QAction * action_robotpilot
Open robot pilot form action. callback_robotpilot is triggered with this action. Actions are required...
QMenu * menu1
Pointer to the customized menu.
RoboDK * RDK
Pointer to the RoboDK API interface.
virtual QString PluginCommand(const QString &command, const QString &value) override
Specific commands can be passed from the RoboDK API. For example, a parent application can rely on a ...
virtual bool PluginItemClick(Item item, QMenu *menu, TypeClick click_type) override
This function is called every time a new context menu is created for an item.
QAction * action_help
Open help action. callback_help is triggered with this action. Actions are required to populate toolb...
virtual QString PluginLoad(QMainWindow *mw, QMenuBar *menubar, QStatusBar *statusbar, RoboDK *rdk, const QString &settings="") override
Load the plugin. This function is called only once when the plugin is loaded (or RoboDK is started wi...
virtual void PluginLoadToolbar(QMainWindow *mw, int icon_size) override
This function is called every time the toolbar is set up. This function is called at least once right...
QAction * action_information
Information action. callback_information is triggered with this action. Actions are required to popul...
The Joints class represents a joint position of a robot (robot axes).
The Matrix4x4 class represents a 4x4 transformation matrix in 3D space.