首页 > 其他分享 >时间同步概览

时间同步概览

时间:2023-01-05 15:23:00浏览次数:46  
标签:同步 timestamp image 概览 camera 时间 Time grab 曝光

Basler接口:

千兆网(GigE Vision) 或Camera Link接口
支持PoE的千兆网(GigE)、支持PoCL的Camera Link、USB 3.0
相机符合GigE Vision、USB3 Vision和Camera Link标准协议,具有极佳的稳定性和灵活性
USB3 Vision 接口标准
     设备标识 设备控制 流技术 技术细节
	   物理层 链路层 协议层 USB3 Vision 
	   带宽 供电能力 效率 稳定

getChunkTimestamp
  括事件产生时间戳 inPixelTimestamp ,
   事件输出时间戳  offPixelTimestamp ,
   还有机器(例如ROS)收到时的时间戳 rosTs

触发方式

 内触发模式: 相机通过设备内部给出的信号采集图像。 
 外触发模式: 相机通过外部给出的信号采集图像。
      外部信号可以是软件信号,也可以是硬件信号,主要包含软触发和硬件触发	   

曝光

叠曝光和非交叠曝光相比,交叠曝光可以减少曝光时间对出图时间的影响
 The frame transmission time  
 delay duration
 相机上的图像采集过程包括两个截然不同的部分。
   第一部分是exposure 曝光。曝光完成后,Exposure Time
   第二部分Readout过程 即从传感器的寄存器中读出数据并传送出去(Readout过程)
 曝光时间
    “non-overlapped”的曝光和“overlapped”的曝光。
      01.在非重叠(“non-overlapped”)模式中,每个图像采集的周期中,相机在下一个图像采集开始前,均要完成曝光/读出整个过程
 	 02.在“overlapped”曝光模式下 相机读出数据和下一帧曝光开始出现重叠的情况,在同一个时刻内,相机执行两个操作,导致在同样的单位时间内,
          可以采集到更多的图片,即相机的帧率更高
 		 
 		 overlapped”的曝光模式下: FramePeriod ≤Exposure Time + ReadoutTime
 		 “non-overlapped”的曝光模式下:FramePeriod > Exposure Time + Readout Time

PTP

 setting their internal clocks based on the same reference clock which is the GPS clock,
   using chronyd, gpsd, and IEEE 1588 PTP protocols,

the timestamps provided alongside with the information 	   
  PTP(Precision Time Protocol,精确时间同步协议)应运而生,最新协议是IEEE1588v2,可实现亚微秒量级的时间同步精度。
  PTP 是一种高精度时间同步协议 , 可以到达亚微秒级精度 , 有资料说可达到 30 纳秒左右的偏差精
       时间戳一般为10位和13位,10位的单位是秒,13位的是毫秒 1秒=1000毫秒(ms)  1秒=1,000,000 微秒(μs)  1秒=1,000,000,000 纳秒(ns)
 stamp: 
  secs: 1582203535
  nsecs: 456908823 

 NTP(Network Time Protocol) 局域网内计算机利用NTP协议进行时间同步,时间同步精度在5ms左右

数据块+ 元数据

1.Chunk   --》 data chunks
 chunk1 图像数据块 image data payload 图像有效载荷数据
 chunk1 ID
 chunk1 长度
 chunk2 Gain块
 
  这些数据帧中的记录信息的原始数据就是有效载荷数据,即 payload data
  头和尾都加上一定的辅助信息,比如这一批数据量的大小,校验位等,这样就相当于给已经分批原始数据加一些外套,
  这些外套起到标示作用,使得原始数据不易丢失
  
   Exposure Time Chunk 
       If this chunk is enabled, the camera appends the exposure time used for image acquisition to every image.
  

2.Metadata  --》 grab result data  or pylon chunk parser
    image height, image width, the image ROI offset, and the pixel format used.


###时间戳数据块
The Timestamp camera feature counts the number of ticks generated by the camera's internal device clock

 Timestamp Chunk#
     If this chunk is enabled, the camera appends an internal timestamp (in ticks) of a certain event to every image.
	    BslChunkTimestampValue  or  ChunkTimestamp
	 current image started 
  ChunkTimestamp  		 

  For Basler cameras, this means that their GevTimestampValue parameter values will be as identical as possible.

