-
Notifications
You must be signed in to change notification settings - Fork 526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-attempting rosserial for VEX Cortex #380
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this is much cleaner. I have a bunch of smaller style and cleanup suggestions. There's also a few places that look like they're ripe for adding/improving reuse. Those might be worth deferring for another PR.
Also depending on the thoughts of maintainers we could work in a branch in parallel with master to be less disruptive as we iterate on Vex support.
rosserial_vex_cortex/README.md
Outdated
3. PROS - [install PROS toolchain](https://github.com/purduesigbots/pros/releases/tag/2.12.1) | ||
|
||
# Setup | ||
Stup a ROS workspace and build rosserial packages (including rosserial_vex_cortex) from source: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo s/Stup/Setup/
rospack = rospkg.RosPack() | ||
|
||
# copy ros_lib stuff in | ||
rosserial_cortex_dir = rospack.get_path(THIS_PACKAGE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this script is a duplicate of the one in rosserial_arduino. Except for the THIS_PACKAGE variable. It might be a good candidate for parameterizing and deduplicating in the future.
|
||
import rospkg | ||
import rosserial_client | ||
from rosserial_client.make_library import * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Importing * is a bad practice. I know it's done in the other version, but explicitly calling the things out make it much easier to debug.
|
||
namespace ros | ||
{ | ||
// #if defined(__AVR_ATmega8__) or defined(__AVR_ATmega168__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should clean out these commented values that are from the other verison.
Also above.
@@ -0,0 +1,85 @@ | |||
#!/usr/bin/env python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not use this file from another instance/location? I don't see any local modifications.
// 1 for yes | ||
#define DEBUG_MODE 0 | ||
|
||
// apply a macro to all args of a variadic macro, used for logg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These old commented versions should be cleaned up.
// will print to uart2. | ||
// Use screen to access uart2 on the terminal with a serial-usb adapter+cable | ||
// on device USB0 at 115200 baud: screen /dev/ttyUSB0 115200 | ||
#define loggy(fmtstr, ...) fprintf((uart2), "[%d]: " \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The names of these functions should be cleaned up too.
@@ -0,0 +1,51 @@ | |||
#ifndef __CANNON_LOGGER_H__ | |||
#define __CANNON_LOGGER_H__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include guards should be PACKAGE_NAME_FILE_NAME_H
format. http://wiki.ros.org/CppStyleGuide
@tfoote, Thanks for the suggestions. I have removed the unnecessary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks much better. Just a few more comments.
rosserial_vex_cortex/README.md
Outdated
# Requirements | ||
1. Linux (Only tested on Ubuntu 18.04LTS) | ||
2. ROS (Only tested on ROS Melodic) - [installation guide](http://wiki.ros.org/melodic/Installation/Source). | ||
3. PROS - [installation guide](tps://github.com/purduesigbots/pros/releases/tag/2.12.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broken link and it says installation gude, but points to the tarball.
#include <ros.h> | ||
#include <std_msgs/String.h> | ||
|
||
// run continuously by the setup function, publishes the time at 50hz. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is out of date.
|
||
#include "API.h" | ||
|
||
// Use screen to access uart2 on the terminal with a serial-usb adapter+cable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation of the debug port would be good to add as a block in the README.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new PR seems in a good shape to me.
Nonetheless, I have added a few minor comments, mostly cosmetic fixes in the README.
But I have a concern about the number of MAX_SUBSCRIBERS and MAX_PUBLISHERS. 2 seems very low to me.
rosserial_vex_cortex/CMakeLists.txt
Outdated
project(rosserial_vex_cortex) | ||
|
||
find_package(catkin REQUIRED COMPONENTS | ||
message_generation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No message is generated so this dependency is not needed.
rosserial_vex_cortex/CMakeLists.txt
Outdated
# put the names of custom service files here | ||
# add_service_files(FILES | ||
# | ||
# ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same apply for this commented lines, they are not needed.
rosserial_vex_cortex/CMakeLists.txt
Outdated
# generate_messages() | ||
|
||
catkin_package( | ||
CATKIN_DEPENDS message_runtime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And also this dependency is not used
rosserial_vex_cortex/README.md
Outdated
@@ -0,0 +1,88 @@ | |||
# rosserial for VEX Cortex | |||
|
|||
This package contains everything needed allow you 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). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/needed allow/needed to allow/
rosserial_vex_cortex/README.md
Outdated
catkin_make install # this will generate folders in the workspace that contain executable scripts. | ||
``` | ||
|
||
# Usage Example(Linux) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Example(Linux)/Example (Linux)/
rosserial_vex_cortex/README.md
Outdated
to view the UART | ||
|
||
# Limitations | ||
Global scope causes segmentation faults. Do not try to use global scope. ROS-related objects in the global scope causes segmentation faults. The cause of this is still unknown, but it may have something to do with the implementation of the global memory segment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first and third sentences are quite similar (only "ROS-related objects" differ). Maybe a reworking would help to clarify.
Maybe something like:
Global scope variables causes segmentation faults. Unlike in the other rosserial
examples, avoid ROS objects in the global scope.
rosserial_vex_cortex/package.xml
Outdated
<run_depend>rospy</run_depend> | ||
<run_depend>rosserial_msgs</run_depend> | ||
<run_depend>rosserial_client</run_depend> | ||
<run_depend>message_runtime</run_depend> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned earlier, does not seems useful.
// any initialization code necessary to use the serial port | ||
void init() { | ||
// uart2 is for debugging, while stdout is initialized automatically. | ||
usartInit(uart2, 115200, SERIAL_8N1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually in rosserial
, the default baudrate is 57600.
And the hardware class can offer a method to change it, see rosserial_arduino
:
rosserial/rosserial_arduino/src/ros_lib/ArduinoHardware.h
Lines 88 to 90 in fe1e233
void setBaud(long baud){ | |
this->baud_= baud; | |
} |
@@ -0,0 +1,43 @@ | |||
/* | |||
* rosserial Publisher Example for VEX Cortex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible, move the examples to a separate folder like in rosserial_arduino
: https://github.com/ros-drivers/rosserial/tree/fe1e233f39d56931b5e223c5e53a2d9c2f9fb664/rosserial_arduino/src/ros_lib/examples
#include "CortexHardware.h" | ||
|
||
namespace ros { | ||
typedef NodeHandle_<CortexHardware, 2, 2, 128, 128> NodeHandle; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first two template arguments are the max number of subscribers and publishers;
rosserial/rosserial_client/src/ros_lib/ros/node_handle.h
Lines 99 to 104 in fe1e233
template<class Hardware, | |
int MAX_SUBSCRIBERS = 25, | |
int MAX_PUBLISHERS = 25, | |
int INPUT_SIZE = 512, | |
int OUTPUT_SIZE = 512> | |
class NodeHandle_ : public NodeHandleBase_ |
Are you really limiting the users of the default version of rosserial_vex_cortex
to use a maximum of two subscribers and two publishers?
Thanks for the continued feedback. I was able to slim the package even more, and I fleshed out the documentation for setting up and configuring the serial connection, and touched it up overall. I also followed every suggestion here (except the @romainreignier I also reset the publisher and subscriber counts to their defaults. The numbers being so low last time was leftover from my testing. Thanks for the find! One topic of discussion: should I create a new branch for continued development of this package in coming weeks, or should I make future potential PRs on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About the branch, I am not sure, but if you don't touch any other rosserial
packages, it should be ok to stay with jade-devel
.
But for these kind of questions, maybe @mikepurvis can answer.
rosserial_vex_cortex/CHANGELOG.rst
Outdated
@@ -1,6 +1,11 @@ | |||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |||
Changelog for package rosserial_vex_cortex | |||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |||
0.1.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that all rosserial
packages should have the same version number so it should be 0.7.7. But I may be wrong. See with @mikepurvis
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, about to re-commit because my commit broke the building (oops).
Oop, just re-added a couple files and dependencies, I broke the vex cortex build process with the last commit. This one is tested and working. |
@mikepurvis, what do you think of this PR? I think it is in good condition to accept. This version of rosserial_vex_cortex is self-contained and documented in-package, and has been closely reviewed by @tfoote and @romainreignier. As I alluded to before, I intend to add further documentation and some additional examples to this package. For that purpose, do you think I should branch off, or stay on |
Note @mikepurvis : Right now, I am continually developing this package, but this version is stable. To facilitate continued development, I will leave this PR as is, for reviewing purposes, and I will branch off of my own fork for the continued changes I am working on for a separate PR later. |
Would you please tell me what you think of this additional hardware support? I am looking to get this through because I have commits that build off of this. I also have VEX V5 support, which is a brand-new platform that will be used by thousands of VEX Robotics teams in the coming few years. |
Looks great! Thanks to all the reviewers who weighed in, and sorry for the long delay. |
Changes have been squashed on merge, so you'll need to rebase your local work. |
@mikepurvis Thanks!! I will promptly rebase and follow up with more content - as I said, I have also ported the cutting-edge VEX V5 Robot Brain microcontroller, and I have tweaked this package slightly. Do you think it would be okay to put the new V5, and tweaks to this one, in one PR? or shall I split them up? |
I'm easy-going on that kind of thing. If you have a lot stuff and/or expect to be iterating on this over time, would it make sense to simply add you as a maintainer of the rosserial repo so you can merge your own changes upon review? |
@mikepurvis I would appreciate that :) thanks! That would be convenient, especially because I am about to open a PR for V5/updated cortex work. Just rebased my fork's jade-devel as you said, and it is ready to go. |
…am to jade-devel * commit 'a707373c7e9f9ad40ad9440550840e29960c9290': Changed hardcoded pin 13 to LED_BUILTIN (ros-drivers#328) Re-attempting rosserial for VEX Cortex (ros-drivers#380) Added service to force an Arduino hard reset in serial_node.py (ros-drivers#349) Fix compiling on boost > 1.66 (ros-drivers#362) Use the ! prefix introduced in gcc4mbed for mbed examples (ros-drivers#304) Add support for boolean parameters (ros-drivers#355) Change Travis to use clang-5.0.0 (ros-drivers#363) [python] fix an unboundlocalerror (ros-drivers#346) Added ESP32 support (ros-drivers#345) Retry opening the serial port every 3 seconds (ros-drivers#342) In rosserial_arduino, changed embedded type size for ROS uint64 to 8 bytes from 4. (ros-drivers#312) 0.7.7 Changes Copy src/examples to install dir so make_libraries.py doesn't fail (ros-drivers#336) Add overall spin timeout to rosserial read. (ros-drivers#334) Fixing formatting on files. (ros-drivers#333) Fix catkin lint errors (ros-drivers#296)
Overview
The added package,
rosserial_vex_cortex
, allows the user to use rosserial on the VEX Cortex, ontop of the PROS kernel.This is a re-attempt at #378, based on feedback from @romainreignier and @tfoote .
This time the added project is self-contained, has no unneeded PROS project files, and allows the user to generate PROS projects and install the rosserial libraries automatically (see README.md).
Limitations
Only tested on Linux 18.04LTS + ros melodic, relies on bash script.