本文整理汇总了C++中DJI_lock::leave方法的典型用法代码示例。如果您正苦于以下问题:C++ DJI_lock::leave方法的具体用法?C++ DJI_lock::leave怎么用?C++ DJI_lock::leave使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DJI_lock
的用法示例。
在下文中一共展示了DJI_lock::leave方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: my_callback
int my_callback(int data_type, int data_len, char *content)
{
printf("enter callback..\n");
g_lock.enter();
if (e_image == data_type && NULL != content)
{
printf("callback: type is image..\n");
image_data data;
memcpy((char*)&data, content, sizeof(data));
memcpy(g_imleft.data, data.m_greyscale_image_left[selected_vbus], IMAGE_SIZE);
memcpy(g_imright.data, data.m_greyscale_image_right[selected_vbus], IMAGE_SIZE);
memcpy(g_depth.data, data.m_depth_image[selected_vbus], IMAGE_SIZE * 2);
}
g_lock.leave();
g_event.set_event();
return 0;
}
示例2: my_callback
//.........这里部分代码省略.........
g_depth.copyTo(depth_16.image);
depth_16.header.frame_id = "guidance";
depth_16.header.stamp = ros::Time::now();
depth_16.encoding = sensor_msgs::image_encodings::MONO16;
depth_image_pub.publish(depth_16.toImageMsg());
}
key = waitKey(1);
}
/* imu */
/*
if ( e_imu == data_type && NULL != content )
{
imu *imu_data = (imu*)content;
printf( "frame index: %d, stamp: %d\n", imu_data->frame_index, imu_data->time_stamp );
printf( "imu: [%f %f %f %f %f %f %f]\n", imu_data->acc_x, imu_data->acc_y, imu_data->acc_z, imu_data->q[0], imu_data->q[1], imu_data->q[2], imu_data->q[3] );
// publish imu data
geometry_msgs::TransformStamped g_imu;
g_imu.header.frame_id = "guidance";
g_imu.header.stamp = ros::Time::now();
g_imu.transform.translation.x = imu_data->acc_x;
g_imu.transform.translation.y = imu_data->acc_y;
g_imu.transform.translation.z = imu_data->acc_z;
g_imu.transform.rotation.w = imu_data->q[0];
g_imu.transform.rotation.x = imu_data->q[1];
g_imu.transform.rotation.y = imu_data->q[2];
g_imu.transform.rotation.z = imu_data->q[3];
imu_pub.publish(g_imu);
}
*/
/* velocity */
/*
if ( e_velocity == data_type && NULL != content )
{
velocity *vo = (velocity*)content;
printf( "frame index: %d, stamp: %d\n", vo->frame_index, vo->time_stamp );
printf( "vx:%f vy:%f vz:%f\n", 0.001f * vo->vx, 0.001f * vo->vy, 0.001f * vo->vz );
// publish velocity
geometry_msgs::Vector3Stamped g_vo;
g_vo.header.frame_id = "guidance";
g_vo.header.stamp = ros::Time::now();
g_vo.vector.x = 0.001f * vo->vx;
g_vo.vector.y = 0.001f * vo->vy;
g_vo.vector.z = 0.001f * vo->vz;
velocity_pub.publish(g_vo);
}
*/
/* obstacle distance */
if ( e_obstacle_distance == data_type && NULL != content )
{
obstacle_distance *oa = (obstacle_distance*)content;
printf( "frame index: %d, stamp: %d\n", oa->frame_index, oa->time_stamp );
printf( "obstacle distance:" );
for ( int i = 0; i < CAMERA_PAIR_NUM; ++i )
{
printf( " %f ", 0.01f * oa->distance[i] );
}
printf( "\n" );
// publish obstacle distance
sensor_msgs::LaserScan g_oa;
g_oa.ranges.resize(CAMERA_PAIR_NUM);
g_oa.header.frame_id = "guidance";
g_oa.header.stamp = ros::Time::now();
for ( int i = 0; i < CAMERA_PAIR_NUM; ++i )
g_oa.ranges[i] = 0.01f * oa->distance[i];
obstacle_distance_pub.publish(g_oa);
}
/* ultrasonic */
/*
if ( e_ultrasonic == data_type && NULL != content )
{
ultrasonic_data *ultrasonic = (ultrasonic_data*)content;
printf( "frame index: %d, stamp: %d\n", ultrasonic->frame_index, ultrasonic->time_stamp );
for ( int d = 0; d < CAMERA_PAIR_NUM; ++d )
{
printf( "ultrasonic distance: %f, reliability: %d\n", ultrasonic->ultrasonic[d] * 0.001f, (int)ultrasonic->reliability[d] );
}
// publish ultrasonic data
sensor_msgs::LaserScan g_ul;
g_ul.ranges.resize(CAMERA_PAIR_NUM);
g_ul.intensities.resize(CAMERA_PAIR_NUM);
g_ul.header.frame_id = "guidance";
g_ul.header.stamp = ros::Time::now();
for ( int d = 0; d < CAMERA_PAIR_NUM; ++d ){
g_ul.ranges[d] = 0.001f * ultrasonic->ultrasonic[d];
g_ul.intensities[d] = 1.0 * ultrasonic->reliability[d];
}
ultrasonic_pub.publish(g_ul);
}
*/
g_lock.leave();
g_event.set_event();
return 0;
}
示例3: guidance_callback
//.........这里部分代码省略.........
for(size_t i=0;i<nextrightpts.size();i++)
{
if(nextrightpts[i].x>=0 && nextrightpts[i].x<=WIDTH && nextrightpts[i].y>=0 && nextrightpts[i].y<=HEIGHT)
{
CvScalar line_color; line_color = CV_RGB(255,0,0);
//int line_thickness = 1;
CvPoint p,q;
p.x = (int) prevrightpts[i].x;
p.y = (int) prevrightpts[i].y;
q.x = (int) nextrightpts[i].x;
q.y = (int) nextrightpts[i].y;
// double angle; angle = atan2( (double) p.y - q.y, (double) p.x - q.x );
// double hypotenuse; hypotenuse = sqrt( pow((p.y - q.y),2) + pow((p.x - q.x),2) );
//
//// //scale the line by a factor of 3
// q.x = (int) (p.x - 2 * hypotenuse * cos(angle));
// q.y = (int) (p.y - 2 * hypotenuse * sin(angle));
//
// cvLine( &prevrightimg, p, q, line_color, line_thickness, CV_AA, 0 );
//
// p.x = (int) (q.x + 9 * cos(angle + pi / 4));
// p.y = (int) (q.y + 9 * sin(angle + pi / 4));
// cvLine( &prevrightimg, p, q, line_color, line_thickness, CV_AA, 0 );
// p.x = (int) (q.x + 9 * cos(angle - pi / 4));
// p.y = (int) (q.y + 9 * sin(angle - pi / 4));
// cvLine( &prevrightimg, p, q, line_color, line_thickness, CV_AA, 0 );
//
arrowedLine(right_mask, p, q, line_color);
circle(right_mask, nextrightpts[i], 2, Scalar(0,255,0),-1);
kpts.push_back(nextrightpts[i]);
}
}
imshow("right", right_mask);
moveWindow("right", 500, 0);
}
if(frame_num>0)
{
if(nextrightpts.size()<=MIN_FEATURES)
{
goodFeaturesToTrack(g_greyscale_image_right, prevrightpts, MAX_FEATURES, QUALITY_EIGVALUE, MIN_DISTANCE);
}
else
{
prevrightpts.assign(kpts.begin(), kpts.end());
}
}
g_greyscale_image_right.copyTo(prevrightimg);
frame_num++;
}
//Stero matching
// Mat g_l,g_r;
//
// cvtColor(g_greyscale_image_left, g_l, CV_BGR2GRAY);
// cvtColor(g_greyscale_image_right,g_r, CV_BGR2GRAY);
Mat imgDisparity16S = Mat( g_greyscale_image_left.rows, g_greyscale_image_left.cols, CV_16S );
Mat imgDisparity8U = Mat( g_greyscale_image_left.rows, g_greyscale_image_left.cols, CV_8UC1 );
int ndisparities = 16*4;
int SADWindowSize = 7;
Ptr<StereoBM> sbm = StereoBM::create( ndisparities, SADWindowSize );
sbm->compute( g_greyscale_image_left, g_greyscale_image_right, imgDisparity16S );
double minVal; double maxVal;
minMaxLoc( imgDisparity16S, &minVal, &maxVal );
printf("Min disp: %f Max value: %f \n", minVal, maxVal);
imgDisparity16S.convertTo( imgDisparity8U, CV_8UC1, 255/(maxVal - minVal));
namedWindow( "windowDisparity", WINDOW_AUTOSIZE );
imshow( "windowDisparity", imgDisparity8U );
moveWindow("windowDisparity", 500, 500);
}
waitKey(1);
}
g_lock.leave();
g_event.set_DJI_event();
return 0;
}
示例4: my_callback
int my_callback(int data_type, int data_len, char *content)
{
g_lock.enter();
/* image data */
if (e_image == data_type && NULL != content)
{
image_data* data = (image_data*)content;
dji_guidance::multi_image msg;
// forward facing guidance sensor is disabled for now...
//msg.images.push_back(create_image_message(data, e_vbus1));
msg.images.push_back(create_image_message(data, e_vbus2));
msg.images.push_back(create_image_message(data, e_vbus3));
msg.images.push_back(create_image_message(data, e_vbus4));
//msg.images.push_back(create_image_message(data, e_vbus5));
image_pub.publish(msg);
std::cout << "published " << msg.images.size() << " images" << std::endl;
}
/* imu */
if ( e_imu == data_type && NULL != content )
{
imu *imu_data = (imu*)content;
// printf( "frame index: %d, stamp: %d\n", imu_data->frame_index, imu_data->time_stamp );
// printf( "imu: [%f %f %f %f %f %f %f]\n", imu_data->acc_x, imu_data->acc_y, imu_data->acc_z, imu_data->q[0], imu_data->q[1], imu_data->q[2], imu_data->q[3] );
// publish imu data
geometry_msgs::TransformStamped g_imu;
g_imu.header.frame_id = "guidance";
g_imu.header.stamp = ros::Time::now();
g_imu.transform.translation.x = imu_data->acc_x;
g_imu.transform.translation.y = imu_data->acc_y;
g_imu.transform.translation.z = imu_data->acc_z;
g_imu.transform.rotation.w = imu_data->q[0];
g_imu.transform.rotation.x = imu_data->q[1];
g_imu.transform.rotation.y = imu_data->q[2];
g_imu.transform.rotation.z = imu_data->q[3];
imu_pub.publish(g_imu);
}
/* velocity */
if ( e_velocity == data_type && NULL != content )
{
velocity *vo = (velocity*)content;
// printf( "frame index: %d, stamp: %d\n", vo->frame_index, vo->time_stamp );
// printf( "vx:%f vy:%f vz:%f\n", 0.001f * vo->vx, 0.001f * vo->vy, 0.001f * vo->vz );
// publish velocity
geometry_msgs::Vector3Stamped g_vo;
g_vo.header.frame_id = "guidance";
g_vo.header.stamp = ros::Time::now();
g_vo.vector.x = 0.001f * vo->vx;
g_vo.vector.y = 0.001f * vo->vy;
g_vo.vector.z = 0.001f * vo->vz;
velocity_pub.publish(g_vo);
}
g_lock.leave();
g_event.set_event();
return 0;
}
示例5: my_callback
//.........这里部分代码省略.........
tf::Matrix3x3(orientation).getRPY(roll, pitch, yaw);
*/
imu_m.publish(imu_p);
}
/* velocity */
if ( e_velocity == data_type && NULL != content )
{
velocity *vo = (velocity*)content;
if(flag)
{
printf( "frame index: %d, stamp: %d\n", vo->frame_index, vo->time_stamp );
printf( "vx:%f vy:%f vz:%f\n", 0.001f * vo->vx, 0.001f * vo->vy, 0.001f * vo->vz );
}
// printf( "frame index: %d, stamp: %d\n", vo->frame_index, vo->time_stamp );
//printf( "vx:%f vy:%f vz:%f\n", 0.001f * vo->vx, 0.001f * vo->vy, 0.001f * vo->vz );
// publish velocity
geometry_msgs::Vector3Stamped g_vo;
g_vo.header.frame_id = "guidance";
g_vo.header.stamp = ros::Time::now();
g_vo.vector.x = 0.001f * vo->vx;
g_vo.vector.y = 0.001f * vo->vy;
g_vo.vector.z = 0.001f * vo->vz;
velocity_pub.publish(g_vo);
if(abs(vo->vx) > 0) flag=false;
}
/* obstacle distance
if ( e_obstacle_distance == data_type && NULL != content )
{
obstacle_distance *oa = (obstacle_distance*)content;
printf( "frame index: %d, stamp: %d\n", oa->frame_index, oa->time_stamp );
printf( "obstacle distance:" );
for ( int i = 0; i < CAMERA_PAIR_NUM; ++i )
{
printf( " %f ", 0.01f * oa->distance[i] );
}
printf( "\n" );
// publish obstacle distance
sensor_msgs::LaserScan g_oa;
g_oa.ranges.resize(5);
g_oa.header.frame_id = "guidance";
g_oa.header.stamp = ros::Time::now();
g_oa.ranges[0] = 0.01f * oa->distance[0];
g_oa.ranges[1] = 0.01f * oa->distance[1];
g_oa.ranges[2] = 0.01f * oa->distance[2];
g_oa.ranges[3] = 0.01f * oa->distance[3];
g_oa.ranges[4] = 0.01f * oa->distance[4];
obstacle_distance_pub.publish(g_oa);
}*/
/* ultrasonic
if ( e_ultrasonic == data_type && NULL != content )
{
ultrasonic_data *ultrasonic = (ultrasonic_data*)content;
printf( "frame index: %d, stamp: %d\n", ultrasonic->frame_index, ultrasonic->time_stamp );
for ( int d = 0; d < CAMERA_PAIR_NUM; ++d )
{
printf( "ultrasonic distance: %f, reliability: %d\n", ultrasonic->ultrasonic[d] * 0.001f, (int)ultrasonic->reliability[d] );
}
// publish ultrasonic data
sensor_msgs::LaserScan g_ul;
g_ul.ranges.resize(5);
g_ul.intensities.resize(5);
g_ul.header.frame_id = "guidance";
g_ul.header.stamp = ros::Time::now();
g_ul.ranges[0] = 0.001f * ultrasonic->ultrasonic[0];
g_ul.ranges[1] = 0.001f * ultrasonic->ultrasonic[1];
g_ul.ranges[2] = 0.001f * ultrasonic->ultrasonic[2];
g_ul.ranges[3] = 0.001f * ultrasonic->ultrasonic[3];
g_ul.ranges[4] = 0.001f * ultrasonic->ultrasonic[4];
g_ul.intensities[0] = 1.0 * ultrasonic->reliability[0];
g_ul.intensities[1] = 1.0 * ultrasonic->reliability[1];
g_ul.intensities[2] = 1.0 * ultrasonic->reliability[2];
g_ul.intensities[3] = 1.0 * ultrasonic->reliability[3];
g_ul.intensities[4] = 1.0 * ultrasonic->reliability[4];
ultrasonic_pub.publish(g_ul);
}*/
g_lock.leave();
g_event.set_event();
return 0;
}
示例6: my_callback
//.........这里部分代码省略.........
g_cam_info_right.header.frame_id = "guidance5";
try {
read_params_from_yaml_and_fill_cam_info_msg(camera5_params_right, g_cam_info_right);
cam5_info_right_pub.publish(g_cam_info_right);
} catch(...) {
// if yaml fails to read data, don't try to publish
}
}
key = waitKey(1);
}
/* imu */
if ( e_imu == data_type && NULL != content )
{
imu *imu_data = (imu*)content;
printf( "frame index: %d, stamp: %d\n", imu_data->frame_index, imu_data->time_stamp );
printf( "imu: [%f %f %f %f %f %f %f]\n", imu_data->acc_x, imu_data->acc_y, imu_data->acc_z, imu_data->q[0], imu_data->q[1], imu_data->q[2], imu_data->q[3] );
// publish imu data
geometry_msgs::TransformStamped g_imu;
g_imu.header.frame_id = "guidance";
g_imu.header.stamp = ros::Time::now();
g_imu.transform.translation.x = imu_data->acc_x;
g_imu.transform.translation.y = imu_data->acc_y;
g_imu.transform.translation.z = imu_data->acc_z;
g_imu.transform.rotation.w = imu_data->q[0];
g_imu.transform.rotation.x = imu_data->q[1];
g_imu.transform.rotation.y = imu_data->q[2];
g_imu.transform.rotation.z = imu_data->q[3];
imu_pub.publish(g_imu);
}
/* velocity */
if ( e_velocity == data_type && NULL != content )
{
velocity *vo = (velocity*)content;
printf( "frame index: %d, stamp: %d\n", vo->frame_index, vo->time_stamp );
printf( "vx:%f vy:%f vz:%f\n", 0.001f * vo->vx, 0.001f * vo->vy, 0.001f * vo->vz );
// publish velocity
geometry_msgs::Vector3Stamped g_vo;
g_vo.header.frame_id = "guidance";
g_vo.header.stamp = ros::Time::now();
g_vo.vector.x = 0.001f * vo->vx;
g_vo.vector.y = 0.001f * vo->vy;
g_vo.vector.z = 0.001f * vo->vz;
velocity_pub.publish(g_vo);
}
/* obstacle distance */
if ( e_obstacle_distance == data_type && NULL != content )
{
obstacle_distance *oa = (obstacle_distance*)content;
printf( "frame index: %d, stamp: %d\n", oa->frame_index, oa->time_stamp );
printf( "obstacle distance:" );
for ( int i = 0; i < CAMERA_PAIR_NUM; ++i )
{
printf( " %f ", 0.01f * oa->distance[i] );
}
printf( "\n" );
// publish obstacle distance
sensor_msgs::LaserScan g_oa;
g_oa.ranges.resize(CAMERA_PAIR_NUM);
g_oa.header.frame_id = "guidance";
g_oa.header.stamp = ros::Time::now();
for ( int i = 0; i < CAMERA_PAIR_NUM; ++i )
g_oa.ranges[i] = 0.01f * oa->distance[i];
obstacle_distance_pub.publish(g_oa);
}
/* ultrasonic */
if ( e_ultrasonic == data_type && NULL != content )
{
ultrasonic_data *ultrasonic = (ultrasonic_data*)content;
printf( "frame index: %d, stamp: %d\n", ultrasonic->frame_index, ultrasonic->time_stamp );
for ( int d = 0; d < CAMERA_PAIR_NUM; ++d )
{
printf( "ultrasonic distance: %f, reliability: %d\n", ultrasonic->ultrasonic[d] * 0.001f, (int)ultrasonic->reliability[d] );
}
// publish ultrasonic data
sensor_msgs::LaserScan g_ul;
g_ul.ranges.resize(CAMERA_PAIR_NUM);
g_ul.intensities.resize(CAMERA_PAIR_NUM);
g_ul.header.frame_id = "guidance";
g_ul.header.stamp = ros::Time::now();
for ( int d = 0; d < CAMERA_PAIR_NUM; ++d ) {
g_ul.ranges[d] = 0.001f * ultrasonic->ultrasonic[d];
g_ul.intensities[d] = 1.0 * ultrasonic->reliability[d];
}
ultrasonic_pub.publish(g_ul);
}
g_lock.leave();
g_event.set_event();
return 0;
}
示例7: my_callback
int my_callback(int data_type, int data_len, char *content)
{
g_lock.enter();
if (e_image == data_type && NULL != content)
{
image_data data;
memcpy( (char*)&data, content, sizeof(data) );
printf( "frame index:%d,stamp:%d\n", data.frame_index, data.time_stamp );
#if !USE_GUIDANCE_ASSISTANT_CONFIG
#ifdef HAVE_OPENCV
memcpy( g_greyscale_image_left.data, data.m_greyscale_image_left[sensor_id], IMAGE_SIZE );
memcpy( g_greyscale_image_right.data, data.m_greyscale_image_right[sensor_id], IMAGE_SIZE );
memcpy( g_depth.data, data.m_depth_image[sensor_id], IMAGE_SIZE * 2 );
imshow("left", g_greyscale_image_left);
imshow("right", g_greyscale_image_right);
#endif
#else
for ( int d = 0; d < CAMERA_PAIR_NUM; ++d )
{
string stmps;
if ( data.m_greyscale_image_left[d] )
{
#ifdef HAVE_OPENCV
memcpy( g_greyscale_image_left.data, data.m_greyscale_image_left[d], IMAGE_SIZE );//maybe select too many image so just overwrite it
stmps = "left";
stmps = stmps + (char)('0'+d);
imshow(stmps.c_str(), g_greyscale_image_left);
#endif
}
if ( data.m_greyscale_image_right[d] )
{
#ifdef HAVE_OPENCV
memcpy( g_greyscale_image_right.data, data.m_greyscale_image_right[d], IMAGE_SIZE );
stmps = "right";
stmps = stmps + (char)('0'+d);
imshow(stmps, g_greyscale_image_right);
#endif
}
if ( data.m_depth_image[d] )
{
#ifdef HAVE_OPENCV
Mat depthmap(HEIGHT, WIDTH, CV_16SC1);
Mat depthmap8(HEIGHT, WIDTH, CV_8UC1);
memcpy( depthmap.data, data.m_depth_image[d], IMAGE_SIZE * 2 );
depthmap.convertTo(depthmap8, CV_8UC1);
stmps = "depthmap";
stmps = stmps + (char)('0'+d);
imshow(stmps, depthmap8);
#endif
}
}
#endif
#ifdef HAVE_OPENCV
waitKey(1);
#endif
}
if ( e_imu == data_type && NULL != content )
{
imu *imu_data = (imu*)content;
printf( "imu:%f %f %f,%f %f %f %f\n", imu_data->acc_x, imu_data->acc_y, imu_data->acc_z, imu_data->q[0], imu_data->q[1], imu_data->q[2], imu_data->q[3] );
printf( "frame index:%d,stamp:%d\n", imu_data->frame_index, imu_data->time_stamp );
}
if ( e_velocity == data_type && NULL != content )
{
velocity *vo = (velocity*)content;
printf( "vx:%f vy:%f vz:%f\n", 0.001f * vo->vx, 0.001f * vo->vy, 0.001f * vo->vz );
printf( "frame index:%d,stamp:%d\n", vo->frame_index, vo->time_stamp );
}
if ( e_obstacle_distance == data_type && NULL != content )
{
obstacle_distance *oa = (obstacle_distance*)content;
printf( "obstacle distance:" );
for ( int i = 0; i < CAMERA_PAIR_NUM; ++i )
{
printf( " %f ", 0.01f * oa->distance[i] );
}
printf( "\n" );
printf( "frame index:%d,stamp:%d\n", oa->frame_index, oa->time_stamp );
}
if ( e_ultrasonic == data_type && NULL != content )
{
ultrasonic_data *ultrasonic = (ultrasonic_data*)content;
for ( int d = 0; d < CAMERA_PAIR_NUM; ++d )
{
printf( "ultrasonic distance:%f,reliability:%d\n", ultrasonic->ultrasonic[d] * 0.001f, (int)ultrasonic->reliability[d] );
}
printf( "frame index:%d,stamp:%d\n", ultrasonic->frame_index, ultrasonic->time_stamp );
}
g_lock.leave();
g_event.set_event();
return 0;
}