Go to the documentation of this file.00001 #include <string>
00002 #include "ros/ros.h"
00003 #include "std_msgs/String.h"
00004 #include "tinycan/CanMsg.h"
00005 #include "multicar_hydraulic_core.h"
00006 #include "sensor_msgs/JointState.h"
00007 #include "sensor_msgs/JointState.h"
00008
00009 using std::string;
00010
00011 int main (int argc, char **argv)
00012 {
00013 hydraulic::Hydraulic *hydev = new hydraulic::Hydraulic();
00014 int rate = 10;
00015 string pub_topic_raw;
00016 string pub_topic_js;
00017 string sub_topic_raw;
00018 string sub_topic_robot_trajectory;
00019
00020 ros::init(argc, argv, "multicar_hydraulic");
00021
00022 ros::NodeHandle n;
00023
00024
00025 ros::NodeHandle private_node_handle_("~");
00026 private_node_handle_.param("rate", rate, int(50));
00027 private_node_handle_.param("pub_topic_raw", pub_topic_raw, string("/can_raw_send"));
00028 private_node_handle_.param("sub_topic_raw", sub_topic_raw, string("/can_raw_receive"));
00029 private_node_handle_.param("sub_topic_robot_trajectory", sub_topic_robot_trajectory, string("/move_group/fake_controller_joint_states"));
00030 private_node_handle_.param("pub_topic_jointstate", pub_topic_js, string("/joint_states"));
00031
00032
00033 ros::Publisher pub_can_message = n.advertise<tinycan::CanMsg>(pub_topic_raw.c_str(), 50);
00034
00035 ros::Publisher pub_joint_state_message = n.advertise<sensor_msgs::JointState>(pub_topic_js.c_str(), 50);
00036
00037 ros::Subscriber sub_robot_trajectory = n.subscribe(sub_topic_robot_trajectory.c_str(), 1000, &hydraulic::Hydraulic::callbackRobotTrajectory, hydev);
00038
00039 ros::Subscriber sub_raw_message = n.subscribe(sub_topic_raw.c_str(), 1000, &hydraulic::Hydraulic::callbackCanMessageRaw, hydev);
00040
00041 hydev->init();
00042
00043
00044 hydev->setCanMsgPublisher(&pub_can_message);
00045 hydev->setJointStatePublisher(&pub_joint_state_message);
00046
00047 ros::Duration(1.5).sleep();
00048 hydev->cmdToCanMessage("boot",0x7F);
00049 hydev->cmdToCanMessage("boot",0x7D);
00050 hydev->cmdToCanMessage("boot",0x7E);
00051
00052 ros::Rate loop_rate(rate);
00053
00054 while (ros::ok()) {
00055
00056 hydev->checkTask();
00057 ros::spinOnce();
00058 loop_rate.sleep();
00059 }
00060 return 0;
00061 }