60 hdBeginFrame(hdGetCurrentDevice());
65 hdGetIntegerv(HD_CURRENT_BUTTONS, &nButtons);
68 (nButtons & HD_DEVICE_BUTTON_1) ? HD_TRUE : HD_FALSE;
70 hdEndFrame(hdGetCurrentDevice());
79 if (HD_DEVICE_ERROR(error = hdGetError()))
81 hduPrintError(stderr, &error,
"Error during main scheduler callback\n");
82 if (hduIsSchedulerError(&error))
83 return HD_CALLBACK_DONE;
86 return HD_CALLBACK_CONTINUE;
98 double roll = A*sin(w*time);
99 double pitch = A*sin(w*time);
106 else if (
plane ==
"sag")
130 right_platform.pose.orientation = tf::createQuaternionMsgFromRollPitchYaw(roll*
PI/180, pitch*
PI/180, 0);
138 left_platform.pose.orientation = tf::createQuaternionMsgFromRollPitchYaw(roll*
PI/180, pitch*
PI/180, 0);
142 cout <<
"Platform's roll: " << roll <<
" pitch: " << pitch << endl;
143 cout <<
"--------------------------------------" << endl;
183 ros::init(argc, argv,
"platform_control");
186 if (!ros::param::get(
"plane",
plane))
187 ROS_ERROR(
"Failed to read symbols on parameter server");
188 else if (!ros::param::get(
"amplitude",
amplitude))
189 ROS_ERROR(
"Failed to read symbols on parameter server");
190 else if (!ros::param::get(
"frequency",
frequency))
191 ROS_ERROR(
"Failed to read symbols on parameter server");
201 HDenum *calibrationStyle = (HDenum *) pUserData;
203 if (hdCheckCalibration() == HD_CALIBRATION_NEEDS_UPDATE)
205 hdUpdateCalibration(*calibrationStyle);
208 return HD_CALLBACK_DONE;
214 HDint supportedCalibrationStyles;
215 HDenum calibrationStyle;
220 hdGetIntegerv(HD_CALIBRATION_STYLE, &supportedCalibrationStyles);
222 if (supportedCalibrationStyles & HD_CALIBRATION_ENCODER_RESET)
224 calibrationStyle = HD_CALIBRATION_ENCODER_RESET;
228 if (supportedCalibrationStyles & HD_CALIBRATION_INKWELL)
230 calibrationStyle = HD_CALIBRATION_INKWELL;
234 if (supportedCalibrationStyles & HD_CALIBRATION_AUTO)
236 calibrationStyle = HD_CALIBRATION_AUTO;
244 HDenum status = hdCheckCalibration();
246 if (status == HD_CALIBRATION_OK)
250 else if (status == HD_CALIBRATION_NEEDS_MANUAL_INPUT)
252 cout <<
"Calibration requires manual input." << endl;
255 else if (status == HD_CALIBRATION_NEEDS_UPDATE)
260 if (HD_DEVICE_ERROR(hdGetError()))
262 cout <<
"\nFailed to update calibration.\n" << endl;
267 cout <<
"\nCalibration updated successfully.\n" << endl;
273 assert(!
"Unknown calibration status");
279 int main(
int argc,
char **argv)
295 HHD hHD = hdInitDevice(HD_DEFAULT_DEVICE);
296 if (HD_DEVICE_ERROR(error = hdGetError()))
298 hduPrintError(stderr, &error,
"Failed to initialize the device");
299 fprintf(stderr,
"\nPress any key to quit.\n");
304 ROS_INFO(
"Found %s.\n\n", hdGetString(HD_DEVICE_MODEL_TYPE));
308 if (HD_DEVICE_ERROR(error = hdGetError()))
310 hduPrintError(stderr, &error,
"Failed to schedule servoloop callback");
312 hdDisableDevice(hHD);
314 fprintf(stderr,
"\nPress any key to quit.\n");
321 hdEnable(HD_FORCE_OUTPUT);
325 hdSetSchedulerRate(1000);
327 if (HD_DEVICE_ERROR(error = hdGetError()))
329 hduPrintError(stderr, &error,
"Failed to start the scheduler");
331 fprintf(stderr,
"\nPress any key to quit.\n");
343 hdDisableDevice(hHD);
geometry_msgs::Vector3 right_platform_init
HDSchedulerHandle gCallbackHandle
void setupMessaging(ros::NodeHandle nh)
int main(int argc, char **argv)
geometry_msgs::PoseStamped left_platform
HDboolean button_state[2]
HDdouble device_position[3]
geometry_msgs::Vector3 left_platform_init
static device_state state
ros::Subscriber simulation_state_sub
geometry_msgs::PoseStamped right_platform
geometry_msgs::Point pelvis_target
ros::Publisher command_left_platform_pub
void simulationCallback(const vrep_common::VrepInfo &msg)
HDCallbackCode HDCALLBACK SchedulerCallback(void *pUserData)
HDCallbackCode HDCALLBACK UpdateCalibrationCallback(void *pUserData)
void setPlatformPose(double &time)
HDboolean CheckCalibration()
ros::Publisher command_right_platform_pub
void mainLoop(int argc, char **argv)
geometry_msgs::PointStamped pelvis_target_stamped
geometry_msgs::Point pelvis_target_init