前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >机器人实践课程镜像分享及使用说明(Arduino+ROS1+ROS2+Gazebo+SLAM+...)

机器人实践课程镜像分享及使用说明(Arduino+ROS1+ROS2+Gazebo+SLAM+...)

作者头像
zhangrelay
发布2020-08-02 22:20:40
7840
发布2020-08-02 22:20:40
举报
文章被收录于专栏:机器人课程与技术

经过5年尝试和努力,在吸取indigo、kinetic版本经验后,融合Arduino、ROS1、ROS2、Gazebo和SLAM的适用机器人爱好者的实践课程镜像尝鲜版(bug是免不了的!_!)终于完成了。

非常感谢给我宝贵建议的学生、老师以及热心的博客朋友们,祝福大家2020年新春快乐。

留言提出建议和需求一经采纳,就有机会获赠如下小礼物(不要私信哦,太多了,无法回答了,并且其他朋友看不到):

 限量版,只供赠送,内置本文镜像和相关资料。

唯一需要自备的硬件为Arduino及其相关配件:

制作遥控ROS机器人的手柄或IoT物联网传感器 

机器人实践课程镜像分享及使用说明分为6大部分,分别为:

  1. 镜像使用说明
  2. Arduino案例
  3. ROS1案例
  4. ROS2案例
  5. Gazebo案例
  6. SLAM案例

 镜像依据本科课程制作,以项目式案例教学和实践为主,适用上述课程(点击可打开链接,了解详细内容):

分别涵盖在不同时期发布的教学镜像中,经过学生使用、实践和反馈,逐步改进和完善,但由于水平有限和能力不足,依然存在不少问题,可自行研究解决。

第一部分:镜像使用说明

下载链接:https://share.weiyun.com/5yS1hT6 密码:rmxebn

制作iso镜像U盘启动使用rufus-3.8p,可以直接去官网下载,iso镜像文件较大3.54GB。

实践课已经详细讲解过使用方式,需要用管理员权限启动rufus,具体流程如下图所示。

支持legacy和UEFI双模式。

制作速度依据U盘读写速度而定,SLC盘小于2分钟,年代久远的古董盘超过20分钟也正常。

做好后的课程学习盘内部文件如下图所示:

在开机BIOS设置为U盘启动,或者直接快捷方式更改启动顺序设定U盘为先。

此处需注意,legacy和UEFI启动界面略有差异,镜像支持安装:

打开终端,输入$ sudo ubiquity    输入密码:ros

此镜像为个人上课使用,测试时间2018.6-2020.1,用户名为博客名,不喜欢可以随意修改。

测试过10+型号笔记本和台式机,兼容性良好,也有部分电脑需要专业级设置,属于个别案例。

测试截图如下:

  1. U盘系统:

较新配置台式机

较旧配置台式机

  1. U盘镜像:

较新配置笔记本

较旧配置笔记本

Desktop

Arduino

代码语言:javascript
复制
# ROS 1.0 melodic or ROS 2.0 Dashing
echo Hello, ROS 1.0 or ROS 2.0? 1=Melodic 2=Dashing 
read ROS
if (($ROS==1));then
source /opt/ros/melodic/setup.bash
#export ROS_PACKAGE_PATH=/home/relaybot/RobTool/ROS1/Wiki/src:/home/relaybot/RobTool/Cozmo/ros/src:$ROS_PACKAGE_PATH
#source /home/relaybot/RobTool/ROS1/Wiki/devel/setup.bash
#export ROS_MASTER_URI=http://192.168.1.100:11311
#export ROS_IP=192.168.1.100
echo "Melodic"
elif (($ROS==2));then
source /opt/ros/dashing/setup.bash
echo "Dashing"
else
echo "Non-ROS"
fi

# turtlebot3 model env TURTLEBOT3_MODEL  model type [burger, waffle, waffle_pi]" name="model"
export TURTLEBOT3_MODEL=waffle

ROS1+ROS2

Gazebo

