• 大小: 345KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-13
  • 语言: 其他
  • 标签: ROS  SLAM  

资源简介

ROS通过RPLIDAR-A2实现Gmapping,其中包括机器人描述文件、模型文件、导航文件、运动控制文件等,可有效帮助ROS-SLAM初学者进行基本学习

资源截图

代码片段和文件信息

#include 
#include 
#include 
#include 

int main(int argc char** argv) {
    ros::init(argc argv “state_publisher“);
    ros::NodeHandle n;
    ros::Publisher joint_pub = n.advertise(“joint_states“ 1);
    tf::TransformBroadcaster broadcaster;
    ros::Rate loop_rate(30);

    const double degree = M_PI/180;

    // robot state
    double inc= 0.005 base_arm_inc= 0.005 arm1_armbase_inc= 0.005 arm2_arm1_inc= 0.005 gripper_inc= 0.005 tip_inc= 0.005;
    double angle= 0 base_arm = 0 arm1_armbase = 0 arm2_arm1 = 0 gripper = 0 tip = 0;
    // message declarations
    geometry_msgs::TransformStamped odom_trans;
    sensor_msgs::JointState joint_state;
    odom_trans.header.frame_id = “odom“;
    odom_trans.child_frame_id = “base_link“;

    while (ros::ok()) {
        //update joint_state
        joint_state.header.stamp = ros::Time::now();
        joint_state.name.resize(11);
        joint_state.position.resize(11);
        joint_state.name[0] =“base_to_arm_base“;
        joint_state.position[0] = base_arm;
        joint_state.name[1] =“arm_1_to_arm_base“;
        joint_state.position[1] = arm1_armbase;
        joint_state.name[2] =“arm_2_to_arm_1“;
        joint_state.position[2] = arm2_arm1;
joint_state.name[3] =“left_gripper_joint“;
        joint_state.position[3] = gripper;
joint_state.name[4] =“left_tip_joint“;
        joint_state.position[4] = tip;
joint_state.name[5] =“right_gripper_joint“;
        joint_state.position[5] = gripper;
joint_state.name[6] =“right_tip_joint“;
        joint_state.position[6] = tip;
joint_state.name[7] =“base_to_wheel1“;
        joint_state.position[7] = 0;
joint_state.name[8] =“base_to_wheel2“;
        joint_state.position[8] = 0;
joint_state.name[9] =“base_to_wheel3“;
        joint_state.position[9] = 0;
joint_state.name[10] =“base_to_wheel4“;
        joint_state.position[10] = 0;






        // update transform
        // (moving in a circle with radius)
        odom_trans.header.stamp = ros::Time::now();
        odom_trans.transform.translation.x = cos(angle);
        odom_trans.transform.translation.y = sin(angle);
        odom_trans.transform.translation.z = 0.0;
        odom_trans.transform.rotation = tf::createQuaternionMsgFromYaw(angle);

        //send the joint state and transform
        joint_pub.publish(joint_state);
        broadcaster.sendTransform(odom_trans);


// Create new robot state
        arm2_arm1 += arm2_arm1_inc;
        if (arm2_arm1<-1.5 || arm2_arm1>1.5) arm2_arm1_inc *= -1;
  arm1_armbase += arm1_armbase_inc;
        if (arm1_armbase>1.2 || arm1_armbase<-1.0) arm1_armbase_inc *= -1;
        base_arm += base_arm_inc;
        if (base_arm>1. || base_arm<-1.0) base_arm_inc *= -1;
        gripper += gripper_inc;
        if (gripper<0 || gripper>1) gripper_inc *= -1;

  angle += degree/4;

        // This will adjust as needed per iteration
        loop_rate.sleep

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-05-10 13:06  ROS-SLAM-Gmapping-master\
     文件          42  2018-05-10 13:06  ROS-SLAM-Gmapping-master\README.md
     目录           0  2018-05-10 13:06  ROS-SLAM-Gmapping-master\ROSArduinoBridge\
     文件        9279  2018-05-10 13:06  ROS-SLAM-Gmapping-master\ROSArduinoBridge\ROSArduinoBridge.ino
     文件         542  2018-05-10 13:06  ROS-SLAM-Gmapping-master\ROSArduinoBridge\commands.h
     文件        3994  2018-05-10 13:06  ROS-SLAM-Gmapping-master\ROSArduinoBridge\diff_controller.h
     文件         630  2018-05-10 13:06  ROS-SLAM-Gmapping-master\ROSArduinoBridge\encoder_driver.h
     文件        2340  2018-05-10 13:06  ROS-SLAM-Gmapping-master\ROSArduinoBridge\encoder_driver.ino
     文件         302  2018-05-10 13:06  ROS-SLAM-Gmapping-master\ROSArduinoBridge\motor_driver.h
     文件        1696  2018-05-10 13:06  ROS-SLAM-Gmapping-master\ROSArduinoBridge\motor_driver.ino
     文件        1001  2018-05-10 13:06  ROS-SLAM-Gmapping-master\ROSArduinoBridge\sensors.h
     文件         997  2018-05-10 13:06  ROS-SLAM-Gmapping-master\ROSArduinoBridge\servos.h
     文件        1791  2018-05-10 13:06  ROS-SLAM-Gmapping-master\ROSArduinoBridge\servos.ino
     目录           0  2018-05-10 13:06  ROS-SLAM-Gmapping-master\robot1_description\
     文件        5442  2018-05-10 13:06  ROS-SLAM-Gmapping-master\robot1_description\CMakeLists.txt
     目录           0  2018-05-10 13:06  ROS-SLAM-Gmapping-master\robot1_description\launch\
     文件        1190  2018-05-10 13:06  ROS-SLAM-Gmapping-master\robot1_description\launch\dis_gmapping.launch
     文件         781  2018-05-10 13:06  ROS-SLAM-Gmapping-master\robot1_description\launch\dis_gmapping.launch~
     文件         536  2018-05-10 13:06  ROS-SLAM-Gmapping-master\robot1_description\launch\display.launch
     文件         535  2018-05-10 13:06  ROS-SLAM-Gmapping-master\robot1_description\launch\display.launch~
     文件         508  2018-05-10 13:06  ROS-SLAM-Gmapping-master\robot1_description\launch\display_state_pub.launch
     文件         508  2018-05-10 13:06  ROS-SLAM-Gmapping-master\robot1_description\launch\state_xacro.launch
     目录           0  2018-05-10 13:06  ROS-SLAM-Gmapping-master\robot1_description\meshes\
     文件       40678  2018-05-10 13:06  ROS-SLAM-Gmapping-master\robot1_description\meshes\bot.dae
     文件       87855  2018-05-10 13:06  ROS-SLAM-Gmapping-master\robot1_description\meshes\hokuyo.dae
     文件        2795  2018-05-10 13:06  ROS-SLAM-Gmapping-master\robot1_description\package.xml
     目录           0  2018-05-10 13:06  ROS-SLAM-Gmapping-master\robot1_description\src\
     文件        3028  2018-05-10 13:06  ROS-SLAM-Gmapping-master\robot1_description\src\state_publisher.cpp
     文件        4735  2018-05-10 13:06  ROS-SLAM-Gmapping-master\robot1_description\urdf.rviz
     目录           0  2018-05-10 13:06  ROS-SLAM-Gmapping-master\robot1_description\urdf\
     文件         268  2018-05-10 13:06  ROS-SLAM-Gmapping-master\robot1_description\urdf\dae.urdf
............此处省略225个文件信息

评论

共有 条评论