Parse URDF file from ros_robot class#144
Conversation
|
|
||
| void enterSafeState() override; | ||
|
|
||
| urdf::Model model_; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Agreed.
I'm looking into footprint to see what we can do.
| protected: | ||
| rclcpp::Node * node_; | ||
|
|
||
| const char * urdf_file_; |
There was a problem hiding this comment.
I'd prefer to use std::string instead of char *. You can always get the char * using urdf_file_.c_str().
| @@ -23,6 +24,17 @@ RosRobot::RosRobot(rclcpp::Node * node) | |||
| : node_(node), initial_pose_received_(false) | |||
| { | |||
| // Open and parser the URDF file | |||
There was a problem hiding this comment.
Just noticed a typo here that you could fix while you're in this file ("parser" should be "parse").
|
|
||
| int main(int argc, char ** argv) | ||
| { | ||
| try { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
| rclcpp::shutdown(); | ||
|
|
||
| return 0; | ||
| } catch(std::exception& e) { |
There was a problem hiding this comment.
There's no return statement when catching the exception. Main will exit without a return statement.
| void enterSafeState() override; | ||
|
|
||
| geometry_msgs::msg::PoseWithCovarianceStamped::SharedPtr getCurrentPose(); | ||
| bool getCurrentPose(geometry_msgs::msg::PoseWithCovarianceStamped::SharedPtr & robot_pose); |
There was a problem hiding this comment.
@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; |
There was a problem hiding this comment.
Don't think we should return 0 on a failure.
| return 0; | ||
| return 0; | ||
| } catch (std::exception & e) { | ||
| RCLCPP_ERROR(rclcpp::get_logger("simple_navigator"), e.what()); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
mjeronimo
left a comment
There was a problem hiding this comment.
Remove the unimplemented getFootprint method and fix the typo.
mkhansenbot
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Please file an issue for any 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"); |
There was a problem hiding this comment.
Can we change the RCLCPP_INFO messages here to something useful, like "Pose Received" or change this to a RCLCPP_DEBUG message
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Agreed. This should be RCLCPP_WARN. Will fix it.
| @@ -0,0 +1,29 @@ | |||
| robot: | |||
There was a problem hiding this comment.
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.
mkhansenbot
left a comment
There was a problem hiding this comment.
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.
* added to the BT XML list * tilte underline * added to the full navigation plugin list * Migration
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