• 大小: 418KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-09
  • 语言: 其他
  • 标签: ROS  多机器人  pioneer  

资源简介

基于ROS环境,开发针对pioneer 3 先锋多机器人控制的程序。内容包括如何构建ROS、RosAria环境,及针对Pioneer 3的单个、多个机器人控制程序,并附带简单例程。

资源截图

代码片段和文件信息

/**************************************************************************
   Date:      16 Feb. 2014
   File:      android_teleop.cpp
   Function:  use your Android phone to control the robot 
   Description: 
              1) http://wiki.ros.org/ROSARIA/Tutorials/iPhone%20Teleop%20with%20ROSARIA/Android%20teleop%20Pioneer%203at
              2) you need to download ROS Sensor Drive to your phone
**************************************************************************/

   #include 
   #include “geometry_msgs/Twist.h“
   #include “rosaria/BumperState.h“
   #include “sensor_msgs/Imu.h“
   #include 
   #include 
   
   
   using geometry_msgs::Twist;
   using namespace std;
   
   ros::Publisher vel_pub;
   ros::Time t1;
   Twist vel;
   int kfd = 0;
   struct termios cooked raw;
   unsigned int temp=0;
   float x;
   float y;
   float z;
   
   
   void quit(int sig)
   {
       tcsetattr(kfd TCSANOW &cooked);
       ros::shutdown();
       exit(0);
   }
   

   void anCallback(const sensor_msgs::Imu::ConstPtr& ansmsg)
   {
       x=ansmsg->angular_velocity.x;
       y=ansmsg->angular_velocity.y;
       z=ansmsg->angular_velocity.z; 
   }


   int main(int argc char** argv)
   { 
       int ther=3;
   
       ros::init(argc argv “android_teleop“);
       ros::NodeHandle n;
       vel_pub = n.advertise(“/RosAria/cmd_vel“ 1);  
       signal(SIGINTquit);
       ros::Rate r(5);

       char c;
       bool dirty=false;   
       t1=ros::Time::now();
   
       tcgetattr(kfd &cooked);
       memcpy(&raw &cooked sizeof(struct termios));
       raw.c_lflag &=~ (ICANON | ECHO);
       raw.c_cc[VEOL] = 1;
       raw.c_cc[VEOF] = 2;
       tcsetattr(kfd TCSANOW &raw);
   
       //subscribe to android imu sensor msgs
       ros::Subscriber imu_pub = n.subscribe(“/android/imu“ 1 anCallback);
    
   
       while (ros::ok())
       {     
         if(x > ther)
         {
           vel.linear.x = 0.2;
           vel.linear.y=0;
           vel.linear.z=0;
           vel.angular.x = 0;
           vel.angular.y = 0;
           vel.angular.z = 0;
           ROS_INFO(“forward“);  
         }

         if(x < -ther)
         {
           vel.linear.x = -0.2;
           vel.linear.y=0;
           vel.linear.z=0;
           vel.angular.x = 0;
           vel.angular.y = 0;
           vel.angular.z = 0;
           ROS_INFO(“Backward“);
         }
       
         if(z > ther)
         {
           vel.linear.x = 0;
           vel.linear.y=0;
           vel.linear.z=0;
           vel.angular.x = 0;
           vel.angular.y = 0;
           vel.angular.z = 0.5;
           ROS_INFO(“Turnleft“);
         }
 
         if(z < -ther)
         {
           vel.linear.x = 0;
           vel.linear.y=0;
           vel.linear.z=0;
           vel.angular.x = 0;
           vel.angular.y = 0;
           vel.angular.z = -0.5;
           ROS_INFO(“Turnright“);
         }
 
         if(y < -ther)
         {
  

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       3609  2014-08-18 08:28  pioneer3_control_ros-master\android_teleop.cpp

     文件      27591  2014-08-18 08:28  pioneer3_control_ros-master\AriaRobot.h

     文件       1179  2014-08-18 08:28  pioneer3_control_ros-master\cfg\RosAria.cfg

     文件       5055  2014-08-18 08:28  pioneer3_control_ros-master\CMakeLists.txt

    .......        56  2014-08-18 08:28  pioneer3_control_ros-master\msg\BumperState.msg

     文件       2255  2014-08-18 08:28  pioneer3_control_ros-master\p3_kinect.cpp

     文件       4550  2014-08-18 08:28  pioneer3_control_ros-master\p3_sonar.cpp

     文件      11307  2017-10-18 11:35  pioneer3_control_ros-master\p3_sonar_following_moving_object.cpp

     文件       2094  2014-08-18 08:28  pioneer3_control_ros-master\package.xml

     文件     487293  2014-08-18 08:28  pioneer3_control_ros-master\pioneer3_control_ros_18AUG14.pdf

     文件       1295  2014-08-18 08:28  pioneer3_control_ros-master\readme.txt

     文件        738  2014-08-18 08:28  pioneer3_control_ros-master\robotDemo.cpp

     文件        913  2014-08-18 08:28  pioneer3_control_ros-master\robotWander.cpp

     文件       2365  2014-08-18 08:28  pioneer3_control_ros-master\rob_key.cpp

     文件      13451  2014-08-18 08:28  pioneer3_control_ros-master\rob_key_multi_robot_con_separately.cpp

     文件        622  2014-08-18 08:28  pioneer3_control_ros-master\RosAria.cpp

     文件      22962  2014-08-18 08:28  pioneer3_control_ros-master\RosAria_original.cpp

     文件       2642  2014-08-18 08:28  pioneer3_control_ros-master\rosRemoteTest.launch

     文件        972  2014-08-18 08:28  pioneer3_control_ros-master\test_cmd.cpp

     文件       1443  2014-08-18 08:28  pioneer3_control_ros-master\test_record_data.cpp

     目录          0  2014-08-18 08:28  pioneer3_control_ros-master\cfg

     目录          0  2014-08-18 08:28  pioneer3_control_ros-master\msg

     目录          0  2017-03-27 11:17  pioneer3_control_ros-master\pioneer3_control_ros-master

     目录          0  2017-03-27 11:17  pioneer3_control_ros-master

----------- ---------  ---------- -----  ----

               592392                    24


评论

共有 条评论