SLAM    高翔 等著, 视觉SLAM十四讲:从理论到实践(第2版)

第二部分:Arduino案例

  • AD0-LED13
代码语言:javascript
复制
// These constants won't change. They're used to give names to the pins used:
int i=0,j=0,stime=32,sloop=0;
const int atime=16;
const int analogInPin = A0;  // Analog input pin that the potentiometer is attached to

int sensorValue = 0;        // value read from the pot
int outputValue = 0;        // value output to the PWM (analog out)

void setup() {
  // initialize serial communications at 9600 bps:
  pinMode(LED_BUILTIN, OUTPUT);  
  Serial.begin(9600);
}

void loop() {
  // read the analog in value:
  sensorValue = analogRead(analogInPin);
  // map it to the range of the analog out:
  outputValue = map(sensorValue, 0, 1023, 0, atime);
  // change the analog out value:
  stime=outputValue;
  // print the results to the Serial Monitor:
  //Serial.print("sensor = ");
  //Serial.print(sensorValue);
  //Serial.print("\t output = ");
  //Serial.println(outputValue);
  ledfade(stime);
  // wait 2 milliseconds before the next loop for the analog-to-digital
  // converter to settle after the last reading:
}

void ledfade(int i)
{
      digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(i);                          // wait for a second
      digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
      delay(atime-i);                    // wait for a second
}
  • AD3&4&5-/cmd_vel(ROS)
代码语言:javascript
复制
#if (ARDUINO >= 100)
 #include <Arduino.h>
#else
 #include <WProgram.h>
#endif
#include <ros.h>
#include <rosserial_arduino/Adc.h>
#include <geometry_msgs/Twist.h>

ros::NodeHandle nh;

rosserial_arduino::Adc adc_msg;
geometry_msgs::Twist twist_msg;
ros::Publisher p("adc", &adc_msg);
ros::Publisher t("cmd_vel", &twist_msg); 
//turtlesim turtle1/cmd_vel
//turtlebot3 cmd_vel
//husky cmd_vel
void setup()
{ 
  pinMode(13, OUTPUT);
  nh.initNode();
  nh.advertise(p);
  nh.advertise(t);
}

//We average the analog reading to elminate some of the noise
int averageAnalog(int pin){
  int v=0;
  for(int i=0; i<4; i++) v+= analogRead(pin);
  return v/4;
}

long adc_timer;
int x_mid=600,y_mid=600,x_now=600,y_now=600;
int adc_init=100;
void loop()
{
  adc_msg.adc0 = averageAnalog(0);
  adc_msg.adc1 = averageAnalog(1);
  adc_msg.adc2 = averageAnalog(2);
  adc_msg.adc3 = averageAnalog(3);
  adc_msg.adc4 = averageAnalog(4);
  adc_msg.adc5 = averageAnalog(5);
  x_now=adc_msg.adc5-x_mid;
  y_now=adc_msg.adc4-y_mid;
  adc_init=adc_msg.adc3;
  if(adc_init<10){
    x_mid=adc_msg.adc5;
    y_mid=adc_msg.adc4;
  }
  if(x_now>0)
    twist_msg.linear.x=map(x_now,0,1023-x_mid,0,255);
  else
    twist_msg.linear.x=map(x_now,-x_mid,0,-255,0);
  if(y_now>0)
    twist_msg.angular.z=map(y_now,0,1023-y_mid,0,255);
  else
    twist_msg.angular.z=map(y_now,-y_mid,0,-255,0); 

  twist_msg.linear.x=twist_msg.linear.x/(1024.0-adc_msg.adc0)/4.0;
  twist_msg.angular.z=-twist_msg.angular.z/(1024.0-adc_msg.adc0);
         
  p.publish(&adc_msg);
  t.publish(&twist_msg);
  nh.spinOnce();
//  delay(1);
}

C++&Arduino+ROS


第三部分:ROS1案例

  • turtlesim+action
代码语言:javascript
复制
roscore

rosrun turtlesim turtlesim_node

rosrun turtle_actionlib shape_server

