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

Added Assisted Teleop feature in Navigation2 #2575

Closed
wants to merge 6 commits into from

Conversation

MOLOCH-dev
Copy link

@MOLOCH-dev MOLOCH-dev commented Sep 29, 2021


Basic Info

Signed-off-by: Anushree Sabnis [email protected]

Info Please fill out this column
Ticket(s) this addresses (add tickets here #2226 )
Primary OS tested on (Ubuntu)
Robotic platform tested on (gazebo simulation of turtlebot3)

Description of contribution in a few bullet points

  • I added Assistive Teleop as a feature in Nav2. It currently takes a Pure Collision Rejection approach to Assistive Teleop, as mentioned in the linked discourse topic.
  • In this, a teleop input velocity command is tested for collisions by projecting its footprint till N seconds in the future
  • If a collision is detected within N seconds, velocity is scaled down so the robot again remains N seconds away from a collision
  • Assisted Teleop is a Recovery Plugin that hosts its own action server
  • Added four new parameters : projection_time, linear_velocity_threshold, input_vel_topic and cmd_vel_topic
  • projection_time : Maximum allowed time to collision (N)
  • linear_velocity_threshold : Upon collision detection within projection_time, if the scaled-down velocity of the robot is below this threshold, the robot is stopped.
  • cmd_vel_topic : Assisted Teleop publishes velocity to this topic.
  • input_vel_topic : Assisted Teleop subscribes to this topic to receive velocity commands

Description of documentation updates required from your changes

  • Added new parameters, so need to add that to default configs and documentation page
  • Need to add documentation for Assisted Teleop, including an example behavior tree configuration

Future work that may be required in bullet points

  • Update README to include Assisted Teleop as a Recovery
  • I need to create a Behaviour Tree Node for Assisted Teleop
  • I need to potentially implement more ways for carrying out Assisted Teleop, exploring a mixture of Pure Collision Avoidance and Rejection approaches.

For Maintainers:

  • Check that any new parameters added are updated in navigation.ros.org
  • Check that any significant change is added to the migration guide
  • Check that any new functions have Doxygen added
  • Check that any new features have test coverage
  • Check that any new plugins is added to the plugins page
  • If BT Node, Additionally: add to BT's XML index of nodes for groot, BT package's readme table, and BT library lists

Signed-off-by: MOLOCH-dev <[email protected]>
Signed-off-by: MOLOCH-dev <[email protected]>
Signed-off-by: MOLOCH-dev <[email protected]>
@SteveMacenski
Copy link
Member

  • scale angular velocities proportionally as well so we follow the same vector of travel
  • handle omni robots

Copy link
Member

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

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

Good first draft, I'll have some more review comments after you fix these, but these are necessary to get into the bigger architectural patterns

nav2_bringup/params/nav2_params.yaml Outdated Show resolved Hide resolved
nav2_recoveries/plugins/assisted_teleop.hpp Outdated Show resolved Hide resolved
std::shared_ptr<tf2_ros::Buffer> tf_;
rclcpp_lifecycle::LifecyclePublisher<geometry_msgs::msg::Twist>::SharedPtr vel_pub_;
rclcpp::Subscription<geometry_msgs::msg::Twist>::SharedPtr vel_sub_;
std::unique_ptr<nav2_costmap_2d::CostmapSubscriber> costmap_sub_;
Copy link
Member

Choose a reason for hiding this comment

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

You should have access to this from the main recovery server / collision checker object. You shouldn't need this?

Copy link
Author

Choose a reason for hiding this comment

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

Could you please guide me as to how I could get access to costmap_sub_ from the collision checker object? Since it is protected in the context of the CostmapTopicCollisionChecker, I'm unable to access the costmap subscriber

Copy link
Member

Choose a reason for hiding this comment

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

Why do you need the costmap sub at all?

Copy link
Author

Choose a reason for hiding this comment

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

I am unable to figure out a way to access the costmap (to use in the getResolution() method for calculating time increments ). Hence, I have retained this block of code in my most recent push. Could you please guide me as to how I can access the costmap object without creating a costmap subscriber?

Copy link
Member

@SteveMacenski SteveMacenski Oct 18, 2021

Choose a reason for hiding this comment

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

You could add a method to get a reference to the costmap subscriber that the CostmapTopicCollisionChecker had internally, and then query that for the resolution. Maybe even have the costmap subscriber specifically store that to pass on in a function so that you don't need to populate a full costmap just to get a piece of metadata

rclcpp::Subscription<geometry_msgs::msg::Twist>::SharedPtr vel_sub_;
std::unique_ptr<nav2_costmap_2d::CostmapSubscriber> costmap_sub_;

// User defined parameters
Copy link
Member

Choose a reason for hiding this comment

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

Put all variables after all functions

Also, some of these look unnecessary (others don't have the correct naming with trailing underscores for member variables)

{
using namespace std::chrono_literals; //NOLINT
void
AssistedTeleop::cleanup()
Copy link
Member

Choose a reason for hiding this comment

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

reorder functions to be: configure, activate, deactivate, cleanup to be in order

nav2_recoveries/plugins/assisted_teleop.cpp Outdated Show resolved Hide resolved
nav2_recoveries/plugins/assisted_teleop.cpp Outdated Show resolved Hide resolved
nav2_recoveries/plugins/assisted_teleop.cpp Outdated Show resolved Hide resolved
nav2_msgs/action/AssistedTeleop.action Outdated Show resolved Hide resolved
nav2_recoveries/plugins/assisted_teleop.cpp Outdated Show resolved Hide resolved
@SteveMacenski
Copy link
Member

Any update?

Signed-off-by: MOLOCH-dev <[email protected]>
@MOLOCH-dev
Copy link
Author

MOLOCH-dev commented Oct 14, 2021

Sorry for being a bit inactive, I was trying to figure out a way around some problems that I have mentioned here : I am done with all but 2 of the requested changes. The ones I am stuck with are the deletion of the costmap_sub_ object I have created to get access to the getResolution method and the velocity transformation from the base frame to the odom frame. I have commented under those requested changes,
I also had a doubt regarding creating the tests for assisted teleop, I have been working on creating a test that is a modification of the current test_recoveries.cpp file. Is that the correct approach? I can push the newly created test for review if that seems correct.

@ros-navigation ros-navigation deleted a comment from mergify bot Oct 15, 2021
@mergify
Copy link
Contributor

mergify bot commented Oct 15, 2021

@MOLOCH-dev, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

node->get_parameter("cmd_vel_topic", cmd_vel_topic_);
node->get_parameter("input_vel_topic", input_vel_topic_);

vel_sub_ = node->create_subscription<geometry_msgs::msg::Twist>(
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be created in execute now? So that its made when requested to start?


protected:
// Clock
rclcpp::Clock steady_clock_{RCL_STEADY_TIME};
Copy link
Member

Choose a reason for hiding this comment

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

Remove, not used

std::string cmd_vel_topic_;
std::string input_vel_topic_;

geometry_msgs::msg::PoseStamped current_pose;
Copy link
Member

Choose a reason for hiding this comment

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

doesn't need to be a class member

geometry_msgs::msg::PoseStamped current_pose;
std::string recovery_name_;
std::shared_ptr<nav2_costmap_2d::Costmap2D> costmap_ros_;
geometry_msgs::msg::TransformStamped transform;
Copy link
Member

Choose a reason for hiding this comment

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

doesn't need to be a class member

geometry_msgs::msg::TransformStamped transform;

// Parameters for Assisted Teleop
double scaling_factor = 1;
Copy link
Member

Choose a reason for hiding this comment

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

doesn't need to be a class member

@SteveMacenski
Copy link
Member

On testing:

  • Create the object and call moveRobot with an example message, verify that it was received on the right topic with the right information based on a changed output velocity parameter
  • Create an example costmap to publish and call computeVelocity to test a few velocity commands, some that should be in collision, which it should back out of, and some that are not, that should be passed through, check the return command
  • Call stopRobot and check works to return on the right topic and 0 call
  • Create a system test to bring up the system in simulation and call the assisted teleop action and test that it works fine / timeout works / no collisions

}

void
AssistedTeleop::vel_callback(const geometry_msgs::msg::Twist::SharedPtr msg)
Copy link
Member

Choose a reason for hiding this comment

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

velCallback()

@ros-navigation ros-navigation deleted a comment from mergify bot Nov 8, 2021
@mergify
Copy link
Contributor

mergify bot commented Nov 18, 2021

This pull request is in conflict. Could you fix it @MOLOCH-dev?

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.

2 participants