YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
partitem.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 */
6
7#ifndef PARTITEM_H
8#define PARTITEM_H
9
10#include "flowlayout.h"
11#include "sequencewindow.h"
12#include "jointitem.h"
13#include "piddlg.h"
14#include "yarpmotorgui.h"
15
17#include <yarp/os/Port.h>
18#include <yarp/os/Network.h>
22#include <yarp/dev/PolyDriver.h>
23#include <yarp/sig/Vector.h>
24#include <yarp/os/Time.h>
26#include <yarp/os/Stamp.h>
27
28#include <QWidget>
29#include <QTimer>
30
31
32
33using namespace yarp::dev;
34using namespace yarp::sig;
35using namespace yarp::os;
36
37#define MAX_WIDTH_JOINT 320
38
39class PartItem : public QWidget
40{
42public:
43 explicit PartItem(std::string robotName,
44 int partId,
45 std::string partName,
50 QWidget *parent = 0);
51
52
53 ~PartItem();
54 bool openPolyDrivers();
55 void initInterfaces();
56 bool openInterfaces();
57 bool getInterfaceError();
58 void openSequenceWindow();
61 bool checkAndRunAllSeq();
65 void runPart();
66 void idlePart();
67 bool homeJoint(int joint);
68 bool homePart();
70 void calibratePart();
71 bool checkAndGo();
72 void stopSequence();
73 void setTreeWidgetModeNode(QTreeWidgetItem *node);
74 void loadSequence();
76 QTreeWidgetItem *getTreeWidgetModeNode();
79 void resizeWidget(int w);
82 JointItem* getJointWidget(int jointIndex);
83
84
85private:
86 void fixedTimeMove(SequenceItem sequence);
87
88protected:
89 void resizeEvent(QResizeEvent *event) override;
90 void changeEvent(QEvent *event) override;
91
92private:
93 FlowLayout *m_layout;
94 SequenceWindow *m_sequenceWindow;
95 std::string m_robotPartPort;
96 std::string m_robotName;
97 std::string m_partName;
98 int m_partId;
99 bool m_mixedEnabled;
100 bool m_positionDirectEnabled;
101 bool m_pwmEnabled;
102 bool m_currentEnabled;
103 PidDlg *m_currentPidDlg;
104 Stamp m_sequence_port_stamp;
105 QTimer m_runTimer;
106 QTimer m_runTimeTimer;
107 QTimer m_cycleTimer;
108 QTimer m_cycleTimeTimer;
109
110 QList<SequenceItem> m_runValues;
111 QList<SequenceItem> m_runTimeValues;
112 QList<SequenceItem> m_cycleValues;
113 QList<SequenceItem> m_cycleTimeValues;
114 std::vector<int> m_controlModes;
115 std::vector<double> m_refTrajectorySpeeds;
116 std::vector<double> m_refTrajectoryPositions;
117 std::vector<double> m_refTorques;
118 std::vector<double> m_refVelocitySpeeds;
119 std::vector<double> m_torques;
120 std::vector<double> m_positions;
121 std::vector<double> m_speeds;
122 std::vector<double> m_currents;
123 std::vector<double> m_motorPositions;
124 std::vector<double> m_dutyCycles;
125 std::vector<bool> m_done;
126 bool m_part_speedVisible;
127 bool m_part_motorPositionVisible;
128 bool m_part_dutyVisible;
129 bool m_part_currentVisible;
130 std::vector<InteractionModeEnum> m_interactionModes;
132
133 ResourceFinder* m_finder;
134 PolyDriver* m_partsdd;
135 Property m_partOptions;
136 Port m_sequence_port;
137 bool m_interfaceError;
138
139 IPositionControl *m_iPos;
140 IPositionDirect *m_iDir;
141 IVelocityControl *m_iVel;
142 IRemoteVariables *m_iVar;
143 IEncoders *m_iencs;
144 IMotorEncoders *m_iMot;
145 IAmplifierControl *m_iAmp;
146 IPidControl *m_iPid;
147 ICurrentControl *m_iCur;
148 IPWMControl *m_iPWM;
149 ITorqueControl *m_iTrq;
150 IImpedanceControl *m_iImp;
151 IAxisInfo *m_iinfo;
152 IControlLimits *m_iLim;
153 IControlCalibration *m_ical;
154 IControlMode *m_ictrlmode;
155 IInteractionMode *m_iinteract;
156 IJointFault *m_ijointfault;
157 IRemoteCalibrator *m_iremCalib;
158 int m_slow_k;
159
160signals:
170
171public slots:
172 void updateControlMode();
173 bool updatePart();
174 void onViewSpeedValues(bool);
175 void onViewMotorPositions(bool);
176 void onViewDutyCycles(bool);
177 void onViewCurrentValues(bool);
178 void onSetPosSliderOptionPI(int mode, double step, int numOfDec);
179 void onSetVelSliderOptionPI(int mode, double step);
180 void onSetTrqSliderOptionPI(int mode, double step);
181 void onSetCurSliderOptionPI(int mode, double step);
182 void onViewPositionTargetBox(bool);
183 void onViewPositionTargetValue(bool);
185 void onEnableControlMixed(bool control);
187 void onEnableControlPWM(bool control);
189
190private slots:
191 void onSequenceActivated();
192 void onSequenceStopped();
193 void onStopSequence();
194 void onCycleTimeTimerTimeout();
195 void onCycleTimerTimeout();
196 void onRunTimerTimeout();
197 void onRunTimeout();
198 void onGo(SequenceItem);
199 void onOpenSequence();
200 void onSaveSequence(QList<SequenceItem> values, QString fileName);
201 void onSequenceRunTime(QList<SequenceItem>);
202 void onSequenceRun(QList<SequenceItem> values);
203 void onSequenceCycle(QList<SequenceItem>);
204 void onSequenceCycleTime(QList<SequenceItem>);
205 void onCalibClicked(JointItem *joint);
206 void onJointChangeMode(int mode,JointItem *joint);
207 void onJointInteraction(int interaction,JointItem *joint);
208 void onSliderDirectPositionCommand(double dirpos, int index);
209 void onSliderMixedPositionCommand(double pos, int index);
210 void onSliderMixedVelocityCommand(double vel, int index);
211 void onSliderTorqueCommand(double torqueVal, int index);
212 void onSliderTrajectoryPositionCommand(double pos, int index);
213 void onSliderTrajectoryVelocityCommand(double speedVal, int index);
214 void onSliderPWMCommand(double dutyVal, int index);
215 void onSliderCurrentCommand(double current, int index);
216 void onSliderVelocityCommand(double speedVal, int index);
217 void onSequenceWindowDoubleClicked(int sequenceNum);
218 void onHomeClicked(JointItem *joint);
219 void onIdleClicked(JointItem *joint);
220 void onRunClicked(JointItem *joint);
221 void onPidClicked(JointItem *joint);
222 void onSendPositionPid(int jointIndex, Pid newPid);
223 void onSendVelocityPid(int jointIndex, Pid newPid);
224 void onSendCurrentPid(int jointIndex, Pid newPid);
225 void onSendSingleRemoteVariable(std::string key, yarp::os::Bottle val);
226 void onUpdateAllRemoteVariables();
227 void onSendTorquePid(int jointIndex, Pid newPid, MotorTorqueParameters newTorqueParam);
228 void onSendStiffness(int jointIdex, double stiff, double damp, double force);
229 void onSendPWM(int jointIndex, double dutyVal);
230 void onRefreshPids(int jointIndex);
231 void onDumpAllRemoteVariables();
232
233
234};
235
236#endif // PARTITEM_H
define control board standard interfaces
define control board standard interfaces
contains the definition of a Vector type
Original license follows:
Definition flowlayout.h:59
void initInterfaces()
Definition partitem.cpp:353
bool openPolyDrivers()
Definition partitem.cpp:332
bool checkAndGo()
void onSetCurSliderOptionPI(int mode, double step)
void cycleTimeSequence()
bool homePart()
bool checkAndRunAllSeq()
void onViewDutyCycles(bool)
void resizeWidget(int w)
bool homeToCustomPosition(const yarp::os::Bottle &positionElement)
void setCurrentIndex(int)
void runTimeSequence()
void idlePart()
JointItem * getJointWidget(int jointIndex)
int getNumberOfJoints()
void onEnableControlCurrent(bool control)
bool getInterfaceError()
Definition partitem.cpp:481
void onViewMotorPositions(bool)
void onEnableControlPWM(bool control)
void runPart()
void onEnableControlVelocity(bool control)
QString getJointName(int joint)
QString getPartName()
Definition partitem.cpp:486
void onViewPositionTargetValue(bool)
void onViewPositionTargetBox(bool)
bool homeJoint(int joint)
void onViewCurrentValues(bool)
void runSequence()
void sendPartJointsValues(int, QList< double >, QList< double >)
bool checkAndCycleAllSeq()
void closeSequenceWindow()
bool updatePart()
void onViewSpeedValues(bool)
void openSequenceWindow()
void updateControlMode()
void stopSequence()
void stoppedSequence()
void onEnableControlPositionDirect(bool control)
void saveSequence(QString global_filename)
void resizeEvent(QResizeEvent *event) override
void changeEvent(QEvent *event) override
void loadSequence()
void sequenceStopped()
const QVector< JointItem::JointState > & getPartModes()
void cycleSequence()
void onEnableControlMixed(bool control)
bool cycleAllSeq()
void onSetPosSliderOptionPI(int mode, double step, int numOfDec)
void sequenceActivated()
void onSetTrqSliderOptionPI(int mode, double step)
bool checkAndRunTimeAllSeq()
bool checkAndCycleTimeAllSeq()
QTreeWidgetItem * getTreeWidgetModeNode()
void setTreeWidgetModeNode(QTreeWidgetItem *node)
void onSetVelSliderOptionPI(int mode, double step)
void calibratePart()
bool openInterfaces()
Definition partitem.cpp:376
Interface for control devices, amplifier commands.
Interface for getting information about specific axes, if available.
Definition IAxisInfo.h:36
Interface for control devices, calibration commands.
Interface for control devices, commands to get/set position and veloity limits.
Interface for setting control mode in control board.
Interface for control boards implementing current control.
Control board, encoder interface.
Definition IEncoders.h:116
Interface for control boards implementing impedance control.
Interface settings the way the robot interacts with the environment: basic interaction types are Stif...
Interface for getting info about the fault which may occur on a robot.
Definition IJointFault.h:23
Control board, encoder interface.
Interface for controlling an axis, by sending directly a PWM reference signal to a motor.
Definition IPWMControl.h:23
Interface for a generic control board device implementing a PID controller, with scaled arguments.
Interface for a generic control board device implementing position control.
Interface for a generic control board device implementing position control.
IRemoteCalibrator interface is meant to remotize the access of the calibration device in order to all...
IRemoteVariables interface.
Interface for control boards implementing torque control.
Interface for control boards implementing velocity control.
Contains the parameters for a PID.
A container for a device driver.
Definition PolyDriver.h:23
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
A mini-server for performing network communication in the background.
A mini-server for network communication.
Definition Port.h:46
A class for storing options and configuration information.
Definition Property.h:33
Helper class for finding config files and other external resources.
An abstraction for a time stamp and/or sequence number.
Definition Stamp.h:21
bool speedview_param_enabled
Definition main.cpp:35
bool debug_param_enabled
Definition main.cpp:34
bool enable_calib_all
Definition main.cpp:36
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.