1.通过节点订阅t265的里程计数据
我使用的是Kinetic版本 1)环境安装
sudo apt-key adv --keyserver keys.gnupg.net --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE || sudo ap
sudo add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo $(lsb_release -cs) main" -u
sudo apt-get update
sudo apt-get install librealsense2-dkms librealsense2-utils librealsense2-dev librealsense2-dbg
realsense-viewer
成功运行的话就会出现Intel的上位机的界面了。 2)安装T265的ROS包
sudo apt-get install ros-kinetic-ddynamic-reconfigure
cd ~/catkin_ws/src/
git clone https://github.com/IntelRealSense/realsense-ros.git
cd realsense-ros/
git checkout `git tag | sort -V | grep -P "^2.\d+\.\d+" | tail -1`
cd ..
catkin_make -DCATKIN_ENABLE_TESTING=False -DCMAKE_BUILD_TYPE=Release
3)接下来运行这个可以在rviz中看到T265的图像信息
roslaunch realsense2_camera demo_t265.launch
运行这个可以使t265发布话题
roslaunch realsense2_camera rst265.launch
这样t265就可以发布数据了,我们以话题的方式来接受他
订阅T265的里程计信息
我用的是vscode开发环境
1)在realsense2_camera功能包里创建一个stm32_sub_t265.cpp文件,并编写如下代码
#include "../include/t265_realsense_node.h"
#include "t265_realsense_node.h"
#include <serial/serial.h>
void doMsg(const nav_msgs::Odometry::ConstPtr& msg)
{
float pose_x=0,pose_y=0,pose_z=0,speed_x=0,speed_y=0,speed_z=0;
pose_x = -msg->pose.pose.position.x;
pose_y = -msg->pose.pose.position.y;
pose_z = msg->pose.pose.position.z;
speed_x = msg->twist.twist.linear.x;
speed_y = -msg->twist.twist.linear.y;
speed_z = msg->twist.twist.linear.z;
ROS_INFO("X_坐标:%f Y_坐标:%f Z_坐标:%f", pose_x,pose_y,pose_z);
ROS_INFO("X_速度:%f Y_速度:%f Z_速度:%f", speed_x,speed_y,speed_z);
}
int main(int argc, char *argv[])
{
setlocale(LC_ALL,"");
ros::init(argc, argv, "air_t265");
ros::NodeHandle nh;
ros::Subscriber sub = nh.subscribe("/camera/odom/sample",10,doMsg);
ros::spin();
return 0;
}
2)在CMakeList.txt中添加如下代码
add_executable(stm32_sub_t265 src/stm32_sub_t265.cpp)
target_link_libraries(stm32_sub_t265
${catkin_LIBRARIES}
)
并修改这段代码如下
add_library(${PROJECT_NAME}
include/constants.h
include/realsense_node_factory.h
include/base_realsense_node.h
include/t265_realsense_node.h
src/realsense_node_factory.cpp
src/base_realsense_node.cpp
src/t265_realsense_node.cpp
src/stm32_sub_t265.cpp
)
4)接下来就可以运行相关节点了
roslaunch realsense2_camera rst265.launch
roslaunch realsense2_camera stm32_sub_t265
运行结果如下
实现linux系统与stm32通信,并向stm32发送里程计信息
|