10 #include "imstkEventObject.h" 11 #include "imstkSpinLock.h" 13 #include <unordered_map> 17 using DeviceType = int;
18 #define UNKNOWN_DEVICE 0 19 #define OPENHAPTICS_DEVICE 1 20 #define OPENVR_LEFT_CONTROLLER 3 21 #define OPENVR_RIGHT_CONTROLLER 4 24 using ButtonStateType = int;
25 #define BUTTON_RELEASED 0 26 #define BUTTON_TOUCHED 1 27 #define BUTTON_UNTOUCHED 2 28 #define BUTTON_PRESSED 3 33 ButtonEvent(std::string type,
const int button,
const ButtonStateType keyPressType) :
Event(type),
34 m_buttonState(keyPressType),
41 ButtonStateType m_buttonState;
42 const int m_button = -1;
65 const std::string&
getIp() {
return m_ip; }
66 void setIp(
const std::string& ip) { m_ip = ip; }
73 void setDeviceName(
const std::string& deviceName) { m_deviceName = deviceName; }
80 void setTrackingEnabled(
const bool status) { m_trackingEnabled = status; }
81 bool getAnalogicEnabled()
const {
return m_analogicEnabled; }
82 void setAnalogicEnabled(
const bool status) { m_analogicEnabled = status; }
83 bool getButtonsEnabled()
const {
return m_buttonsEnabled; }
84 void setButtonsEnabled(
const bool status) { m_buttonsEnabled = status; }
85 bool getForceEnabled()
const {
return m_forceEnabled; }
86 void setForceEnabled(
const bool status) { m_forceEnabled = status; }
101 Vec3d getAngularVelocity();
106 Quatd getOrientation();
111 const Vec3d&
getOffset()
const {
return m_endEffectorOffset; }
117 void setForce(Vec3d force);
123 const std::unordered_map<int, int>& getButtons()
const;
129 int getButton(
const int buttonId);
134 std::vector<double> getAnalog()
const;
140 double getAnalog(
int i)
const;
148 DeviceClient(
const std::string& name,
const std::string& ip);
153 bool m_trackingEnabled =
true;
154 bool m_analogicEnabled =
true;
155 bool m_buttonsEnabled =
true;
156 bool m_forceEnabled =
false;
163 Vec3d m_endEffectorOffset = Vec3d(0.0, 0.0, 0.0);
165 std::unordered_map<int, int> m_buttons;
166 std::vector<double> m_analogChannels;
The device client's represents the device and provides an interface to acquire data from a device...
Vec3d m_angularVelocity
Angular velocity of the end effector.
const std::string & getDeviceName()
Get/Set the device name.
const std::string & getIp()
Get/Set the device IP.
std::string m_ip
Connection device IP.
Base class for events which contain a type, priority, and data priority defaults to 0 and uses a grea...
const Vec3d & getOffset() const
Get offset from position for device end effector.
bool getTrackingEnabled() const
Get/Set what listeners to enable on the device: tracking, analogic, force, buttons.
ParallelUtils::SpinLock m_dataLock
Used for button and analog data.
ParallelUtils::SpinLock m_transformLock
Used for devices filling data from other threads.
virtual void update()
Do runtime logic.
Quatd m_orientation
Orientation of the end effector.
ParallelUtils::SpinLock m_forceLock
Used for devices filling data from other threads.
Vec3d m_velocity
Linear velocity of end effector.
Vec3d m_position
Position of end effector.
EventObject is the base class for all objects in iMSTK that can receive and emit events. It supports direct and queued observer functions. Direct observers receive events immediately on the same thread This can either be posted on an object or be a function pointer Queued observers receive events within their queue which they can process whenever they like. These can be connected with the connect/queuedConnect/disconnect functions Lambda recievers cannot be disconnected unless all receivers to a signal are removed.
Vec3d m_force
Force vector.
std::string m_deviceName
Device Name.