iCub-main
MotorTemperaturePublisher.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2024 iCub Facility - Istituto Italiano di Tecnologia
3  * Author: Jacopo Losi
4  * email: jacopo.losi@iit.it
5  * Permission is granted to copy, distribute, and/or modify this program
6  * under the terms of the GNU General Public License, version 2 or any
7  * later version published by the Free Software Foundation.
8  *
9  * A copy of the license can be found at
10  * http://www.robotcub.org/icub/license/gpl.txt
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15  * Public License for more details
16 */
17 
18 
19 #ifndef __MOTORTEMPERATUREPUBLISHER__
20 #define __MOTORTEMPERATUREPUBLISHER__
21 
22 #include <yarp/os/RFModule.h>
23 #include <yarp/dev/PolyDriver.h>
24 #include <yarp/sig/Vector.h>
25 #include <yarp/os/Bottle.h>
26 #include <yarp/dev/ControlBoardHelper.h>
27 #include <yarp/dev/ControlBoardInterfaces.h>
28 #include <yarp/os/BufferedPort.h>
29 
30 class MotorTemperaturePublisher: public yarp::os::RFModule
31 {
32 private:
33  yarp::dev::IMotor *_imot;
34  yarp::os::BufferedPort<yarp::os::Bottle> _outputPort;
35 
36  double *_motorTemperatures;
37  double *_motorTemperatureLimits;
38  int _nmotors;
39  int _nEnabledMotors = 0;
40 
41  std::string m_portPrefix="";
42  double _updatePeriod = 1; //seconds
43  std::string _robotName= "";
44  yarp::sig::Vector _listOfJoints = 0;
45 
46  yarp::dev::PolyDriver _motionControlDevice;
47 
48  bool sendData2OutputPort(double *temperatures);
49  bool alloc(int nm);
50  bool dealloc();
51 
52 public:
53 
55  ~MotorTemperaturePublisher() override;
56 
61 
62  bool configure(yarp::os::ResourceFinder &rf);
63  bool close();
64  double getPeriod();
65  bool updateModule();
66 };
67 
68 #endif
MotorTemperaturePublisher(const MotorTemperaturePublisher &)=default
MotorTemperaturePublisher(MotorTemperaturePublisher &&)=default
bool configure(yarp::os::ResourceFinder &rf)
MotorTemperaturePublisher & operator=(MotorTemperaturePublisher &&)=default
MotorTemperaturePublisher & operator=(const MotorTemperaturePublisher &)=default