3 #include <std_msgs/Float32.h>
4 #include <std_msgs/String.h>
5 #include <std_msgs/Bool.h>
7 #include <phidget_ik/phidget_ik.h>
15 void shutdown(
const std_msgs::Bool::ConstPtr&);
32 int main(
int argc,
char **argv){
36 ros::Publisher publisher = n.advertise<std_msgs::Float32>(
"phidget_value", 1000);
37 ros::Subscriber sd = n.subscribe(
"shutdown", 1,
shutdown);
38 ros::Rate loop_rate(
freq);
42 phidget_ik.waitForAttachment(1000);
44 if (phidget_ik.getLastError()){
45 std::cerr <<
"Error initializing PhidgetInterfaceKit: " << phidget_ik.getErrorDescription(phidget_ik.getLastError()) << std::endl;
55 int data = phidget_ik.getSensorValue(
sensor_id);
56 std_msgs::Float32 sensor_val;
61 printf(
"Ignoring sensor value of %i\n", data);
69 sensor_val.data = distance;
70 printf(
"Reading sensor %i, value: %i, distance:%f\n",
sensor_id, data, distance);
73 publisher.publish(sensor_val);
93 buffer[buffer_size - 1] = data;
108 return(ceil(size/buffer_size));
134 return 2076.0f / (sensorValue - 11.0f);
143 void shutdown(
const std_msgs::Bool::ConstPtr& b){