yarp-devices
Jr3Pci.hpp
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 
3 #ifndef __JR3_PCI_HPP__
4 #define __JR3_PCI_HPP__
5 
6 #include <string>
7 #include <vector>
8 
9 #include <yarp/dev/DeviceDriver.h>
10 #include <yarp/dev/IAnalogSensor.h>
11 #include <yarp/dev/MultipleAnalogSensorsInterfaces.h>
12 
13 #include <jr3pci-ioctl.h>
14 
15 namespace roboticslab
16 {
17 
28 class Jr3Pci : public yarp::dev::DeviceDriver,
29  public yarp::dev::IAnalogSensor,
30  public yarp::dev::ISixAxisForceTorqueSensors
31 {
32 public:
33  Jr3Pci() : fd(0)
34  { }
35 
36  ~Jr3Pci() override
37  { close(); }
38 
39  // --------- DeviceDriver Declarations. Implementation in DeviceDriverImpl.cpp ---------
40  bool open(yarp::os::Searchable& config) override;
41  bool close() override;
42 
43  // --------- IAnalogSensor Declarations. Implementation in IAnalogSensorImpl.cpp ---------
49  int read(yarp::sig::Vector &out) override;
50 
56  int getState(int ch) override;
57 
62  int getChannels() override;
63 
68  int calibrateSensor() override;
69 
75  int calibrateSensor(const yarp::sig::Vector& value) override;
76 
82  int calibrateChannel(int ch) override;
83 
90  int calibrateChannel(int ch, double value) override;
91 
92  // --------- ISixAxisForceTorqueSensors Declarations. Implementation in ISixAxisForceTorqueSensorsImpl.cpp ---------
93  std::size_t getNrOfSixAxisForceTorqueSensors() const override;
94  yarp::dev::MAS_status getSixAxisForceTorqueSensorStatus(std::size_t sens_index) const override;
95  bool getSixAxisForceTorqueSensorName(std::size_t sens_index, std::string & name) const override;
96  bool getSixAxisForceTorqueSensorFrameName(std::size_t sens_index, std::string & name) const override;
97  bool getSixAxisForceTorqueSensorMeasure(std::size_t sens_index, yarp::sig::Vector & out, double & timestamp) const override;
98 
99 private:
100  void loadFilters(int id);
101 
102  int fd {0};
103  force_array fs[4];
104  unsigned long int filters[4];
105  std::vector<std::string> names {"ch0", "ch1", "ch2", "ch3"};
106  bool isDextrorotary {false};
107 };
108 
109 } // namespace roboticslab
110 
111 #endif // __JR3_PCI_HPP__
Implementation for the JR3 sensor (PCi board).
Definition: Jr3Pci.hpp:31
int getChannels() override
Definition: IAnalogSensorImpl.cpp:50
int calibrateSensor() override
Definition: IAnalogSensorImpl.cpp:57
int read(yarp::sig::Vector &out) override
Definition: IAnalogSensorImpl.cpp:15
int getState(int ch) override
Definition: IAnalogSensorImpl.cpp:43
int calibrateChannel(int ch) override
Definition: IAnalogSensorImpl.cpp:86
The main, catch-all namespace for Robotics Lab UC3M.
Definition: groups.dox:6