Skip to content

Parse URDF file from ros_robot class#144

Merged
mhpanah merged 9 commits intoros-navigation:masterfrom
mhpanah:robot
Oct 15, 2018
Merged

Parse URDF file from ros_robot class#144
mhpanah merged 9 commits intoros-navigation:masterfrom
mhpanah:robot

Conversation

@mhpanah
Copy link
Copy Markdown
Contributor

@mhpanah mhpanah commented Oct 5, 2018

Open and parse URDF file from ros_robot class. Once the URDF file is parsed, the robot description can be obtained from "model_".

Currently getCurrentPose, getCurrentVelocity, getRobotName, and sendVelocity methods have been implemented.

getCurrentVelocity method gets odometry msg which contains both twist and pose. getCurrentPose method gets pose msg which is estimated from localization module. To make this less confusing, I will open another PR to rename the getCurrentVelocity method to getOdometry and also rename the getCurrentPose to getCurrentEstimatedPose.

TODO(mhpanah):

  • getFootPrint()

  • robot types and SN or ID

  • Add unit and integration test

  • Be able to configure which topic name to subscribe to

@mhpanah mhpanah added this to the October 2018 milestone Oct 5, 2018
@mhpanah mhpanah self-assigned this Oct 5, 2018
@mhpanah mhpanah requested review from a user, bpwilcox, mjeronimo and mkhansenbot October 5, 2018 22:12

void enterSafeState() override;

urdf::Model model_;
Copy link
Copy Markdown

@mjeronimo mjeronimo Oct 5, 2018

Choose a reason for hiding this comment

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

This should be a protected member variable. There should be public methods used to access the data held in the model. For example, you could add a getFootprint() method that other code could use to get the robot footprint.

Update: I see you mentioned that the footprint is in the yaml file. Can we add to the URDF to include it there?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed.
I'm looking into footprint to see what we can do.

protected:
rclcpp::Node * node_;

const char * urdf_file_;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'd prefer to use std::string instead of char *. You can always get the char * using urdf_file_.c_str().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@@ -23,6 +24,17 @@ RosRobot::RosRobot(rclcpp::Node * node)
: node_(node), initial_pose_received_(false)
{
// Open and parser the URDF file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just noticed a typo here that you could fix while you're in this file ("parser" should be "parse").

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.


int main(int argc, char ** argv)
{
try {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't want to diverge this file from all of the other main.cpp's. If we want to catch exceptions at the top, we should do it for all of them. Let's discuss as a group.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, we should discuss this. Actually Me and Carl were thinking to bring this up on Monday for discussion.

int main(int argc, char ** argv)
{
try {
rclcpp::init(argc, argv);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Indentation isn't right here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

rclcpp::shutdown();

return 0;
} catch(std::exception& e) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There's no return statement when catching the exception. Main will exit without a return statement.

@mhpanah mhpanah closed this Oct 10, 2018
@mhpanah mhpanah reopened this Oct 11, 2018
void enterSafeState() override;

geometry_msgs::msg::PoseWithCovarianceStamped::SharedPtr getCurrentPose();
bool getCurrentPose(geometry_msgs::msg::PoseWithCovarianceStamped::SharedPtr & robot_pose);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@mhpanah @crdelsey
What's the rationale to prefer a success/failure return code in this case versus an exception? We should be consistent with our error handling mechanisms, if possible, and I thought we were preferring exceptions. That is, we'd introduce specific exception types instead of using the generic ones, such as runtime_error.

return 0;
} catch (std::exception & e) {
RCLCPP_ERROR(rclcpp::get_logger("simple_navigator"), e.what());
return 0;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Don't think we should return 0 on a failure.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's right. :)

return 0;
return 0;
} catch (std::exception & e) {
RCLCPP_ERROR(rclcpp::get_logger("simple_navigator"), e.what());
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't recommend using the logger name of the simple navigator module here as a string literal. This introduces a dependency on the name defined somewhere else (the name is duplicated and prone to getting out of sync). It also isn't good form, in my opinion, to write to other module's loggers. I think we should use the name of this module since it caught the exception. Perhaps this means that we do still need the logging at the source throwing the exception so that it appears in that module's log.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Per our discussion, I will remove handling the exception for now to be consistent with other main files.

RosRobot::getFootPrint()
{
}
// TODO(mhpanah): modify this method name and implementation to inclue robot types and Serial # (ID)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Typo: "inclue" -> include

Copy link
Copy Markdown

@mjeronimo mjeronimo left a comment

Choose a reason for hiding this comment

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

Remove the unimplemented getFootprint method and fix the typo.

Copy link
Copy Markdown
Collaborator

@mkhansenbot mkhansenbot left a comment

Choose a reason for hiding this comment

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

A few small changes needed, and the turtlebot urdf and yaml files need to be removed.

geometry_msgs::msg::PoseWithCovarianceStamped::SharedPtr getCurrentPose();
bool getCurrentPose(geometry_msgs::msg::PoseWithCovarianceStamped::SharedPtr & robot_pose);
bool getCurrentVelocity(nav_msgs::msg::Odometry::SharedPtr & robot_velocity);
// TODO(mhpanah): implement getFootPrint method
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please file an issue for any TODO's

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Opened #163 to address all the TODO's.

RosRobot::onPoseReceived(const geometry_msgs::msg::PoseWithCovarianceStamped::SharedPtr msg)
{
RCLCPP_INFO(node_->get_logger(), "RosRobot::onPoseReceved");
RCLCPP_INFO(node_->get_logger(), "RosRobot::onPoseReceived");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we change the RCLCPP_INFO messages here to something useful, like "Pose Received" or change this to a RCLCPP_DEBUG message

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think we should we just remove this message or change it to RCLCPP_DEBUG.

RosRobot::getCurrentVelocity(nav_msgs::msg::Odometry::SharedPtr & robot_velocity)
{
if (!initial_odom_received_) {
RCLCPP_INFO(node_->get_logger(), "initial odom not received yet");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we improve this message to something like "Can't return current velocity: Initial odometry not yet received". Also, should this be an RCLCPP_WARN() instead of an INFO, or this OK if it occurs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. This should be RCLCPP_WARN. Will fix it.

@@ -0,0 +1,29 @@
robot:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Turtlebot files (urdf and yaml) shouldn't be in this repo. If they're needed for testing they should be pulled in at launch time from their packages.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Copy Markdown
Collaborator

@mkhansenbot mkhansenbot left a comment

Choose a reason for hiding this comment

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

I think you have extra quotes in one of the strings, and you need to rebase because it's showing merge conflicts due to other PRs having been merged.

Copy link
Copy Markdown
Collaborator

@mkhansenbot mkhansenbot left a comment

Choose a reason for hiding this comment

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

Looks good now 👍

@mhpanah mhpanah merged commit d0a2f6e into ros-navigation:master Oct 15, 2018
mini-1235 pushed a commit to mini-1235/navigation2 that referenced this pull request Feb 5, 2025
* added to the BT XML list

* tilte underline

* added to the full navigation plugin list

* Migration
Forsyth-Creations pushed a commit to Forsyth-Creations/navigation2 that referenced this pull request Feb 19, 2025
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.

3 participants