rosrun turtle_actionlib shape_client

rqt_graph
  • turtlebot3+rqt_image_view
代码语言:javascript
复制
roslaunch turtlebot3_gazebo turtlebot3_world.launch

rqt_image_view

第四部分:ROS2案例

  • turtlesim+action+rqt
代码语言:javascript
复制
ros2 run turtlesim turtlesim_node

ros2 run turtlesim turtle_teleop_key

rqt
  • dummy_robot_bringup+rviz2
代码语言:javascript
复制
ros2 launch dummy_robot_bringup dummy_robot_bringup.launch.py

rviz2

demo.rviz

代码语言:javascript
复制
Panels:
  - Class: rviz_common/Displays
    Help Height: 78
    Name: Displays
    Property Tree Widget:
      Expanded:
        - /Global Options1
        - /Status1
      Splitter Ratio: 0.5
    Tree Height: 435
  - Class: rviz_common/Selection
    Name: Selection
  - Class: rviz_common/Tool Properties
    Expanded:
      - /2D Nav Goal1
      - /Publish Point1
    Name: Tool Properties
    Splitter Ratio: 0.5886790156364441
  - Class: rviz_common/Views
    Expanded:
      - /Current View1
    Name: Views
    Splitter Ratio: 0.5
Visualization Manager:
  Class: ""
  Displays:
    - Alpha: 0.5
      Cell Size: 1
      Class: rviz_default_plugins/Grid
      Color: 160; 160; 164
      Enabled: true
      Line Style:
        Line Width: 0.029999999329447746
        Value: Lines
      Name: Grid
      Normal Cell Count: 0
      Offset:
        X: 0
        Y: 0
        Z: 0
      Plane: XY
      Plane Cell Count: 10
      Reference Frame: <Fixed Frame>
      Value: true
    - Alpha: 0.699999988079071
      Class: rviz_default_plugins/Map
      Color Scheme: map
      Draw Behind: false
      Enabled: true
      Name: Map
      Topic: /map
      Unreliable: false
      Use Timestamp: false
      Value: true
    - Alpha: 1
      Autocompute Intensity Bounds: true
      Autocompute Value Bounds:
        Max Value: 10
        Min Value: -10
        Value: true
      Axis: Z
      Channel Name: intensity
      Class: rviz_default_plugins/LaserScan
      Color: 255; 255; 255
      Color Transformer: Intensity
      Decay Time: 0
      Enabled: true
      Invert Rainbow: false
      Max Color: 255; 255; 255
      Max Intensity: 4096
      Min Color: 0; 0; 0
      Min Intensity: 0
      Name: LaserScan
      Position Transformer: XYZ
      Queue Size: 10
      Selectable: true
      Size (Pixels): 3
      Size (m): 0.009999999776482582
      Style: Flat Squares
      Topic: /scan
      Unreliable: false
      Use Fixed Frame: true
      Use rainbow: true
      Value: true
    - Alpha: 1
      Axes Length: 1
      Axes Radius: 0.10000000149011612
      Class: rviz_default_plugins/Pose
      Color: 255; 25; 0
      Enabled: true
      Head Length: 0.30000001192092896
      Head Radius: 0.10000000149011612
      Name: Pose
      Shaft Length: 1
      Shaft Radius: 0.05000000074505806
      Shape: Arrow
      Topic: /move_base_simple/goal
      Unreliable: false
      Value: true
    - Class: rviz_default_plugins/TF
      Enabled: true
      Frame Timeout: 15
      Frames:
        All Enabled: true
      Marker Scale: 1
      Name: TF
      Show Arrows: true
      Show Axes: true
      Show Names: false
      Tree:
        {}
      Update Interval: 0
      Value: true
    - Alpha: 1
      Class: rviz_default_plugins/RobotModel
      Collision Enabled: false
      Description File: ""
      Description Source: Topic
      Description Topic: ""
      Enabled: true
      Links:
        All Links Enabled: true
        Expand Joint Details: false
        Expand Link Details: false
        Expand Tree: false
        Link Tree Style: ""
      Name: RobotModel
      TF Prefix: ""
      Unreliable: false
      Update Interval: 0
      Value: true
      Visual Enabled: true
  Enabled: true
  Global Options:
    Background Color: 48; 48; 48
    Fixed Frame: world
    Frame Rate: 30
  Name: root
  Tools:
    - Class: rviz_default_plugins/MoveCamera
    - Class: rviz_default_plugins/Select
    - Class: rviz_default_plugins/FocusCamera
    - Class: rviz_default_plugins/Measure
      Line color: 128; 128; 0
    - Class: rviz_default_plugins/SetInitialPose
      Topic: /initialpose
    - Class: rviz_default_plugins/SetGoal
      Topic: /move_base_simple/goal
    - Class: rviz_default_plugins/PublishPoint
      Single click: true
      Topic: /clicked_point
  Transformation:
    Current:
      Class: rviz_default_plugins/TF
  Value: true
  Views:
    Current:
      Class: rviz_default_plugins/Orbit
      Distance: 8.303964614868164
      Enable Stereo Rendering:
        Stereo Eye Separation: 0.05999999865889549
        Stereo Focal Distance: 1
        Swap Stereo Eyes: false
        Value: false
      Focal Point:
        X: 0.5349314212799072
        Y: -1.8630497455596924
        Z: 0.5543326139450073
      Focal Shape Fixed Size: true
      Focal Shape Size: 0.05000000074505806
      Invert Z Axis: false
      Name: Current View
      Near Clip Distance: 0.009999999776482582
      Pitch: 0.7453981041908264
      Target Frame: <Fixed Frame>
      Value: Orbit (rviz)
      Yaw: 1.8422259092330933
    Saved: ~