3.时间戳
  时间戳一般为10位和13位,10位的单位是秒,13位的是毫秒
  1秒=1000毫秒(ms)  1秒=1,000,000 微秒(μs)  1秒=1,000,000,000 纳秒(ns)
 stamp: 
  secs: 1582203535
  nsecs: 456908823
  
    The nodes “TimestampControlLatch”, 
	         “TimestampTickFrequency”,
			 Timestamp Value” 
			 and “TimestampControlReset” are used to retrieve the timestamp
  GevTimestampTickFrequency
 ## aca1920-48gc 
 执行 GevTimestampControlLatch 命令。获取相机当前时间戳值的“快照”。
 获取 GevTimestampValue 参数的值。该参数的值表示执行 GevTimestampControlLatch 命令的时间点 
  

相机型号
#include <GenApi/GenApi.h>

    // Take a "snapshot" of the camera's current timestamp value
     camera.TimestampLatch.Execute();
     // Get the timestamp value
     int64_t i = camera.TimestampLatchValue.GetValue();
     
	INodeMap& nodemap = camera.GetNodeMap();
    // Take a "snapshot" of the camera's current timestamp value
    CCommandParameter(nodemap, "TimestampLatch").Execute();
    // Get the timestamp value
    int64_t i = CIntegerParameter(nodemap, "TimestampLatchValue").GetValue(); 
	参考   
      https://docs.baslerweb.com/timestamp#__tabbed_2_1

相机型号 按C选择型号  GevTimestampControlReset command aca1920-48gc
    cam_->ChunkTimestamp.GetValue();
	
    // Take a "snapshot" of the camera's current timestamp value
    camera.GevTimestampControlLatch.Execute();
    // Get the timestamp value
    int64_t i = camera.GevTimestampValue.GetValue();
	
	
	INodeMap& nodemap = camera.GetNodeMap();
    // Take a "snapshot" of the camera's current timestamp value
    CCommandParameter(nodemap, "GevTimestampControlLatch").Execute();
    // Get the timestamp value
     int64_t i = CIntegerParameter(nodemap, "GevTimestampValue").GetValue();	

驱动代码

 bool PylonCameraNode::grabImage()
 {
     boost::lock_guard<boost::recursive_mutex> lock(grab_mutex_);
     // Store current time before the image is transmitted for a more accurate grab time estimation
     ros::Time grab_time = ros::Time::now();
     if ( !pylon_camera_->grab(img_raw_msg_.data) )
     {
         return false;
     }
     img_raw_msg_.header.stamp = grab_time; 
     return true;
 }



GenApi::INodeMap& node_map = cam_->GetNodeMap();
GenApi::INodeMap& node_map = dev.GetNodeMap();
Pylon::CCommandParameter
   Execute(bool Verify =true)   //Execute the command.
Pylon::CIntegerParameter
   GetValue(bool Verify =false, bool IgnoreCache =false) //Get node value.

