Go to the documentation of this file.00001
00034 #include <ros/ros.h>
00035 #include <geometry_msgs/Twist.h>
00036 #include <md49_serialport/md49_serialport.h>
00037 #include <md49_messages/md49_data.h>
00038 #include <md49_messages/md49_encoders.h>
00039 #include "md49_base_controller/md49_base_controller_class.h"
00040
00041 int main( int argc, char* argv[] ){
00042
00043
00044
00045
00046 ros::init(argc, argv, "base_controller" );
00047 BaseController myBaseController;
00048 ros::Rate loop_rate(10);
00049 ROS_INFO("base_controller: base_controller running...");
00050
00051
00052
00053
00054 myBaseController.open_serialport();
00055
00056
00057
00058
00059 myBaseController.init_md49(myBaseController.get_requested_speed_l(), myBaseController.get_requested_speed_r(), myBaseController.get_initial_md49_mode(), \
00060 myBaseController.get_initial_md49_acceleration(), myBaseController.get_initial_md49_timeout(), myBaseController.get_initial_md49_regulator());
00061
00062
00063
00064
00065 while(myBaseController.n.ok())
00066 {
00067
00068 if ((myBaseController.get_requested_speed_l() != myBaseController.get_actual_speed_l()) || (myBaseController.get_requested_speed_r() != myBaseController.get_actual_speed_r()))
00069 {
00070 myBaseController.set_speed(myBaseController.get_requested_speed_l(),myBaseController.get_requested_speed_r());
00071 myBaseController.set_actual_speed_l(myBaseController.get_requested_speed_l());
00072 myBaseController.set_actual_speed_r(myBaseController.get_requested_speed_r());
00073 ROS_INFO("base_controller: Set speed_l=%i and speed_r=%i on MD49", myBaseController.get_requested_speed_l(), myBaseController.get_requested_speed_r());
00074 }
00075
00076 myBaseController.publish_encoders();
00077
00078 myBaseController.publish_md49_data();
00079
00080 ros::spinOnce();
00081 loop_rate.sleep();
00082 }
00083 return 1;
00084 }
00085