# rosserial for VEX Cortex
This package contains everything needed to run rosserial on the [VEX Cortex](https://www.vexrobotics.com/276-2194.html), on the [PROS Kernel](https://pros.cs.purdue.edu/cortex/index.html).
# Requirements
- Software:
1. Linux (Only tested on Ubuntu 18.04LTS) (possible on windows with a Linux virtual machine, provided there is USB support)
2. ROS installed on Linux (Only tested on ROS Melodic) - [installation guide](http://wiki.ros.org/melodic/Installation/Source).
3. PROS installed on Linux - [installation guide](https://pros.cs.purdue.edu/cortex/getting-started/index.html)
- Hardware:
1. VEX essentials:
- VEX Cortex
- VEX Joystick
- VEXnet keys
- VEX Competition battery
- VEX Programming Cable
2. (optional, for debugging) a [USB-serial adapter](https://www.adafruit.com/product/954)
3. (optional, for debugging) Three Male-Male jumper wires for USB-serial adapter
# Table Of Contents
- [Setup](#setup)
- [Examples](#examples)
- [Hello World Example](#hello-world-example)
- [Keyboard or Android Phone Driving Example](#keyboard-or-android-driving-example)
- [Alternative Joystick Example](#alternative-joystick-example)
- [Physical Serial Connections](#physical-serial-connections)
- [Generating Custom Messages](#generating-custom-messages)
- [Limitations](#limitations)
- [Speed](#speed)
- [Troubleshooting](#troubleshooting)
# Setup
This setup requires knowledge of entering commands into a Linux terminal.
Note: it is possible to follow along with this guide without understanding basic ROS constructs
(such as workspaces, projects, rosrun, roslaunch, and catkin_make). However, in order to work
with ROS beyond the examples in this project, you will need to learn about the ROS framework itself. See the
[ROS documentation, getting-started, and tutorials pages](http://wiki.ros.org/) for more information.
### ROS Workspace
This workspace is used to generate a PROS project, and then help the Cortex interact with ROS using that generated project.
Notice the first `source` command below. This includes ROS commands into the terminal (such as catkin_make), so it will come first in
most of the terminal commands in this setup process. Make sure you replace `melodic` with your corresponding ROS version name, if it
is not `melodic` (e.g. `kinetic`).
Open up a terminal, and enter:
```bash
source /opt/ros/melodic/setup.bash
mkdir -p ~/ros-vex-workspace/src; cd ~/ros-vex-workspace/src
git clone https://github.com/ros-drivers/rosserial.git
cd ..; catkin_make; catkin_make install
```
Next, generate a PROS project, which has the code that runs on the Cortex.
The project can exist anywhere (it does NOT need to be inside the ROS workspace).
```bash
source ~/ros-vex-workspace/install/setup.bash
rosrun rosserial_vex_cortex genscript.sh ~/path/to/prosproject
```
# Examples
These examples are made to run out-of-the-box, and they made to be proof-of-concepts of what ROS can provide.
ROS allows standardized messages to be sent to and from the Cortex and an outside computer, which allows for all kinds
of ideas and projects to be organized with messages!
To understand what is going on with the example code, look at the tutorials for the sister project, [Rosserial Arduino](http://wiki.ros.org/rosserial_arduino/Tutorials).
There are some differences between the two projects (namely, in the PROS c++ code, [global scope is not allowed](#limitations)).
Set up the physical download connection by plugging in
the VEX Programming cable to the computer and the joystick, and then pluging the VEXnet keys into the Cortex and the joystick.
This connection serves as BOTH the downloading channel AND the serial connection, so leave the
programming cable plugged in! (to alter the connection to use something else, see [physical serial connections](#physical-serial-connections)).
Between downloads, power-cycle the Joystick and Cortex for optimal usage.
## Hello World Example
```bash
source ~/your-workspace-name/install/setup.bash
cd ~/path/to/prosproject
pros make upload; roslaunch rosserial_vex_cortex hello_world.launch
```
If everything is working properly, you should see "hello world" messages in the terminal!
## Keyboard or Android Driving Example
This example showcases an integrated demo with a VEX EDR Robot, such as the [clawbot](https://www.vexrobotics.com/276-2600.html), and an alternative method of control: a keyboard!
Open up "src/twistdrive.cpp" and modify the motor control code, to specify how you want to control your robot's drive .
Modify `src/opcontrol.cpp` in your generated PROS project to include the `twistdrive.cpp` file instead of the `helloworld.cpp` file. Then, open a terminal and run the following:
```bash
source ~/your-workspace-name/install/setup.bash
cd /path/to/prosproject
pros make clean; pros make upload; roslaunch rosserial_vex_cortex minimal_robot.launch
```
Android phones can now control this robot.
Download this [ROS Map Navigation](https://play.google.com/store/apps/details?id=com.github.rosjava.android_apps.map_nav.kinetic) app.
Configure the app to connect to your computer, and you can now drive your robot with a phone!
For keyboard input instead, install the keyboard twist publisher: http://wiki.ros.org/teleop_twist_keyboard
Run the following in another terminal:
```bash
source /opt/ros/melodic/setup.bash
rosrun teleop_twist_keyboard teleop_twist_keyboard.py
```
Now, you can use the keys listed in the command to drive the robot!
## Alternative Joystick Example
This is for using an alternative joystick, such as a Logitech Wireless Gamepad F710 or a PS3 controller.
This controlling example is extensibile: anything publishing a [sensor_msgs/Joy message](http://wiki.ros.org/sensor_msgs) can control your VEX robot,
so feel free to program your own controller!
Open up `src/joydrive.cpp` and make modifications to make this demo work on your robot.
Modify `src/opcontrol.cpp` in your generated PROS project to include the `joydrive.cpp` file instead of the `helloworld.cpp` file. Then, open a terminal and run the following:
```bash
cd /path/to/prosproject
pros make upload
roslaunch rosserial_vex_cortex joystick.launch
```
Now, you can use the alternative joystick to control the robot!
# Physical Serial Connections
The optimal setup for this project is with two physical serial connections, one for rosserial to function, and one for debugging. The default connection for rosserial is the VEX Programming Cable, and the default debugging serial connection is UART2.
Since the The VEX programming cable provides the default rosserial connection, the baud rate of the ROS serial connecting node must be 115200 Hz, which is why the command reads:
This overrides the default (57600) Hz. To switch the rosserial/debug serial connections, see `include/ros_lib/logger.h` in your generated PROS project.
If you do end up using UART1 or UART2 for rosserial instead of debugging,
open the `launch/` directory (which is inside the ROS workspace in `src/rosserial/rosserial_vex_cortex`).
Inside `launch/minimal_robot.launch`, update the `mainport` USB device argument to be `/dev/ttyUSB0`,
and update the `mainbaud` argument to be `57600`.
There are also `debugport` and `debugbaud` arguments in the launchfile, which are unused for now but can be used for project generation later.
Also, the USB device path for the VEX Programming cable on Linux may either be `/dev/ttyACM0` or `/dev/ttyACM1`. To figure out which to use as an argument, use `pros lsusb`, or unplug/replug the cable from/into the computer and run `dmesg` and look at the last lines. Usually, unplugging the programming cable for 10 seconds and then re-plugging it should revert
the device back to `/dev/ttyUSB0`
Viewing the UART debug stream requires a [USB-serial adapter](https://www.adafruit.com/product/954) for your computer, and it needs to be plugged in correctly.
To set up the wires with the cable linked above, use this layout:
[layout](./uartdiagram.
m0_74689786
- 粉丝: 1
- 资源: 2
最新资源
- 基于JAVA的社团管理系统的设计与实现-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 基于spring boot的小型诊疗预约平台的设计与开发-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.rar
- 引入注意力机制的resnet鸟类识别
- 毕业设计A048-基于Java的抗疫物资管理系统的设计与实现
- 433JSP基于SpringMVC+Hibernate自动补货商品采购系统毕业课程源码设计+论文资料
- Java毕业设计图书推荐系统源码+数据库(高分毕业设计项目).zip
- MATLAB仿真轴棱锥产生贝塞尔高斯光束 以及环形光束光强图像
- B双馈风电机组仿真,matlab simulink仿真源文件,有详细报告说明书,双馈风力发电机仿真,风力发电机仿真,风力发电控制系统仿真
- 基于YOLOv8的红领巾目标检测项目源码+模型文件+文档说明(高分项目)
- SpringBoot+Vue测评系统及部署教程
- gige vision协议工业相机采图及存储实现,gvcp相机控制通道实现,gvsp流通道实现,千兆以太网实现以及ddr3控制器实现 代码已经用于实际工程,纯Verilog开发实现
- Qt实现使用QAxObject在word中实现文本替换和插入图片
- ABS模型 汽车制动防抱死模型ABS模型 基于MATLAB Simulink搭建电动汽车直线abs模型,相关模型文件可为初学者提供便利,有详细的建模过程,有Word说明文件
- (嵌入式毕设)实验室环境检测-主要是多个传感器组成的检测小项目,主要检测多种气体,当出现气体超标等危险情况是,进行实时报警与通风
- 基于高频HF注入的永磁同步电机PMSM 无速度传感器矢量控制仿真模型 Matlab Simulink仿真(成品)
- TEE:多CA调用同一个TA的迸发场景
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