Window Geometry:
  Displays:
    collapsed: false
  Height: 664
  Hide Left Dock: false
  Hide Right Dock: true
  QMainWindow State: 000000ff00000000fd0000000400000000000001560000023efc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d0000023e000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f0000023efc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073000000003d0000023e000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004420000003efc0100000002fb0000000800540069006d00650100000000000004420000000000000000fb0000000800540069006d00650100000000000004500000000000000000000002a40000023e00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
  Selection:
    collapsed: false
  Tool Properties:
    collapsed: false
  Views:
    collapsed: true
  Width: 1024
  X: 0
  Y: 27

第五部分:Gazebo案例

代码语言:javascript
复制
ros2 topic pub /demo/cmd_demo geometry_msgs/Twist '{linear: {x: 0.2}}' -1

第六部分:SLAM案例

高翔 等著, 视觉SLAM十四讲:从理论到实践(第2版)

 ROS:~$ tree -L 3

代码语言:javascript
复制
.
├── Arduino
│   ├── course
│   │   ├── ADCdemo
│   │   ├── AnalogInOutLEDdemo
│   │   ├── AnalogInOutLEDtimedemo
│   │   ├── AnalogInputdemo
│   │   ├── Blinkdemo
│   │   ├── blinkmicrosdemo
│   │   ├── Buttondemo
│   │   ├── Controldemo
│   │   ├── Controlplusdemo
│   │   ├── Controlplusdemo2
│   │   ├── DHTtesterDemo
│   │   ├── dueControldemo
│   │   ├── HCSR04demo
│   │   ├── Knobdemo
│   │   ├── motordemo
│   │   ├── robotdemo
│   │   └── tonePitchFollowerdemo
│   └── libraries
│       ├── Adafruit_Circuit_Playground
│       ├── Adafruit_Unified_Sensor
│       ├── DHT_sensor_library
│       ├── readme.txt
│       ├── Rosserial_Arduino_Library
│       └── SD
├── Desktop
│   └── demo.rviz
├── Documents
│   ├── Arduino
│   │   ├── imutovel.py
│   │   ├── Integrating Arduino-Based Educational Mobile Robots in ROS.pdf
│   │   ├── LabLecture3 Hardware interfacing Arduino.pdf
│   │   ├── note191125.md
│   │   ├── Programming Your First Robot - EE100 Fall 2016.pdf
│   │   └── 机器人控制器编程-总结篇.pdf
│   └── Fritzing
│       ├── bins
│       └── parts
├── Downloads
│   ├── android_camera_imu.apk
│   ├── pinguybuilder_5.1-8_all.deb
│   ├── pycozmo-master.zip
│   └── slambook2-master.zip
├── Music
├── Pictures
│   ├── Screenshot from 2020-01-07 14-44-21.png
│   ├── Screenshot from 2020-01-07 14-51-44.png
│   ├── Screenshot from 2020-01-07 14-55-28.png
│   ├── Screenshot from 2020-01-07 14-56-49.png
│   ├── Screenshot from 2020-01-07 15-05-16.png
│   ├── Screenshot from 2020-01-07 15-18-33.png
│   ├── Screenshot from 2020-01-07 15-54-15.png
│   ├── Screenshot from 2020-01-07 15-57-50.png
│   ├── Screenshot from 2020-01-07 16-08-05.png
│   ├── Screenshot from 2020-01-07 16-26-15.png
│   └── Wallpapers
│       └── ubunturobot.png
├── Public
├── Roft
│   ├── arduino
│   │   └── arduino-1.8.10
│   ├── cozmo_ros2_ws
│   │   ├── build
│   │   ├── install
│   │   ├── log
│   │   └── src
│   ├── Micro-XRCE-DDS-Agent
│   │   ├── agent.refs
│   │   ├── build
│   │   ├── cmake
│   │   ├── CMakeLists.txt
│   │   ├── CTestJenkins.cmake
│   │   ├── Dockerfile
│   │   ├── docs
│   │   ├── include
│   │   ├── LICENSE
│   │   ├── microxrce_agent.cpp
│   │   ├── README.md
│   │   ├── src
│   │   ├── test
│   │   ├── thirdparty
│   │   ├── utils
│   │   └── valgrind.supp
│   ├── opencv-4.1.2
│   │   ├── 3rdparty
│   │   ├── apps
│   │   ├── build
│   │   ├── cmake
│   │   ├── CMakeLists.txt
│   │   ├── CONTRIBUTING.md
│   │   ├── data
│   │   ├── doc
│   │   ├── include
│   │   ├── LICENSE
│   │   ├── modules
│   │   ├── platforms
│   │   ├── README.md
│   │   └── samples
│   └── tello_ros2_ws
│       ├── build
│       ├── install
│       ├── log
│       └── src
├── SLAM
│   └── slambook2
│       ├── ch10
│       ├── ch11
│       ├── ch12
│       ├── ch13
│       ├── ch2
│       ├── ch3
│       ├── ch4
│       ├── ch5
│       ├── ch6
│       ├── ch7
│       ├── ch8
│       ├── ch9
│       ├── errata.cls
│       ├── errata.pdf
│       ├── errata.tex
│       ├── figures
│       ├── LICENSE
│       └── README.md
├── Templates
└── Videos

2020-01-07

~Fin~

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020/01/07 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 非常感谢给我宝贵建议的学生、老师以及热心的博客朋友们,祝福大家2020年新春快乐。
  • 机器人实践课程镜像分享及使用说明分为6大部分,分别为:
    • 第一部分:镜像使用说明
      • 第二部分:Arduino案例
        • 第三部分:ROS1案例
          • 第四部分:ROS2案例
            • 第五部分:Gazebo案例
              • 第六部分:SLAM案例
              相关产品与服务
              对象存储
              对象存储(Cloud Object Storage,COS)是由腾讯云推出的无目录层次结构、无数据格式限制,可容纳海量数据且支持 HTTP/HTTPS 协议访问的分布式存储服务。腾讯云 COS 的存储桶空间无容量上限,无需分区管理,适用于 CDN 数据分发、数据万象处理或大数据计算与分析的数据湖等多种场景。
              领券
              问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档