bool setChunkEnableCallback(std_srvs::SetBool::Request &req, std_srvs::SetBool::Response &res);
 /**
 * Service callback for getting the Value of the timestamp when the image was acquired - Applies to: GigE and ace USB..
 * @param req request
 * @param res response
 * @return true on success
 */
 bool getChunkTimestampCallback(camera_control_msgs::GetIntegerValue::Request &req, camera_control_msgs::GetIntegerValue::Response &res);

 ros::ServiceServer get_chunk_timestamp_srv;
 int PylonCameraImpl<CameraTraitT>::getChunkTimestamp() {


 cam_info->header.stamp = img_raw_msg_.header.stamp;
 
  ros::Time grab_time = ros::Time::now();
  img_raw_msg_.header.stamp = grab_time; 
  
 
     // Store current time before the image is transmitted for a more accurate grab time estimation
    img.header.stamp = ros::Time::now();

格式化转换

 ros::Time int64_t
#include <string>	 
 
ros::Time timesamp2rostime(int64_t timesamp){
  std::string suanz = std::to_string(timesamp);
  std::string sec_string = suanz.substr(0,10);
  std::string nsec_string = suanz.substr(10,9);
  while(nsec_string.length() < 9){
      nsec_string += "0";
  }
  return ros::Time(std::stoi(sec_string),std::stoi(nsec_string));
}
 
 stamp: 
  secs: 1582203535
  nsecs: 456908823
 ROS的时间戳是很大的一个数值,所以在计算时, 用 double 类型,而不能用float

project

 A basic CMakeLists.txt CMake file could look like this:
  project (grab)
  
  ## Locate pylon.
  find_package(pylon 7.1.0 REQUIRED)
  
  add_executable(grab Grab.cpp)
  
  target_link_libraries(grab pylon::pylon)	 

相位锁定功能,也就是输入PPS,但PPS上升沿到来时,激光雷达的激光束恰好旋转到一定的角度

参考

 https://www.baslerweb.com/en/products/cameras/area-scan-cameras/ace/aca1920-40gc/
  https://zh.docs.baslerweb.com/aca1920-48gc	 
  https://docs.baslerweb.com/pylonapi/cpp/class_pylon_1_1_c_command_parameter
  https://blog.csdn.net/wyf826459/article/details/104783394
  激光雷达与相机时间同步问题的低成本完整解决方案 https://blog.csdn.net/qq_24972557/article/details/115049024

标签:同步,timestamp,image,概览,camera,时间,Time,grab,曝光
From: https://www.cnblogs.com/ytwang/p/17027668.html

相关文章

  • 用python得知 cron表达式-执行时间
    #!/user/bin/python3#-*-coding:utf-8-*-#@Author:zhaoruixiao#@Datetime:2023/1/514:30#@Software:PyCharm#@File:cron.py"""workfor$用python得......
  • 多传感器的空间同步和时间同步(Lidar+Camera+Radar+IMU)
    应用背景介绍多传感器融合是一项结合多传感器数据的综合性前沿内容,主要包括Camera、激光雷达、IMU、毫米波雷达等传感器的融合,在自动驾驶、移动机器人的感知和定位领域中占......
  • MongoDB时间范围查找
    1.查询时间范围,且模糊匹配message列中含“api”字符串的记录db.collection_fee.find({'time':{$gte:ISODate("2023-01-05T09:58:51.122Z"),$lte:ISODate("2......
  • win11修改任务栏中时间的字体颜色
    操作系统升级Windows11后,以前使用的透明任务栏软件StartIsBack也升级为StartAllBack了,由于同时使用了动态主题,有时自动下载的桌面背景的颜色和任务栏图标颜色冲突,导致看不......
  • unity代码编译时间分析工具
    https://github.com/needle-tools/compilation-visualizer    ......
  • rsync远程同步
    1.rsync远程备份1-1特点能以递归的形式更新整个目录;能有选择的保留文件同步属性,比如硬链接、软链接、所有者、所属组、对应权限、修改时间等,可以保留其中的一部分属性......
  • 前端时间xls表格数据读取和录入
    给了一份表格让把表格里的数据录到系统里,数据有7百多条,表单还很长所以简单写了一个脚本方便快速录入数据,主要用到了js读取表单首先 文件上传<in......
  • RestTemplate 设置超时时间(转发)
    项目访问量大,频繁调取其他系统接口经常出现项目后台假死现象,发现其他系统掉线重启一段时间必现。查看调用接口,同事直接引用了RestTemplate但是没有设置超时时间->_<-。两......
  • 极客时间《性能测试实战》——性能测试基础
    性能测试的概念1.性能测试概念的传统解释:压力测试压力测试是评估系统处于或超过预期负载时系统的运行情况。压力测试的关注点在于系统在峰值负载或超出最大载荷情况下......
  • 数据分享|R语言分析上海空气质量指数数据:kmean聚类、层次聚类、时间序列分析:arima模型
    全文链接:http://tecdat.cn/?p=30131最近我们被客户要求撰写关于上海空气质量指数的研究报告,包括一些图形和统计输出。最近我们被客户要求撰写关于上海空气质量指数的研究......