文章目录
2020.12.17
1. zip压缩包解压后文件名乱码
解决方法:
unzip -O CP936 xxx.zip # 其中字符可以是CP936、GBK、GB18030三种中的任一一种
2. 缺少orocos-bfl包
报错如下:
-- Checking for module 'orocos-bfl'
-- No package 'orocos-bfl' found
CMake Error at /usr/share/cmake-3.5/Modules/FindPkgConfig.cmake:367 (message):
解决方法:
sudo apt-get install ros-kinetic-bfl
注意:不存在安装orocos-bfl,只有安装bfl。
3. roslaunch的BUG
报错如下:
~$ roslaunch turtlebot_bringup minimal.launch
... logging to /home/zth/.ros/log/9db37e30-4028-11eb-8353-70c94edd2295/roslaunch-sugoasurada-16599.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
xacro: Traditional processing is deprecated. Switch to --inorder processing!
To check for compatibility of your document, use option --check-order.
For more infos, see http://wiki.ros.org/xacro#Processing_Order
resource not found: create_description
ROS path [0]=/opt/ros/kinetic/share/ros
ROS path [1]=/home/zth/work_ws/src
ROS path [2]=/home/zth/tutorial_ws/src
ROS path [3]=/opt/ros/kinetic/share None
when processing file: /home/zth/work_ws/src/turtlebot/turtlebot/turtlebot_description/urdf/turtlebot_library.urdf.xacro
included from: /home/zth/work_ws/src/turtlebot/turtlebot/turtlebot_description/robots/kobuki_hexagons_kinect.urdf.xacro
while processing /home/zth/work_ws/src/turtlebot/turtlebot/turtlebot_bringup/launch/includes/robot.launch.xml:
while processing /home/zth/work_ws/src/turtlebot/turtlebot/turtlebot_bringup/launch/includes/description.launch.xml:
Invalid <param> tag: Cannot load command parameter [robot_description]: command [/opt/ros/kinetic/share/xacro/xacro.py '/home/zth/work_ws/src/turtlebot/turtlebot/turtlebot_description/robots/kobuki_hexagons_kinect.urdf.xacro'] returned with code [2].
Param xml is <param command="$(arg urdf_file)" name="robot_description"/>
The traceback for the exception was written to the log file
解决方法:
sudo apt-get install ros-kinetic-create-description
5. 缺少turtlebot_msgs包
报错如下:
-- Could not find the required component 'turtlebot_msgs'. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found.
解决方法:
sudo apt-get install ros-kinetic-turtlebot-msgs
6. 缺少joy包
报错如下:
-- Could not find the required component 'joy'. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found.
解决方法:
udo apt-get install ros-kinetic-joy
7. catkin_make警告和报错
警告如下:
CMake Warning at /opt/ros/kinetic/share/cmake_modules/cmake/Modules/FindEigen.cmake:62 (message):
The FindEigen.cmake Module in the cmake_modules package is deprecated.
Please use the FindEigen3.cmake Module provided with Eigen. Change
instances of find_package(Eigen) to find_package(Eigen3). Check the
FindEigen3.cmake Module for the resulting CMake variable names.
报错如下:
CMake Error at turtlebot/navigation/clear_costmap_recovery/CMakeLists.txt:52 (add_dependencies):
The dependency target "/opt/ros/kinetic/lib/libroslib.so" of target "tests"
does not exist.
吐槽:类似的错误很多很多,感觉有几百个,网上没有找到简单的解决方法,还是我太菜了,不会用那些方法。我偶然给了sudo权限,问题迎刃而解。
解决方法:给sudo权限,然后catkin_make如果产生警告报错就再catkin_make一
遍就ok了。
2020.12.17
1. catkin_make卡住不动
一直卡在下面这个地方,或者100%的地方。
https://github.com/ros-planning/navigation/issues/761在这个Github上发现有人和我同样的问题,看来不是什么大问题,只能慢慢等了。
等了一二十分钟,终于!!!太快乐了!!!
2. 键盘控制机器人移动代码C++版
w:前进
s:后退
a:左转
d:右转
2.1 版本1
#include "ros/ros.h"
#include "geometry_msgs/Twist.h"
#include<stdio.h>
#include<stdlib.h>
float angular_z = 0;
int main(int argc, char **argv)
{
char ch = 0;
// 初始化ROS节点
ros::init(argc, argv, "keyboard");
// 创建节点句柄
ros::NodeHandle n;
// 创建一个Publisher,发布名为/cmd_vel_mux/input/teleop的topic,队列长度10
ros::Publisher turtlebot_pub = n.advertise<geometry_msgs::Twist>("/cmd_vel_mux/input/teleop", 10);
// 设置循环的频率
ros::Rate loop_rate(10);
int count = 0;
while (ros::ok())
{
// 初始化geometry_msgs::Twist类型的消息
geometry_msgs::Twist vel_msg;
ch = getchar();
if(ch == 'w')
{
vel_msg.linear.x = 0.1;
}
else if(ch == 's')
{
vel_msg.linear.x = -0.1;
}
else if(ch == 'a')
{
vel_msg.angular.z += 0.5;
angular_z = vel_msg.angular.z;
}
else if(ch == 'd')
{
vel_msg.angular.z -= 0.5;
angular_z = vel_msg.angular.z;
}
// 发布消息
turtlebot_pub.publish(vel_msg);
ROS_INFO("Publsh turtle command[%0.2f m/s, %0.2f rad/s]", vel_msg.linear.x, vel_msg.angular.z);
// 按照循环频率延时
loop_rate.sleep();
}
return 0;
}
2.2 版本2
#include "ros/ros.h"
#include "geometry_msgs/Twist.h"
#include<stdio.h>
#include<stdlib.h>
float angular_z = 0;
int main(int argc, char **argv)
{
char ch = 0;
// 初始化ROS节点
ros::init(argc, argv, "keyboard");
// 创建节点句柄
ros::NodeHandle n;
// 创建一个Publisher,发布名为/cmd_vel_mux/input/teleop的topic,队列长度10
ros::Publisher turtlebot_pub = n.advertise<geometry_msgs::Twist>("/cmd_vel_mux/input/teleop", 10);
// 设置循环的频率
ros::Rate loop_rate(10);
int count = 0;
while (ros::ok())
{
// 初始化geometry_msgs::Twist类型的消息
geometry_msgs::Twist vel_msg;
if(count == 0)
{
vel_msg.linear.x = 0;
vel_msg.angular.z = angular_z;
ch = getchar();
count++;
}
if(count > 0 && count < 3)
{
if(ch == 'w')
{
vel_msg.linear.x = 0.1;
}
else if(ch == 's')
{
vel_msg.linear.x = -0.1;
}
else if(ch == 'a')
{
vel_msg.angular.z += 0.5;
angular_z = vel_msg.angular.z;
}
else if(ch == 'd')
{
vel_msg.angular.z -= 0.5;
angular_z = vel_msg.angular.z;
}
count++;
}
if(count >= 3)
{
count = 0;
}
// 发布消息
turtlebot_pub.publish(vel_msg);
ROS_INFO("Publsh turtle command[%0.2f m/s, %0.2f rad/s]", vel_msg.linear.x, vel_msg.angular.z);
// 按照循环频率延时
loop_rate.sleep();
}
return 0;
}