USB各描述符的定义怎么表示?

USB各描述符的定义,在C语言中,实际上用简单的数组就可以表示,如下:

uint8_t XXX_DeviceDescriptor[JOYSTICK_SIZ_DEVICE_DESC] =
{

0x12, /* bLength: Size of this descriptor in bytes*/

USB_DEVICE_DESCRIPTOR_TYPE, 			/*bDescriptorType*/

0x00,                       /*bcdUSB : USB Specification Release Number*/
0x02,

0x00,                       /*bDeviceClass: zero, each interface within a configuration specifies its own
				class information and the various interfaces operate independently*/
				
0x00,                       /*bDeviceSubClass*/

0x00,                       /*bDeviceProtocol*/

0x40,                       /*bMaxPacketSize 64:Maximum packet size for endpoint zero*/

0xXX,                       /* idVendor */
0xXX,

0x05,                       /*idProduct*/
0x00,

0x00,                       /*bcdDevice rel. 2.00:Device release number*/
0x02,

IndexStringDescriptor_Manufacturer,                          /*Index of string descriptor describing manufacturer */

IndexStringDescriptor_Product,                          /*Index of string descriptor describing product*/

IndexStringDescriptor_DeviceSerialNumber,                          /*Index of string descriptor describing the device's serial number */

0x01                        /*bNumConfigurations:  Number of possible configurations*/

};
uint8_t XXX_ConfigurationDescriptor[JOYSTICK_SIZ_CONFIG_DESC] =
{
0x09, /* bLength: Configuration Descriptor size */

USB_CONFIGURATION_DESCRIPTOR_TYPE, 	/* bDescriptorType: CONFIGURATION Descriptor Type */

JOYSTICK_SIZ_CONFIG_DESC,				/* wTotalLength: Bytes returned. : Total length of data returned for this*/
0x00,									// configuration. Includes the combined length of all descriptors (configuration, interface,
									// endpoint, and class- or vendor-specific) returned for this configuration.     

0x01,        	 /*bNumInterfaces: 1 interface: Number of interfaces supported by this configuration*/

0x01,         /*bConfigurationValue: Configuration value:Value to use as an argument to the
							SetConfiguration() request to select this configuration*/
							
0x00,         /*iConfiguration: Index of string descriptor describing the configuration*/

0xE0,         /*bmAttributes: Self powered
			D6: Self-powered.
			D5: Remote Wakeup.*/

0x32,         /*MaxPower 100 mA: this current is used for detecting Vbus*/

/************** Descriptor of Joystick Mouse interface ****************/
/* 09 */
0x09,         /*bLength: Size of this descriptor in bytes*/

USB_INTERFACE_DESCRIPTOR_TYPE,/*bDescriptorType: Interface descriptor type*/

0x00,         /*bInterfaceNumber:  Number of this interface. Zero-based
		value identifying the index in the array of concurrent interfaces supported by this configuration*/
		
0x00,         /*bAlternateSetting: Value used to select this alternate setting
		for the interface identified in the prior field*/

0x01,         /*bNumEndpoints: Number of endpoints used by this interface (excluding endpoint zero). If this
		value is zero, this interface only uses the Default Control Pipe*/
		
0x03,         /*bInterfaceClass: HID. : Class code (assigned by the USB-IF).*/

0x01,         /*bInterfaceSubClass : 1=BOOT, 0=no boot.:Subclass code (assigned by the USB-IF).*/

0x02,         /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse.: Protocol code (assigned by the USB)*/

IndexStringDescriptor_Interface,            /*iInterface: Index of string descriptor describing this interface*/
/******************** Descriptor of Joystick Mouse HID ********************/
/* 18 */
0x09,         /*bLength: HID Descriptor size*/

HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/

0x00,         /*bcdHID: HID Class Spec release number*/
0x01,

0x00,         /*bCountryCode: Hardware target country*/

0x01,         /*bNumDescriptors: Number of HID class descriptors to follow*/

0x22,         /*bDescriptorType: type of next descriptor, 0x22 is for report descriptor.*/

JOYSTICK_SIZ_REPORT_DESC,/*wItemLength: Total length of Report descriptor*/
0x00,
/******************** Descriptor of Joystick Mouse endpoint ********************/
/* 27 */
0x07,          /*bLength: Size of this descriptor in bytes*/

USB_ENDPOINT_DESCRIPTOR_TYPE, /* ENDPOINT Descriptor Type*/

0x81,          /*bEndpointAddress: Endpoint Address (IN).
			Bit 3...0: The endpoint number
		Bit 6...4: Reserved, reset to zero
		Bit 7: Direction, ignored for control endpoints.
			 0 = OUT endpoint
			 1 = IN endpoint*/
			 
0x03,          /*bmAttributes: Interrupt endpoint.
			 This field describes the endpoint’s attributes when it is configured using the bConfigurationValue.
			Bits 1..0: Transfer Type
				 00 = Control
				 01 = Isochronous
				 10 = Bulk
				 11 = Interrupt	---set
		If not an isochronous endpoint, bits 5..2 are reserved and must be set to zero. If isochronous, they are
		defined as follows:...*/
		
0x04,          /*wMaxPacketSize: 4 Byte max. :Maximum packet size this endpoint is capable of*/
0x00,		 // sending or receiving when this configuration is selected. 
		
0x20,          /*bInterval: Polling Interval (32 ms). :Interval for polling endpoint for data transfers*/
/* 34 */

};

### RVIZ2 中不支持立体视觉的原因 RVIZ2 主要用于可视化来自不同传感器的数据,包括激光雷达、摄像头等。然而,在当前版本中确实存在对立体视觉支持不足的情况[^2]。 原因主要在于: - **数据处理复杂度**:立体视觉涉及到两幅图像的同时处理与匹配计算,这对实时性能提出了更高要求。 - **API 设计差异**:ROS 2 的 API 虽然提供了丰富的功能接口来构建复杂的机器人应用系统,但对于特定类型的多目相机的支持还不够完善。 ### 解决方案 尽管官方默认情况下未直接提供针对立体视觉的良好集成体验,但仍有一些可行的方法可以实现这一需求: #### 方法一:自定义插件开发 通过创建自定义显示插件的方式扩展 RVIZ2 功能。这需要开发者熟悉 C++ 编程语言以及 ROS 2 插件机制,并能够调用 OpenCV 或其他计算机视觉库来进行双目视差图的生成渲染。 ```cpp #include <rviz_common/display.hpp> // ... other necessary includes ... class StereoVisionDisplay : public rviz_common::Display { public: // Implement required methods and members here... }; ``` #### 方法二:利用第三方工具链 借助于像 `stereo_image_proc` 这样的包先对外部获取到的左右眼图片流做预处理得到深度信息后再输入给 RVIZ2 显示。这种方式不需要修改 RVIZ2 源码本身,相对简单易行一些。 ```bash ros2 run stereo_image_proc disparity stereo/left/image_raw stereo/right/image_raw ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

S,D

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值