Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <ros/ros.h>
- #include <geometry_msgs/Twist.h>
- const std::string NODE_NAME = "driveBase_multiBots";
- class RobotDriver {
- private:
- ros::NodeHandle nh_;
- ros::Publisher cmd_vel_pub_;
- public:
- RobotDriver(ros::NodeHandle &nh) {
- nh_ = nh;
- cmd_vel_pub_ = nh_.advertise<geometry_msgs::Twist
- //> ("/base_controller/command", 1); // Topic 'base_controller' works only for 'base'.
- //>("crowd1/turtlebot_node/cmd_vel", 1);
- >("crowd1/turtlebot_node/cmd_vel", 1000);
- //>("/turtlebot_node/cmd_vel", 1);
- }
- void runDemoScenario() {
- sleep(2); // To avoid error upon instantiating.
- geometry_msgs::Twist base_cmd;
- base_cmd.linear.x = base_cmd.linear.y = base_cmd.angular.z = 0; // init
- base_cmd.linear.y = 10.25; //arbitrary value for testing purpose only.
- cmd_vel_pub_.publish(base_cmd);
- sleep(10); // Only to have ample time to look at rxgraph :P
- }
- };
- int main(int argc, char** argv) {
- ros::init(argc, argv, NODE_NAME);
- ros::NodeHandle nh;
- RobotDriver driver(nh);
- driver.runDemoScenario();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement