整理翻译ROS中结构体LDP、correspondence和laser_data的数据格式,翻译和理解水平有限,有问题可以指出留言,我们一起进步。
1、laser_data.h(可不看)
三个结构体都在该文件下,单个结构体解释请看本文小部分
#ifndef H_LASER_DATA
#define H_LASER_DATA
#include <sys/time.h>
#include <stdio.h>
#include "restrict.h"
struct correspondence;
typedef struct {
double p[2];
double rho, phi;
} point2d;
struct laser_data {
int nrays;
double min_theta;
double max_theta;
double * restrict theta;
int * restrict valid;
double * restrict readings;
int * restrict cluster;
double * restrict alpha;
double * restrict cov_alpha;
int * restrict alpha_valid;
double * restrict readings_sigma;
double * restrict true_alpha;
struct correspondence* restrict corr;
double true_pose[3];
double odometry[3];
double estimate[3];
/** Cartesian representation */
point2d * restrict points;
/** Cartesian representation, in "world" (laser_ref) coordinates.
Computed using ld_compute_world_coords() */
point2d * restrict points_w;
/** Timestamp */
struct timeval tv;
char hostname[32];
/* Jump tables needed by find_correspondences_tricks(). */
int * restrict up_bigger,
* restrict up_smaller,
* restrict down_bigger,
* restrict down_smaller;
};
struct correspondence {
/** 1 if this correspondence is valid */
int valid;
/** Closest point in the other scan. */
int j1;
/** Second closest point in the other scan. */
int j2;
/** Type of correspondence (point to point, or point to line) */
enum { corr_pp = 0, corr_pl = 1} type;
/** Squared distance from p(i) to point j1 */
double dist2_j1;
};
typedef struct laser_data* LDP;
/** This returns a new structure, with all fields initialized */
LDP ld_alloc_new(int nrays);
/** This DOES free() the pointer */
void ld_free(LDP);
/** This allocs the fields in the given structure. Use ld_alloc_new(), not this. */
void ld_alloc(LDP, int nrays);
/** This does NOT free the pointer. Don't use -- use ld_alloc_new()/ld_free() instead. */
void ld_dealloc(LDP);
/** Fills the x,y fields in "points" by transforming (theta, reading) to cartesian */
void ld_compute_cartesian(LDP);
/** Computes the "points_w" coordinates by roto-translating "points" */
void ld_compute_world_coords(LDP, const double *pose);
/** Fills the fields: *up_bigger, *up_smaller, *down_bigger, *down_smaller.*/
void ld_create_jump_tables(LDP);
/** Computes an hash of the correspondences */
unsigned int ld_corr_hash(LDP);
/** Returns the number of valid correspondences. */
int ld_num_valid_correspondences(LDP);
/** Do an extensive sanity check about the data contained in the structure. */
int ld_valid_fields(LDP);
/** A simple clustering algorithm. Sets the `cluster' field in the structure. */
void ld_simple_clustering(LDP ld, double threshold);
/** A cool orientation estimation algorithm. Needs cluster. */
void ld_compute_orientation(LDP ld, int size_neighbourhood, double sigma);
/**
Tries to read a laser scan from file. If error or EOF, it returns 0.
Whitespace is skipped. If first valid char is '{', it tries to read
it as JSON. If next char is 'F' (first character of "FLASER"),
it tries to read in Carmen format. Else, 0 is returned.
*/
LDP ld_read_smart(FILE*);
/**
Tries to read a laser scan from a string.
*/
LDP ld_read_smart_string(const char*);
/** Read next FLASER line in file (initializes ld).
Returns 0 on failure. If the file is EOF, it returns 1
and sets ld to 0.
You probably want to use the ld_read_smart() function. */
int ld_read_next_laser_carmen(FILE*, LDP*ld);
/** Read laser data from a Carmen-formatted line */
LDP ld_from_carmen_string(const char*line);
/** Reads all the scans it can find. */
int ld_read_all(FILE*file, LDP **array, int*num);
/** Read a scan every interval (1=all)*/
int ld_read_some_scans(FILE*file, LDP **array, int*num, int interval);
/** Write a scan in carmen format */
void ld_write_as_carmen(LDP ld, FILE * stream);
/** Write a scan according to out_format = {"carmen", "json"} */
void ld_write_format(LDP ld, FILE*stream, const char * out_format);
void possible_interval(
const double *p_i_w, LDP laser_sens,
double max_angular_correction_deg, double max_linear_correction, int*from, int*to, int*start_cell);
#include "laser_data_inline.h"
#endif
2、 laser_data
struct laser_data {
int nrays;
double min_theta;
double max_theta;
double * restrict theta;
int * restrict valid;
double * restrict readings;
int * restrict cluster;
double * restrict alpha;
double * restrict cov_alpha;
int * restrict alpha_valid;
double * restrict readings_sigma;
double * restrict true_alpha;
struct correspondence* restrict corr;
double true_pose[3];
double odometry[3];
double estimate[3];
/** Cartesian representation */
point2d * restrict points;
/** Cartesian representation, in "world" (laser_ref) coordinates.
Computed using ld_compute_world_coords() */
point2d * restrict points_w;
/** Timestamp */
struct timeval tv;
char hostname[32];
/* Jump tables needed by find_correspondences_tricks(). */
int * restrict up_bigger,
* restrict up_smaller,
* restrict down_bigger,
* restrict down_smaller;
};
3、correspondence
struct correspondence {
/** 1 if this correspondence is valid */
int valid;
/** Closest point in the other scan. */
int j1;
/** Second closest point in the other scan. */
int j2;
/** Type of correspondence (point to point, or point to line) */
enum { corr_pp = 0, corr_pl = 1} type;
/** Squared distance from p(i) to point j1 */
double dist2_j1;
};
4、LDP
typedef struct laser_data* LDP;
/** This returns a new structure, with all fields initialized */
//这将返回一个新的结构,并初始化所有字段
LDP ld_alloc_new(int nrays);
/** This DOES free() the pointer */
//这将执行free()指针
void ld_free(LDP);
/** This allocs the fields in the given structure. Use ld_alloc_new(), not this. */
void ld_alloc(LDP, int nrays);
/** This does NOT free the pointer. Don't use -- use ld_alloc_new()/ld_free() instead. */
void ld_dealloc(LDP);
/** Fills the x,y fields in "points" by transforming (theta, reading) to cartesian */
//通过将(theta, reading)变换为笛卡尔坐标来填充“点”中的x,y字段
void ld_compute_cartesian(LDP);
/** Computes the "points_w" coordinates by roto-translating "points" */
//通过roto- translation“points”计算“points_w”坐标
void ld_compute_world_coords(LDP, const double *pose);
/** Fills the fields: *up_bigger, *up_smaller, *down_bigger, *down_smaller.*/
//填充字段:*up_bigger, *up_smaller, *down_bigger, *down_smaller。
void ld_create_jump_tables(LDP);
/** Computes an hash of the correspondences */
//计算对应的哈希值
unsigned int ld_corr_hash(LDP);
/** Returns the number of valid correspondences. */
//返回有效的通信数。
int ld_num_valid_correspondences(LDP);
/** Do an extensive sanity check about the data contained in the structure. */
//对结构中包含的数据进行全面检查。
int ld_valid_fields(LDP);
/** A simple clustering algorithm. Sets the `cluster' field in the structure. */
//一个简单的聚类算法。在结构中设置‘cluster’字段。
void ld_simple_clustering(LDP ld, double threshold);
/** A cool orientation estimation algorithm. Needs cluster. */
//一种很酷的方向估计算法。需要集群。
void ld_compute_orientation(LDP ld, int size_neighbourhood, double sigma);
/**
Tries to read a laser scan from file. If error or EOF, it returns 0. Whitespace is skipped. If first valid char is '{', it tries to read it as JSON. If next char is 'F' (first character of "FLASER"), it tries to read in Carmen format. Else, 0 is returned.
*/
//尝试从文件中读取激光扫描。如果是error或EOF,则返回0。空格是跳过。
//如果第一个有效的字符是'{',它会尝试将其读取为JSON。如果下一个字符是'F' ("FLASER"的第一个字符),
//它将尝试以Carmen格式读取。否则,返回0。
LDP ld_read_smart(FILE*);
/**
Tries to read a laser scan from a string.
尝试从字符串读取激光扫描。
*/
LDP ld_read_smart_string(const char*);
/** Read next FLASER line in file (initializes ld).
Returns 0 on failure. If the file is EOF, it returns 1 and sets ld to 0.
You probably want to use the ld_read_smart() function.
读取文件中的下一个FLASER行(初始化ld)。
失败时返回0。如果文件是EOF,则返回1并将ld设置为0。
您可能需要使用ld_read_smart()函数。
*/
int ld_read_next_laser_carmen(FILE*, LDP*ld);
/** Read laser data from a Carmen-formatted line */
//从carmen格式的行读取激光数据
LDP ld_from_carmen_string(const char*line);
/** Reads all the scans it can find. */
//读取所有能找到的扫描结果。
int ld_read_all(FILE*file, LDP **array, int*num);
/** Read a scan every interval (1=all)*/
//每隔一段时间读取一次扫描(1=all)
int ld_read_some_scans(FILE*file, LDP **array, int*num, int interval);
/** Write a scan in carmen format */
//用carmen格式写扫描
void ld_write_as_carmen(LDP ld, FILE * stream);
/** Write a scan according to out_format = {"carmen", "json"} */
//根据out_format = {"carmen", "json"}写一个扫描
void ld_write_format(LDP ld, FILE*stream, const char * out_format);
void possible_interval(
const double *p_i_w, LDP laser_sens,
double max_angular_correction_deg, double max_linear_correction, int*from, int*to, int*start_cell);