[Documentation] [TitleIndex] [WordIndex

  Show EOL distros: 

phidgets_drivers: phidgets_api | phidgets_c_api | phidgets_imu | phidgets_ir

Package Summary

This is an object oriented C++ wrapper for the Phidgets C API

phidgets_drivers: phidgets_api | phidgets_imu | phidgets_ir

Package Summary

A C++ Wrapper for the Phidgets C API

  • Maintainer: Murilo F. M. <muhrix AT gmail DOT com>, Ivan Dryanovski <ccnyroboticslab AT gmail DOT com>
  • Author: Tully Foote, Ivan Dryanovski, Copyright (C) 2010 Phidgets Inc. <patrick AT phidgets DOT com>
  • License: BSD, LGPLv3
  • Source: git https://github.com/ccny-ros-pkg/phidgets_drivers.git (branch: groovy)
phidgets_drivers: phidgets_api | phidgets_imu | phidgets_ir

Package Summary

A C++ Wrapper for the Phidgets C API

phidgets_drivers: phidgets_api | phidgets_imu | phidgets_ir

Package Summary

A C++ Wrapper for the Phidgets C API

phidgets_drivers: libphidget21 | phidgets_api | phidgets_imu

Package Summary

A C++ Wrapper for the Phidgets C API

phidgets_drivers: libphidget21 | phidgets_api | phidgets_high_speed_encoder | phidgets_ik | phidgets_imu | phidgets_msgs

Package Summary

A C++ Wrapper for the Phidgets C API

phidgets_drivers: libphidget21 | phidgets_api | phidgets_high_speed_encoder | phidgets_imu

Package Summary

A C++ Wrapper for the Phidgets C API

phidgets_drivers: libphidget21 | phidgets_api | phidgets_high_speed_encoder | phidgets_ik | phidgets_imu | phidgets_msgs

Package Summary

A C++ Wrapper for the Phidgets C API

phidgets_drivers: libphidget22 | phidgets_accelerometer | phidgets_analog_inputs | phidgets_api | phidgets_digital_inputs | phidgets_digital_outputs | phidgets_gyroscope | phidgets_high_speed_encoder | phidgets_ik | phidgets_magnetometer | phidgets_motors | phidgets_msgs | phidgets_spatial | phidgets_temperature

Package Summary

A C++ Wrapper for the Phidgets C API

Overview

The phidgets_api package contains a C++ API built on top of the phidgets_c_api package.

The package provides a base Phidget class, from which all other Phidgets inherit. Currently, we have implemented classes for the following devices:

* IMU sensor (PhidgetsSpatial 3/3/3)

* IR sensor (PhidgetIR)

Creating a class is fairly easy - feel free to request devices to be added to the stack. If you write a class for any device using the following example as reference and submit a patch, we'll add it to the package.

Example

In this example, we go through creating an IMU phidget using the C++ API.

We first define the Imu class, which is inherited from the base Phidget class:

   1 class Imu: public Phidget
   2 {
   3   public:
   4 
   5     Imu();
   6 
   7   protected:
   8  
   9     CPhidgetSpatialHandle imu_handle_;
  10     
  11     void zero();
  12     void setDataRate(int rate);
  13 
  14     virtual void dataHandler(CPhidgetSpatial_SpatialEventDataHandle *data, int count);
  15 
  16   private:
  17 
  18     static int SpatialDataHandler(CPhidgetSpatialHandle spatial, void *userptr, CPhidgetSpatial_SpatialEventDataHandle *data, int count);
  19 };

The Imu class has a CPhidgetSpatialHandle, which is a special handle for the Phidget Spatial device. Different devices will have different handle types.

The constructor needs to perform 4 operations:

   1 Imu::Imu(): Phidget(), imu_handle_(0)
   2 {
   3   // create the handle
   4   CPhidgetSpatial_create(&imu_handle_);
   5 
   6   // pass handle to base class
   7   Phidget::init((CPhidgetHandle)imu_handle_);
   8 
   9   // register base class callbacks
  10   Phidget::registerHandlers();
  11   
  12   // register imu data callback
  13   CPhidgetSpatial_set_OnSpatialData_Handler(
  14     imu_handle_, SpatialDataHandler, this);
  15 }

The zero() and setDataRate functions implement sepcific calls to the IMU device using the C API. The data handler function receives spatial data events.

   1 void Imu::setDataRate(int rate)
   2 {
   3   CPhidgetSpatial_setDataRate(imu_handle_, rate);
   4 }
   5 
   6 void Imu::zero()
   7 {
   8   // zero (calibrate) gyro
   9   CPhidgetSpatial_zeroGyro(imu_handle_);
  10 }

The SpatialDataHandler is a static callback function which forwards the data to the correct Imu class instance.

   1 int Imu::SpatialDataHandler(CPhidgetSpatialHandle handle, void *userptr, CPhidgetSpatial_SpatialEventDataHandle *data, int count)
   2 {
   3   // get the class instance from the userptr, and invoke the data handler
   4   ((Imu*)userptr)->dataHandler(data, count);
   5   return 0;
   6 }

Finally, the virtual dataHandler function is the one which is called back when Spatial data arrives. In this example, the function just prints out a message. However, you can create a class which inherits from the Imu class and overwrites this behavior.

   1 void Imu::dataHandler(CPhidgetSpatial_SpatialEventDataHandle *data, int count)
   2 {
   3   printf("Empty data handler\n");
   4 }

Bug Reports & Feature Requests

We appreciate the time and effort spent submitting bug reports and feature requests.

Please submit your tickets through github (requires github account) or by emailing the maintainers.


2022-05-28 12:50