diffdrive_robot.cpp
Go to the documentation of this file.
1 #include <ros/ros.h>
4 
5 int main(int argc, char **argv)
6 {
7  ros::init(argc, argv, "real_robot");
8  ros::NodeHandle n("~");
9 
10  RealRobot::Config robot_cfg;
11 
12  // Attempt to retrieve parameters. If they don't exist, the default values from the struct will be used
13  n.getParam("left_wheel_name", robot_cfg.left_wheel_name);
14  n.getParam("right_wheel_name", robot_cfg.right_wheel_name);
15  n.getParam("baud_rate", robot_cfg.baud_rate);
16  n.getParam("device", robot_cfg.device);
17  n.getParam("enc_counts_per_rev", robot_cfg.enc_counts_per_rev);
18  n.getParam("robot_loop_rate", robot_cfg.loop_rate);
19 
20 
21  RealRobot robot(robot_cfg);
23 
24  ros::AsyncSpinner spinner(1);
25  spinner.start();
26 
27  ros::Time prevTime = ros::Time::now();
28 
29  ros::Rate loop_rate(10);
30 
31  while (ros::ok())
32  {
33  robot.read();
34  cm.update(robot.get_time(), robot.get_period());
35  robot.write();
36 
37  loop_rate.sleep();
38  }
39 }
std::string left_wheel_name
Definition: real_robot.h:17
std::string device
Definition: real_robot.h:20
const ros::Duration & get_period()
Definition: real_robot.h:56
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void read()
Definition: real_robot.cpp:49
int main(int argc, char **argv)
bool getParam(const std::string &key, std::string &s) const
ROSCPP_DECL bool ok()
std::string right_wheel_name
Definition: real_robot.h:18
bool sleep()
static Time now()
void write()
Definition: real_robot.cpp:72
void update(const ros::Time &time, const ros::Duration &period, bool reset_controllers=false)
const ros::Time & get_time()
Definition: real_robot.h:55


diffdrive_arduino
Author(s): Josh Newans
autogenerated on Mon Feb 28 2022 22:13:39