资源简介
基于turtlesim小乌龟实现的ROS 扫地机器人路径覆盖算法,及差速控制。
使用方法:
1、下载源码
cd catkin_ws/src
catkin_create_pkg turtlesim_cleaner
cd catkin_ws
catkin_make
2、运行
roscore //ROS Master
rosrun turtlesim turtlesim_node //turtlesim
rosrun turtlesim_cleaner robot_cleaner_node
代码片段和文件信息
#include “ros/ros.h“
#include “geometry_msgs/Twist.h“
#include “turtlesim/Pose.h“
#include
using namespace std;
ros::Publisher velocity_publisher;
ros::Subscriber pose_subscriber; // to determine the position for turning the robot in an absolute orientation --> in the setDesiredOrientation fn
turtlesim::Pose turtlesim_pose;
const double PI = 3.14159265359;
void move(double speed double distance bool isForward);
void rotate(double angular_speed double angle bool cloclwise); //this will rotate the turtle at specified angle from its current angle
double degrees2radians(double angle_in_degrees);
double setDesiredOrientation(double desired_angle_radians); //this will rotate the turtle at an absolute angle whatever its current angle is
void poseCallback(const turtlesim::Pose::ConstPtr & pose_message); //Callback fn everytime the turtle pose msg is published over the /turtle1/pose topic.
int main(int argc char **argv)
{
// Initiate new ROS node named “talker“
ros::init(argc argv “turtlesim_cleaner“);
ros::NodeHandle n;
double speed angular_speed;
double distance angle;
bool isForward clockwise;
velocity_publisher = n.advertise(“/turtle1/cmd_vel“ 1000);
pose_subscriber = n.subscribe(“/turtle1/pose“ 10 poseCallback); //call poseCallback everytime the turtle pose msg is published over the /turtle1/pose topic.
//ros::Rate loop_rate(10);
// /turtle1/cmd_vel is the Topic name
// /geometry_msgs::Twist is the msg type
ROS_INFO(“\n\n\n ********START TESTING*********\n“);
/*
cout<<“enter speed: “;
cin>>speed;
cout<<“enter distance: “;
cin>>distance;
cout<<“forward?: “;
cin>>isForward;
move(speed distance isForward);
//this is to move and rotate the robot as the user.
cout<<“enter angular velocity: “;
cin>>angular_speed;
cout<<“enter angle: “;
cin>>angle;
cout<<“Clockwise?: “;
cin>>clockwise;
rotate(degrees2radians(angular_speed) degrees2radians(angle) clockwise);
*/
setDesiredOrientation(degrees2radians(120));
ros::Rate loop_rate(0.5);
loop_rate.sleep();
setDesiredOrientation(degrees2radians(-60));
loop_rate.sleep();
setDesiredOrientation(degrees2radians(0));
ros::spin();
return 0;
}
void move(double speed double distance bool isForward){
geometry_msgs::Twist vel_msg;
//set a random linear velocity in the x-axis
if (isForward)
vel_msg.linear.x =abs(speed);
else
vel_msg.linear.x =-abs(speed);
vel_msg.linear.y =0;
vel_msg.linear.z =0;
//set a random angular velocity in the y-axis
vel_msg.angular.x = 0;
vel_msg.angular.y = 0;
vel_msg.angular.z =0;
double t0 = ros::Time::now().toSec();
double current_distance = 0.0;
ros::Rate loop_rate(100);
do{
velocity_publisher.publish(vel_msg);
double t1 = ros::Time::now().toSec();
current_distance = speed * (t1-t0);
ros::spinOnce();
loop_rate.sleep();
//cout<<(t1-t0)<<“ “< }while(current_distance
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 268 2020-01-31 17:51 turtlesim_cleaner\.git\config
文件 73 2020-01-31 17:51 turtlesim_cleaner\.git\desc
文件 23 2020-01-31 17:51 turtlesim_cleaner\.git\HEAD
文件 452 2020-01-31 17:51 turtlesim_cleaner\.git\hooks\applypatch-msg.sample
文件 896 2020-01-31 17:51 turtlesim_cleaner\.git\hooks\commit-msg.sample
文件 189 2020-01-31 17:51 turtlesim_cleaner\.git\hooks\post-update.sample
文件 398 2020-01-31 17:51 turtlesim_cleaner\.git\hooks\pre-applypatch.sample
文件 1642 2020-01-31 17:51 turtlesim_cleaner\.git\hooks\pre-commit.sample
文件 1352 2020-01-31 17:51 turtlesim_cleaner\.git\hooks\pre-push.sample
文件 4898 2020-01-31 17:51 turtlesim_cleaner\.git\hooks\pre-reba
文件 1239 2020-01-31 17:51 turtlesim_cleaner\.git\hooks\prepare-commit-msg.sample
文件 3611 2020-01-31 17:51 turtlesim_cleaner\.git\hooks\update.sample
文件 784 2020-01-31 17:51 turtlesim_cleaner\.git\index
文件 240 2020-01-31 17:51 turtlesim_cleaner\.git\info\exclude
文件 186 2020-01-31 17:51 turtlesim_cleaner\.git\logs\HEAD
文件 186 2020-01-31 17:51 turtlesim_cleaner\.git\logs\refs\heads\master
文件 186 2020-01-31 17:51 turtlesim_cleaner\.git\logs\refs\remotes\origin\HEAD
文件 121 2020-01-31 17:51 turtlesim_cleaner\.git\ob
文件 156 2020-01-31 17:51 turtlesim_cleaner\.git\ob
文件 633 2020-01-31 17:51 turtlesim_cleaner\.git\ob
文件 391 2020-01-31 17:51 turtlesim_cleaner\.git\ob
文件 157 2020-01-31 17:51 turtlesim_cleaner\.git\ob
文件 203 2020-01-31 17:51 turtlesim_cleaner\.git\ob
文件 156 2020-01-31 17:51 turtlesim_cleaner\.git\ob
文件 2191 2020-01-31 17:51 turtlesim_cleaner\.git\ob
文件 2469 2020-01-31 17:51 turtlesim_cleaner\.git\ob
文件 804 2020-01-31 17:51 turtlesim_cleaner\.git\ob
文件 199 2020-01-31 17:51 turtlesim_cleaner\.git\ob
文件 836 2020-01-31 17:51 turtlesim_cleaner\.git\ob
文件 122 2020-01-31 17:51 turtlesim_cleaner\.git\ob
............此处省略123个文件信息
- 上一篇:TMS320F28335_SCI.rar
- 下一篇:印刷体数字识别
相关资源
- wifi电路调试经验之谈
- Oxford Industries 采用 Microsoft.NET 平台实
- IBM CAW for Microsoft Cluster Server 简介
- IBM.Rational.Rose.Enterprise的license.upd
- Symantec AntiVirus for Microsoft SharePoint产品
- Microservice patterns
- Microsoft Visio 2013 Professional 64位简体中
- Microsoft Project 2016
- 含Microsoft.Office.Interop.Owc11
- The Existence and Stability of Nontrivial St
- DS4000存储系统上Microsoft Exchange 2003的存
- Microsoft Visual Studio 2017 Installer Project
- 通过 Microsoft Services for UNIX 将 UNIX 应用
- Microsoft Windows Services for UNIX 3.5 版中的
- Ross-Konno手术后左心室流出道梗阻
- Genome doubling and chromosome elimination wit
- Improvement of the coercivity and corrosion re
- Effects of cerium on the microstructure and me
- crossfilter tutorial
- RoboWare Studio中文版(2018).pdf
- 倍加福二维码识别模块使用手册
- Bioinformatics analysis of tyrosinase-related
- Effect of isovalent substitution on martensiti
- Facile hydrothermal synthesis of Tb2(MoO4)
- Spectroscopic Study on Cu2+-induced Abnormally
- ROS 6.40.3最新破解版 Mikrotik RouterOS L6全
- 论文研究-基于AMBA AXI总线的Crossbar互联
- router os 6.0支持IDE破解版
- ROST内容挖掘软件
- Aerosim Blockset
评论
共有 条评论