Skip to content
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

Merged
merged 14 commits into from
Jul 25, 2018

Conversation

CanyonTurtle
Copy link
Contributor

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.

Copy link

@tfoote tfoote left a 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.

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:
Copy link

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)
Copy link

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 *
Copy link

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__)
Copy link

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
Copy link

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
Copy link

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]: " \
Copy link

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__
Copy link

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

@CanyonTurtle
Copy link
Contributor Author

@tfoote, Thanks for the suggestions. I have removed the unnecessary serial-node script from this subproject and cleaned up the function names, packages, and documentation.

Copy link

@tfoote tfoote left a 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.

# 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)
Copy link

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.
Copy link

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
Copy link

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@romainreignier romainreignier left a 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.

project(rosserial_vex_cortex)

find_package(catkin REQUIRED COMPONENTS
message_generation
Copy link
Contributor

@romainreignier romainreignier Jul 7, 2018

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.

# put the names of custom service files here
# add_service_files(FILES
#
# )
Copy link
Contributor

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.

# generate_messages()

catkin_package(
CATKIN_DEPENDS message_runtime
Copy link
Contributor

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

@@ -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).
Copy link
Contributor

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/

catkin_make install # this will generate folders in the workspace that contain executable scripts.
```

# Usage Example(Linux)
Copy link
Contributor

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)/

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.
Copy link
Contributor

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.

<run_depend>rospy</run_depend>
<run_depend>rosserial_msgs</run_depend>
<run_depend>rosserial_client</run_depend>
<run_depend>message_runtime</run_depend>
Copy link
Contributor

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);
Copy link
Contributor

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:

void setBaud(long baud){
this->baud_= baud;
}

@@ -0,0 +1,43 @@
/*
* rosserial Publisher Example for VEX Cortex
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#include "CortexHardware.h"

namespace ros {
typedef NodeHandle_<CortexHardware, 2, 2, 128, 128> NodeHandle;
Copy link
Contributor

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;

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?

@CanyonTurtle
Copy link
Contributor Author

CanyonTurtle commented Jul 9, 2018

@tfoote @romainreignier,

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 setBaud hardware member function @romainreignier - I think the serial port must be configured in a special part of the VEX Cortex lifecycle, so I neglected this change. See init.cpp).

@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 jade-devel?

Copy link
Contributor

@romainreignier romainreignier left a 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.

@@ -1,6 +1,11 @@
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Changelog for package rosserial_vex_cortex
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.1.1
Copy link
Contributor

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

Copy link
Contributor Author

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).

@CanyonTurtle
Copy link
Contributor Author

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.

@CanyonTurtle
Copy link
Contributor Author

CanyonTurtle commented Jul 10, 2018

@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 jade-devel?

@CanyonTurtle
Copy link
Contributor Author

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.

@CanyonTurtle
Copy link
Contributor Author

@mikeferguson @mikepurvis,

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.

@mikepurvis
Copy link
Member

Looks great! Thanks to all the reviewers who weighed in, and sorry for the long delay.

@mikepurvis mikepurvis merged commit 86e262f into ros-drivers:jade-devel Jul 25, 2018
@mikepurvis
Copy link
Member

Changes have been squashed on merge, so you'll need to rebase your local work.

@CanyonTurtle
Copy link
Contributor Author

CanyonTurtle commented Jul 25, 2018

@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?

@mikepurvis
Copy link
Member

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?

@CanyonTurtle
Copy link
Contributor Author

CanyonTurtle commented Jul 25, 2018

@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.

romainreignier pushed a commit to 1r0b1n0/rosserial that referenced this pull request Nov 7, 2018
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants