Login
Account
Sign Up
Home
About Us
Catalog
Search
Register RSS
Embed RSS
FAQ
Get Embed Code
Example: Default CSS
Example: Custom CSS
Example: Custom CSS per Embedding
Super RSS
Usage
View Latest
Create
Contact Us
Technical Support
Guest Posts/Articles
Report Violations
Google Warnings
Article Removal Requests
Channel Removal Requests
General Questions
DMCA Takedown Notice
RSSing>>
Collections:
RSSing
EDA
Intel
Mesothelioma
SAP
SEO
Latest
Articles
Channels
Super Channels
Popular
Articles
Pages
Channels
Super Channels
Top Rated
Articles
Pages
Channels
Super Channels
Trending
Articles
Pages
Channels
Super Channels
Switch Editions?
Cancel
Sharing:
Title:
URL:
Copy Share URL
English
RSSing.com
RSSing>>
Latest
Popular
Top Rated
Trending
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
NSFW?
Claim
0
X
Mark channel Not-Safe-For-Work?
cancel
confirm
NSFW Votes:
(
0
votes)
X
Are you the publisher?
Claim
or
contact us
about this channel.
X
0
Showing article 3 of 4 in channel 80159215
Channel Details:
Title: ROS Answers: Open Source Q&A Forum - RSS feed
Channel Number: 80159215
Language: English
Registered On: May 1, 2024, 6:53 pm
Number of Articles: 4
Latest Snapshot: May 9, 2024, 11:25 am
RSS URL:
http://answers.ros.org/feeds/question/205364/
Publisher:
https://answers.ros.org/questions/
Description: Open source question and answer forum written in Python and Django
Catalog:
//answers13765.rssing.com/catalog.php?indx=80159215
Remove ADS
Viewing all articles
Article 1
Article 2
Article 3
Article 4
Browse latest
Browse all 4
↧
Answer by Novinho for I want to move my turtlebot 2 a fixed set of distances such as 1m forward, 1m right and etc accurately using odometry. This is the C++ code i have currently. However, it does not seem to be using the odometry. How should I change the code to enable myself to move the robot accurately ?Below is the code that I currently have. What it does is enable me to move the turtlebot as well as received odometry data on the console. class TurtleMoveAvoid; class TurtleMoveAvoid { public: TurtleMoveAvoid() { _pub = _n.advertise<geometry_msgs::Twist>("/mobile_base/commands/velocity", 1); _sub = _n.subscribe("/odom", 1, &TurtleMoveAvoid::odomCallback, this); _left = true; _right = true; } void publish() { if (_left && _right) { forward(); } else if (_right) { turnRight(); } else if (_left) { turnLeft(); } else { reverse(); } } void forward() { geometry_msgs::Twist vel; vel.linear.x = 0.2; vel.angular.z = 0.0; _pub.publish(vel); } void reverse() { geometry_msgs::Twist vel; vel.linear.x = -0.2; vel.angular.z = 0.0; _pub.publish(vel); } void turnLeft() { geometry_msgs::Twist vel; vel.linear.x = 0.0; vel.angular.z = 0.7; _pub.publish(vel); } void turnRight() { geometry_msgs::Twist vel; vel.linear.x = 0.0; vel.angular.z = -0.7; _pub.publish(vel); } void odomCallback(const nav_msgs::Odometry::ConstPtr& odom) { ROS_INFO("I received odom: [%f,%f,%f]", odom->twist.twist.linear.x, odom->pose.pose.position.y,odom->pose.pose.orientation.z); double xpos = odom->twist.twist.linear.x; if(xpos < 0.2) //assuming 0.2 is the end { _right = true; _left = true; } else { _right = false; _left = false; } publish(); } private: ros::NodeHandle _n; ros::Publisher _pub; ros::Subscriber _sub; bool _right, _left; };// End of class TurtleMoveAvoid int main(int argc, char **argv) { ros::init(argc, argv, "turtle_move_odom"); TurtleMoveAvoid turtle; ros::Rate loop_rate(10); while (ros::ok()) { ros::spinOnce(); //get new callback, adjust publish then publish again. loop_rate.sleep(); } return 0; }
April 4, 2016, 10:34 am
≫
Next: Navigation of turtlebot (Moving 1m forward, 1m left)
≪
Previous: Answer by Humpelstilzchen for I want to move my turtlebot 2 a fixed set of distances such as 1m forward, 1m right and etc accurately using odometry. This is the C++ code i have currently. However, it does not seem to be using the odometry. How should I change the code to enable myself to move the robot accurately ?Below is the code that I currently have. What it does is enable me to move the turtlebot as well as received odometry data on the console. class TurtleMoveAvoid; class TurtleMoveAvoid { public: TurtleMoveAvoid() { _pub = _n.advertise<geometry_msgs::Twist>("/mobile_base/commands/velocity", 1); _sub = _n.subscribe("/odom", 1, &TurtleMoveAvoid::odomCallback, this); _left = true; _right = true; } void publish() { if (_left && _right) { forward(); } else if (_right) { turnRight(); } else if (_left) { turnLeft(); } else { reverse(); } } void forward() { geometry_msgs::Twist vel; vel.linear.x = 0.2; vel.angular.z = 0.0; _pub.publish(vel); } void reverse() { geometry_msgs::Twist vel; vel.linear.x = -0.2; vel.angular.z = 0.0; _pub.publish(vel); } void turnLeft() { geometry_msgs::Twist vel; vel.linear.x = 0.0; vel.angular.z = 0.7; _pub.publish(vel); } void turnRight() { geometry_msgs::Twist vel; vel.linear.x = 0.0; vel.angular.z = -0.7; _pub.publish(vel); } void odomCallback(const nav_msgs::Odometry::ConstPtr& odom) { ROS_INFO("I received odom: [%f,%f,%f]", odom->twist.twist.linear.x, odom->pose.pose.position.y,odom->pose.pose.orientation.z); double xpos = odom->twist.twist.linear.x; if(xpos < 0.2) //assuming 0.2 is the end { _right = true; _left = true; } else { _right = false; _left = false; } publish(); } private: ros::NodeHandle _n; ros::Publisher _pub; ros::Subscriber _sub; bool _right, _left; };// End of class TurtleMoveAvoid int main(int argc, char **argv) { ros::init(argc, argv, "turtle_move_odom"); TurtleMoveAvoid turtle; ros::Rate loop_rate(10); while (ros::ok()) { ros::spinOnce(); //get new callback, adjust publish then publish again. loop_rate.sleep(); } return 0; }
$
0
0
Hi, dylankc. Did you solve this problem?... If yes, how could you do that? Thanks
↧
Search
RSSing.com
Remove ADS
Viewing all articles
Article 1
Article 2
Article 3
Article 4
Browse latest
Browse all 4
Search
RSSing.com
© 2025 //www.rssing.com
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>