00001 #include "darwin_robot_driver_node.h"
00002 #include <math.h>
00003
00004 DarwinRobotDriverNode::DarwinRobotDriverNode(ros::NodeHandle &nh) :
00005 iri_base_driver::IriBaseNodeDriver<DarwinRobotDriver>(nh),
00006 tracking_head_aserver_(public_node_handle_, "tracking_head"),
00007 move_right_arm_joints_aserver_(public_node_handle_, "move_right_arm_joints"),
00008 move_left_arm_joints_aserver_(public_node_handle_, "move_left_arm_joints"),
00009 move_joints_aserver_(public_node_handle_, "move_joints")
00010 {
00011
00012 this->loop_rate_ = 10;
00013
00014
00015 this->adc_channels_publisher_ = this->public_node_handle_.advertise<std_msgs::Float64MultiArray>("adc_channels", 100);
00016 this->inertial_publisher_ = this->public_node_handle_.advertise<sensor_msgs::Imu>("inertial", 100);
00017 this->joint_states_publisher_ = this->public_node_handle_.advertise<sensor_msgs::JointState>("joint_states", 100);
00018
00019
00020 this->head_target_subscriber_ = this->public_node_handle_.subscribe("head_target", 100, &DarwinRobotDriverNode::head_target_callback, this);
00021 this->execute_action_subscriber_ = this->public_node_handle_.subscribe("execute_action", 100, &DarwinRobotDriverNode::execute_action_callback, this);
00022 this->cmd_vel_subscriber_ = this->public_node_handle_.subscribe("cmd_vel", 100, &DarwinRobotDriverNode::cmd_vel_callback, this);
00023
00024
00025
00026
00027
00028
00029 tracking_head_aserver_.registerStartCallback(boost::bind(&DarwinRobotDriverNode::tracking_headStartCallback, this, _1));
00030 tracking_head_aserver_.registerStopCallback(boost::bind(&DarwinRobotDriverNode::tracking_headStopCallback, this));
00031 tracking_head_aserver_.registerIsFinishedCallback(boost::bind(&DarwinRobotDriverNode::tracking_headIsFinishedCallback, this));
00032 tracking_head_aserver_.registerHasSucceedCallback(boost::bind(&DarwinRobotDriverNode::tracking_headHasSucceedCallback, this));
00033 tracking_head_aserver_.registerGetResultCallback(boost::bind(&DarwinRobotDriverNode::tracking_headGetResultCallback, this, _1));
00034 tracking_head_aserver_.registerGetFeedbackCallback(boost::bind(&DarwinRobotDriverNode::tracking_headGetFeedbackCallback, this, _1));
00035 tracking_head_aserver_.start();
00036 move_right_arm_joints_aserver_.registerStartCallback(boost::bind(&DarwinRobotDriverNode::move_right_arm_jointsStartCallback, this, _1));
00037 move_right_arm_joints_aserver_.registerStopCallback(boost::bind(&DarwinRobotDriverNode::move_right_arm_jointsStopCallback, this));
00038 move_right_arm_joints_aserver_.registerIsFinishedCallback(boost::bind(&DarwinRobotDriverNode::move_right_arm_jointsIsFinishedCallback, this));
00039 move_right_arm_joints_aserver_.registerHasSucceedCallback(boost::bind(&DarwinRobotDriverNode::move_right_arm_jointsHasSucceedCallback, this));
00040 move_right_arm_joints_aserver_.registerGetResultCallback(boost::bind(&DarwinRobotDriverNode::move_right_arm_jointsGetResultCallback, this, _1));
00041 move_right_arm_joints_aserver_.registerGetFeedbackCallback(boost::bind(&DarwinRobotDriverNode::move_right_arm_jointsGetFeedbackCallback, this, _1));
00042 move_right_arm_joints_aserver_.start();
00043 move_left_arm_joints_aserver_.registerStartCallback(boost::bind(&DarwinRobotDriverNode::move_left_arm_jointsStartCallback, this, _1));
00044 move_left_arm_joints_aserver_.registerStopCallback(boost::bind(&DarwinRobotDriverNode::move_left_arm_jointsStopCallback, this));
00045 move_left_arm_joints_aserver_.registerIsFinishedCallback(boost::bind(&DarwinRobotDriverNode::move_left_arm_jointsIsFinishedCallback, this));
00046 move_left_arm_joints_aserver_.registerHasSucceedCallback(boost::bind(&DarwinRobotDriverNode::move_left_arm_jointsHasSucceedCallback, this));
00047 move_left_arm_joints_aserver_.registerGetResultCallback(boost::bind(&DarwinRobotDriverNode::move_left_arm_jointsGetResultCallback, this, _1));
00048 move_left_arm_joints_aserver_.registerGetFeedbackCallback(boost::bind(&DarwinRobotDriverNode::move_left_arm_jointsGetFeedbackCallback, this, _1));
00049 move_left_arm_joints_aserver_.start();
00050 move_joints_aserver_.registerStartCallback(boost::bind(&DarwinRobotDriverNode::move_jointsStartCallback, this, _1));
00051 move_joints_aserver_.registerStopCallback(boost::bind(&DarwinRobotDriverNode::move_jointsStopCallback, this));
00052 move_joints_aserver_.registerIsFinishedCallback(boost::bind(&DarwinRobotDriverNode::move_jointsIsFinishedCallback, this));
00053 move_joints_aserver_.registerHasSucceedCallback(boost::bind(&DarwinRobotDriverNode::move_jointsHasSucceedCallback, this));
00054 move_joints_aserver_.registerGetResultCallback(boost::bind(&DarwinRobotDriverNode::move_jointsGetResultCallback, this, _1));
00055 move_joints_aserver_.registerGetFeedbackCallback(boost::bind(&DarwinRobotDriverNode::move_jointsGetFeedbackCallback, this, _1));
00056
00057 this->left_arm_target_id="";
00058 this->right_arm_target_id="";
00059 this->general_target_id="";
00060
00061
00062 }
00063
00064 void DarwinRobotDriverNode::mainNodeThread(void)
00065 {
00066 static bool first=true;
00067 int i=0;
00068 double gyr_x=0.0,gyr_y=0.0,gyr_z=0.0;
00069 double accel_x=0.0,accel_y=0.0,accel_z=0.0;
00070 double voltage[15];
00071
00072
00073 this->driver_.lock();
00074 if(first)
00075 {
00076 first=false;
00077 tracking_head_aserver_.start();
00078 move_joints_aserver_.start();
00079 move_right_arm_joints_aserver_.start();
00080 move_left_arm_joints_aserver_.start();
00081 }
00082
00083 if(this->driver_.getState()==DarwinRobotDriver::RUNNING)
00084 {
00085
00086 this->JointState_msg_.header.stamp = ros::Time::now();
00087 this->JointState_msg_.header.frame_id = "MP_BODY";
00088
00089 this->Imu_msg_.header.stamp = ros::Time::now();
00090 this->Imu_msg_.header.frame_id = "MP_BODY";
00091
00092
00093 this->JointState_msg_.name.resize(JointData::GetNumServos());
00094 this->JointState_msg_.velocity.resize(JointData::GetNumServos());
00095 this->JointState_msg_.effort.resize(JointData::GetNumServos());
00096
00097 this->JointState_msg_.position=this->driver_.get_current_angles();
00098 this->JointState_msg_.name[1]="j_shoulder_l";
00099 this->JointState_msg_.name[0]="j_shoulder_r";
00100 this->JointState_msg_.name[3]="j_high_arm_l";
00101 this->JointState_msg_.name[2]="j_high_arm_r";
00102 this->JointState_msg_.name[5]="j_low_arm_l";
00103 this->JointState_msg_.name[4]="j_low_arm_r";
00104 this->JointState_msg_.name[7]="j_pelvis_l";
00105 this->JointState_msg_.name[6]="j_pelvis_r";
00106 this->JointState_msg_.name[9]="j_thigh1_l";
00107 this->JointState_msg_.name[8]="j_thigh1_r";
00108 this->JointState_msg_.name[11]="j_thigh2_l";
00109 this->JointState_msg_.name[10]="j_thigh2_r";
00110 this->JointState_msg_.name[13]="j_tibia_l";
00111 this->JointState_msg_.name[12]="j_tibia_r";
00112 this->JointState_msg_.name[15]="j_ankle1_l";
00113 this->JointState_msg_.name[14]="j_ankle1_r";
00114 this->JointState_msg_.name[17]="j_ankle2_l";
00115 this->JointState_msg_.name[16]="j_ankle2_r";
00116 this->JointState_msg_.name[18]="j_pan";
00117 this->JointState_msg_.name[19]="j_tilt";
00118 this->JointState_msg_.name[20]="j_wrist_r";
00119 this->JointState_msg_.name[21]="j_gripper_r";
00120 this->JointState_msg_.name[22]="j_wrist_l";
00121 this->JointState_msg_.name[23]="j_gripper_l";
00122
00123
00124 this->driver_.get_gyroscope(&gyr_x,&gyr_y,&gyr_z);
00125 this->driver_.get_accelerometer(&accel_x,&accel_y,&accel_z);
00126 this->driver_.get_analog_channel(CHANNEL1,&voltage[0]);
00127 this->driver_.get_analog_channel(CHANNEL2,&voltage[1]);
00128 this->driver_.get_analog_channel(CHANNEL3,&voltage[2]);
00129 this->driver_.get_analog_channel(CHANNEL4,&voltage[3]);
00130 this->driver_.get_analog_channel(CHANNEL5,&voltage[4]);
00131 this->driver_.get_analog_channel(CHANNEL6,&voltage[5]);
00132 this->driver_.get_analog_channel(CHANNEL7,&voltage[6]);
00133 this->driver_.get_analog_channel(CHANNEL8,&voltage[7]);
00134 this->driver_.get_analog_channel(CHANNEL9,&voltage[8]);
00135 this->driver_.get_analog_channel(CHANNEL10,&voltage[9]);
00136 this->driver_.get_analog_channel(CHANNEL11,&voltage[10]);
00137 this->driver_.get_analog_channel(CHANNEL12,&voltage[11]);
00138 this->driver_.get_analog_channel(CHANNEL13,&voltage[12]);
00139 this->driver_.get_analog_channel(CHANNEL14,&voltage[13]);
00140 this->driver_.get_analog_channel(CHANNEL15,&voltage[14]);
00141 this->Imu_msg_.orientation_covariance[0] = -1;
00142 this->Imu_msg_.angular_velocity.x=gyr_x;
00143 this->Imu_msg_.angular_velocity.y=gyr_y;
00144 this->Imu_msg_.angular_velocity.z=gyr_z;
00145 this->Float64MultiArray_msg_.data.resize(15);
00146 for(i=0;i<15;i++)
00147 this->Float64MultiArray_msg_.data[i]=voltage[i];
00148
00149 this->Imu_msg_.angular_velocity_covariance[0]=1;
00150 this->Imu_msg_.angular_velocity_covariance[4]=1;
00151 this->Imu_msg_.angular_velocity_covariance[8]=1;
00152 this->Imu_msg_.linear_acceleration.x=accel_x;
00153 this->Imu_msg_.linear_acceleration.y=accel_y;
00154 this->Imu_msg_.linear_acceleration.z=accel_z;
00155
00156 this->Imu_msg_.linear_acceleration_covariance[0]=1;
00157 this->Imu_msg_.linear_acceleration_covariance[4]=1;
00158 this->Imu_msg_.linear_acceleration_covariance[8]=1;
00159
00160
00161
00162
00163
00164
00165
00166 this->adc_channels_publisher_.publish(this->Float64MultiArray_msg_);
00167 this->inertial_publisher_.publish(this->Imu_msg_);
00168 this->joint_states_publisher_.publish(this->JointState_msg_);
00169 }
00170
00171 this->driver_.unlock();
00172 }
00173
00174
00175 void DarwinRobotDriverNode::head_target_callback(const std_msgs::Float64MultiArray::ConstPtr& msg)
00176 {
00177
00178 ROS_INFO("DarwinRobotDriverNode::head_target_callback: New Head Target");
00179
00180
00181 this->driver_.lock();
00182
00183 this->head_target_=(*msg);
00184 this->head_target_.data.resize(2);
00185 this->driver_.set_tracking_target(head_target_.data[0],head_target_.data[1]);
00186
00187
00188
00189 this->driver_.unlock();
00190
00191 }
00192 void DarwinRobotDriverNode::execute_action_callback(const std_msgs::Int32::ConstPtr& msg)
00193 {
00194
00195
00196
00197 this->driver_.lock();
00198
00199 this->driver_.start_action(msg->data);
00200
00201
00202
00203 this->driver_.unlock();
00204
00205 }
00206 void DarwinRobotDriverNode::cmd_vel_callback(const geometry_msgs::Twist::ConstPtr& msg)
00207 {
00208 double period=0.0,x_vel=0.0,r_vel=0.0,y_vel=0.0;
00209
00210
00211 this->driver_.lock();
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221 period=this->driver_.get_walking_param(PERIOD_TIME)/1000.0;
00222
00223 x_vel=(msg->linear.x*period*1000.0)/2.0;
00224 y_vel=(msg->linear.y*period*1000.0)/2.0;
00225
00226 r_vel=(msg->angular.z*period*180.0)/(2.0*3.14159);
00227 ROS_INFO("Platform: vt: (%f,%f), vr: %f",x_vel,y_vel,r_vel);
00228
00229 if(fabs(x_vel) <= 0.01 && fabs(y_vel) <= 0.01 && fabs(r_vel) <= 0.01)
00230 {
00231 ROS_INFO("Stop walking");
00232 this->driver_.stop_walking();
00233 }
00234 else
00235 {
00236 if(this->driver_.is_walking())
00237 this->driver_.tune_walking(x_vel,y_vel,r_vel);
00238 else
00239 this->driver_.start_walking(x_vel,y_vel,r_vel);
00240 }
00241
00242
00243 this->driver_.unlock();
00244
00245 }
00246
00247
00248
00249
00250 void DarwinRobotDriverNode::tracking_headStartCallback(const iri_darwin_robot::tracking_headGoalConstPtr& goal)
00251 {
00252 TPID pan_pid,tilt_pid;
00253
00254 driver_.lock();
00255 try{
00256
00257 pan_pid.kp=0.05;
00258 pan_pid.ki=0.001;
00259 pan_pid.kd=0.0001;
00260 tilt_pid.kp=0.03;
00261 tilt_pid.ki=0.001;
00262 tilt_pid.kd=0.0001;
00263 this->driver_.set_tracking_pid(10,&pan_pid,&tilt_pid);
00264
00265
00266
00267 this->driver_.start_head_tracking();
00268 }catch(CDarwinException &e){
00269 this->tracking_head_aserver_.setAborted();
00270 }
00271 driver_.unlock();
00272 }
00273
00274 void DarwinRobotDriverNode::tracking_headStopCallback(void)
00275 {
00276 driver_.lock();
00277
00278 this->driver_.stop_head_tracking();
00279 driver_.unlock();
00280 }
00281
00282 bool DarwinRobotDriverNode::tracking_headIsFinishedCallback(void)
00283 {
00284 bool ret = false;
00285
00286 driver_.lock();
00287
00288
00289 driver_.unlock();
00290
00291 return ret;
00292 }
00293
00294 bool DarwinRobotDriverNode::tracking_headHasSucceedCallback(void)
00295 {
00296 bool ret = false;
00297
00298 driver_.lock();
00299
00300 ret = true;
00301 driver_.unlock();
00302
00303 return ret;
00304 }
00305
00306 void DarwinRobotDriverNode::tracking_headGetResultCallback(iri_darwin_robot::tracking_headResultPtr& result)
00307 {
00308 driver_.lock();
00309
00310
00311 driver_.unlock();
00312 }
00313
00314 void DarwinRobotDriverNode::tracking_headGetFeedbackCallback(iri_darwin_robot::tracking_headFeedbackPtr& feedback)
00315 {
00316 driver_.lock();
00317
00318 this->driver_.get_head_position(&head_target_.data[0],&head_target_.data[1]);
00319 feedback->current_pan=head_target_.data[0];
00320 feedback->current_tilt=head_target_.data[1];
00321
00322
00323 driver_.unlock();
00324 }
00325 void DarwinRobotDriverNode::move_right_arm_jointsStartCallback(const control_msgs::FollowJointTrajectoryGoalConstPtr& goal)
00326 {
00327 std::vector<double> angles,speeds,accels;
00328 std::vector<int> servos;
00329 unsigned int i=0;
00330
00331 driver_.lock();
00332 try{
00333
00334 servos.resize(goal->trajectory.joint_names.size());
00335 angles.resize(goal->trajectory.joint_names.size());
00336 speeds.resize(goal->trajectory.joint_names.size());
00337 accels.resize(goal->trajectory.joint_names.size());
00338 for(i=0;i<goal->trajectory.joint_names.size();i++)
00339 {
00340 if(goal->trajectory.joint_names[i]=="j_shoulder_r")
00341 servos[i]=1;
00342 else if(goal->trajectory.joint_names[i]=="j_high_arm_r")
00343 servos[i]=3;
00344 else if(goal->trajectory.joint_names[i]=="j_low_arm_r")
00345 servos[i]=5;
00346 else if(goal->trajectory.joint_names[i]=="j_wrist_r")
00347 servos[i]=21;
00348 else
00349 throw CDarwinException(_HERE_,"Invalid servo identifier.");
00350 angles[i]=goal->trajectory.points[0].positions[i];
00351 speeds[i]=goal->trajectory.points[0].velocities[i];
00352 accels[i]=goal->trajectory.points[0].accelerations[i];
00353 }
00354 this->right_arm_target_id=this->driver_.move_joints(servos,angles,speeds,accels);
00355 }catch(CDarwinException &e){
00356 this->move_right_arm_joints_aserver_.setAborted();
00357 }
00358
00359 driver_.unlock();
00360 }
00361
00362 void DarwinRobotDriverNode::move_right_arm_jointsStopCallback(void)
00363 {
00364 driver_.lock();
00365
00366 this->driver_.stop_joints(this->right_arm_target_id);
00367 driver_.unlock();
00368 }
00369
00370 bool DarwinRobotDriverNode::move_right_arm_jointsIsFinishedCallback(void)
00371 {
00372 bool ret = false;
00373
00374 driver_.lock();
00375
00376 ret=!this->driver_.joints_are_moving(this->right_arm_target_id);
00377
00378 driver_.unlock();
00379
00380 return ret;
00381 }
00382
00383 bool DarwinRobotDriverNode::move_right_arm_jointsHasSucceedCallback(void)
00384 {
00385 bool ret = false;
00386
00387 driver_.lock();
00388
00389 ret = true;
00390 driver_.unlock();
00391
00392 return ret;
00393 }
00394
00395 void DarwinRobotDriverNode::move_right_arm_jointsGetResultCallback(control_msgs::FollowJointTrajectoryResultPtr& result)
00396 {
00397 driver_.lock();
00398
00399
00400 driver_.unlock();
00401 }
00402
00403 void DarwinRobotDriverNode::move_right_arm_jointsGetFeedbackCallback(control_msgs::FollowJointTrajectoryFeedbackPtr& feedback)
00404 {
00405 driver_.lock();
00406
00407
00408 driver_.unlock();
00409 }
00410 void DarwinRobotDriverNode::move_left_arm_jointsStartCallback(const control_msgs::FollowJointTrajectoryGoalConstPtr& goal)
00411 {
00412 std::vector<double> angles,speeds,accels;
00413 std::vector<int> servos;
00414 unsigned int i=0;
00415
00416 driver_.lock();
00417 try{
00418
00419 servos.resize(goal->trajectory.joint_names.size());
00420 angles.resize(goal->trajectory.joint_names.size());
00421 speeds.resize(goal->trajectory.joint_names.size());
00422 accels.resize(goal->trajectory.joint_names.size());
00423 for(i=0;i<goal->trajectory.joint_names.size();i++)
00424 {
00425 if(goal->trajectory.joint_names[i]=="j_shoulder_l")
00426 servos[i]=2;
00427 else if(goal->trajectory.joint_names[i]=="j_high_arm_l")
00428 servos[i]=4;
00429 else if(goal->trajectory.joint_names[i]=="j_low_arm_l")
00430 servos[i]=6;
00431 else if(goal->trajectory.joint_names[i]=="j_wrist_l")
00432 servos[i]=23;
00433 else
00434 throw CDarwinException(_HERE_,"Invalid servo identifier");
00435 angles[i]=goal->trajectory.points[0].positions[i];
00436 speeds[i]=goal->trajectory.points[0].velocities[i];
00437 accels[i]=goal->trajectory.points[0].accelerations[i];
00438 }
00439 this->left_arm_target_id=this->driver_.move_joints(servos,angles,speeds,accels);
00440 }catch(CDarwinException &e){
00441 this->move_left_arm_joints_aserver_.setAborted();
00442 }
00443
00444 driver_.unlock();
00445 }
00446
00447 void DarwinRobotDriverNode::move_left_arm_jointsStopCallback(void)
00448 {
00449 driver_.lock();
00450
00451 this->driver_.stop_joints(this->left_arm_target_id);
00452 driver_.unlock();
00453 }
00454
00455 bool DarwinRobotDriverNode::move_left_arm_jointsIsFinishedCallback(void)
00456 {
00457 bool ret = false;
00458
00459 driver_.lock();
00460
00461 ret=!this->driver_.joints_are_moving(this->left_arm_target_id);
00462
00463 driver_.unlock();
00464
00465 return ret;
00466 }
00467
00468 bool DarwinRobotDriverNode::move_left_arm_jointsHasSucceedCallback(void)
00469 {
00470 bool ret = false;
00471
00472 driver_.lock();
00473
00474 ret = true;
00475 driver_.unlock();
00476
00477 return ret;
00478 }
00479
00480 void DarwinRobotDriverNode::move_left_arm_jointsGetResultCallback(control_msgs::FollowJointTrajectoryResultPtr& result)
00481 {
00482 driver_.lock();
00483
00484
00485 driver_.unlock();
00486 }
00487
00488 void DarwinRobotDriverNode::move_left_arm_jointsGetFeedbackCallback(control_msgs::FollowJointTrajectoryFeedbackPtr& feedback)
00489 {
00490 driver_.lock();
00491
00492
00493 driver_.unlock();
00494 }
00495 void DarwinRobotDriverNode::move_jointsStartCallback(const control_msgs::FollowJointTrajectoryGoalConstPtr& goal)
00496 {
00497 std::vector<double> angles,speeds,accels;
00498 std::vector<int> servos;
00499 unsigned int i=0;
00500
00501 driver_.lock();
00502 try{
00503
00504 servos.resize(goal->trajectory.joint_names.size());
00505 angles.resize(goal->trajectory.joint_names.size());
00506 speeds.resize(goal->trajectory.joint_names.size());
00507 accels.resize(goal->trajectory.joint_names.size());
00508 for(i=0;i<goal->trajectory.joint_names.size();i++)
00509 {
00510 std::cout << goal->trajectory.joint_names[i] << " -> ";
00511 if(goal->trajectory.joint_names[i]=="j_shoulder_l")
00512 servos[i]=2;
00513 else if(goal->trajectory.joint_names[i]=="j_shoulder_r")
00514 servos[i]=1;
00515 else if(goal->trajectory.joint_names[i]=="j_high_arm_l")
00516 servos[i]=4;
00517 else if(goal->trajectory.joint_names[i]=="j_high_arm_r")
00518 servos[i]=3;
00519 else if(goal->trajectory.joint_names[i]=="j_low_arm_l")
00520 servos[i]=6;
00521 else if(goal->trajectory.joint_names[i]=="j_low_arm_r")
00522 servos[i]=5;
00523 else if(goal->trajectory.joint_names[i]=="j_pelvis_l")
00524 servos[i]=8;
00525 else if(goal->trajectory.joint_names[i]=="j_pelvis_r")
00526 servos[i]=7;
00527 else if(goal->trajectory.joint_names[i]=="j_thigh1_l")
00528 servos[i]=10;
00529 else if(goal->trajectory.joint_names[i]=="j_thigh1_r")
00530 servos[i]=9;
00531 else if(goal->trajectory.joint_names[i]=="j_thigh2_l")
00532 servos[i]=12;
00533 else if(goal->trajectory.joint_names[i]=="j_thigh2_r")
00534 servos[i]=11;
00535 else if(goal->trajectory.joint_names[i]=="j_tibia_l")
00536 servos[i]=14;
00537 else if(goal->trajectory.joint_names[i]=="j_tibia_r")
00538 servos[i]=13;
00539 else if(goal->trajectory.joint_names[i]=="j_ankle1_l")
00540 servos[i]=16;
00541 else if(goal->trajectory.joint_names[i]=="j_ankle1_r")
00542 servos[i]=15;
00543 else if(goal->trajectory.joint_names[i]=="j_ankle2_l")
00544 servos[i]=18;
00545 else if(goal->trajectory.joint_names[i]=="j_ankle2_r")
00546 servos[i]=17;
00547 else if(goal->trajectory.joint_names[i]=="j_pan")
00548 servos[i]=19;
00549 else if(goal->trajectory.joint_names[i]=="j_tilt")
00550 servos[i]=20;
00551 else if(goal->trajectory.joint_names[i]=="j_wrist_r")
00552 servos[i]=21;
00553 else if(goal->trajectory.joint_names[i]=="j_gripper_r")
00554 servos[i]=22;
00555 else if(goal->trajectory.joint_names[i]=="j_wrist_l")
00556 servos[i]=23;
00557 else if(goal->trajectory.joint_names[i]=="j_gripper_l")
00558 servos[i]=24;
00559 else
00560 throw CDarwinException(_HERE_,"Invalid servo identifier.");
00561 angles[i]=goal->trajectory.points[0].positions[i];
00562 speeds[i]=goal->trajectory.points[0].velocities[i];
00563 accels[i]=goal->trajectory.points[0].accelerations[i];
00564 }
00565 this->general_target_id=this->driver_.move_joints(servos,angles,speeds,accels);
00566 }catch(CDarwinException &e){
00567 this->move_left_arm_joints_aserver_.setAborted();
00568 }
00569
00570 driver_.unlock();
00571 }
00572
00573 void DarwinRobotDriverNode::move_jointsStopCallback(void)
00574 {
00575 driver_.lock();
00576
00577 this->driver_.stop_joints(this->general_target_id);
00578 driver_.unlock();
00579 }
00580
00581 bool DarwinRobotDriverNode::move_jointsIsFinishedCallback(void)
00582 {
00583 bool ret = false;
00584
00585 driver_.lock();
00586
00587 ret=!this->driver_.joints_are_moving(this->general_target_id);
00588
00589 driver_.unlock();
00590
00591 return ret;
00592 }
00593
00594 bool DarwinRobotDriverNode::move_jointsHasSucceedCallback(void)
00595 {
00596 bool ret = false;
00597
00598 driver_.lock();
00599
00600 ret = true;
00601 driver_.unlock();
00602
00603 return ret;
00604 }
00605
00606 void DarwinRobotDriverNode::move_jointsGetResultCallback(control_msgs::FollowJointTrajectoryResultPtr& result)
00607 {
00608 driver_.lock();
00609
00610
00611 driver_.unlock();
00612 }
00613
00614 void DarwinRobotDriverNode::move_jointsGetFeedbackCallback(control_msgs::FollowJointTrajectoryFeedbackPtr& feedback)
00615 {
00616 driver_.lock();
00617
00618 driver_.unlock();
00619 }
00620
00621
00622
00623 void DarwinRobotDriverNode::postNodeOpenHook(void)
00624 {
00625 }
00626
00627 void DarwinRobotDriverNode::addNodeDiagnostics(void)
00628 {
00629 }
00630
00631 void DarwinRobotDriverNode::addNodeOpenedTests(void)
00632 {
00633 }
00634
00635 void DarwinRobotDriverNode::addNodeStoppedTests(void)
00636 {
00637 }
00638
00639 void DarwinRobotDriverNode::addNodeRunningTests(void)
00640 {
00641 }
00642
00643 void DarwinRobotDriverNode::reconfigureNodeHook(int level)
00644 {
00645 }
00646
00647 DarwinRobotDriverNode::~DarwinRobotDriverNode(void)
00648 {
00649
00650 }
00651
00652
00653 int main(int argc,char *argv[])
00654 {
00655 return driver_base::main<DarwinRobotDriverNode>(argc, argv, "darwin_robot_driver_node");
00656 }