tested class PubInfo complete.
This commit is contained in:
@@ -260,6 +260,10 @@ target_include_directories(PubData_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/includ
|
||||
target_link_libraries(PubData_lib ${catkin_LIBRARIES})
|
||||
add_dependencies(PubData_lib main_generate_messages_cpp)
|
||||
|
||||
add_library(PubInfo_lib ${CMAKE_CURRENT_SOURCE_DIR}/src/PubInfo.cpp)
|
||||
target_include_directories(PubInfo_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
target_link_libraries(PubInfo_lib ${catkin_LIBRARIES})
|
||||
add_dependencies(PubInfo_lib main_generate_messages_cpp)
|
||||
##################
|
||||
|
||||
add_library(formation_lib ${CMAKE_CURRENT_SOURCE_DIR}/src/formation.cpp)
|
||||
@@ -279,7 +283,7 @@ add_dependencies(mission_lib main_generate_messages_cpp)
|
||||
|
||||
##################
|
||||
add_executable(main src/main.cpp)
|
||||
target_link_libraries(main ${catkin_LIBRARIES} mission_lib)
|
||||
target_link_libraries(main ${catkin_LIBRARIES} mission_lib PubInfo_lib)
|
||||
add_dependencies(main class_model_generate_messages_cpp)
|
||||
|
||||
################json test
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef INFO_H
|
||||
#define INFO_H
|
||||
|
||||
#include<std/string.hpp>
|
||||
#include<std_msgs/String.h>
|
||||
|
||||
typedef struct flight_INFO
|
||||
{
|
||||
@@ -11,4 +11,4 @@ typedef struct flight_INFO
|
||||
|
||||
|
||||
|
||||
#endif INFO_H
|
||||
#endif //INFO_H
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "class_model/mission.h"
|
||||
#include "class_model/choose_leader.h"
|
||||
#include "class_model/PubData.h"
|
||||
#include "class_model/PubInfo.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
@@ -17,7 +17,7 @@ int main(int argc, char **argv) {
|
||||
MissionClass mission_object;
|
||||
CommandClass command_object;
|
||||
SelectClass select_formation;
|
||||
PubDataClass PubData_object;
|
||||
PubInfoClass PubInfo_object;
|
||||
|
||||
// SelectionClass selection_object;
|
||||
|
||||
@@ -30,11 +30,16 @@ int main(int argc, char **argv) {
|
||||
// selection_object.choose_leader();
|
||||
// mission_object.start(); //default hover in goose formation
|
||||
|
||||
INFO msg;
|
||||
msg.type = "V_formation";
|
||||
msg.mission = "fly2target";
|
||||
|
||||
while(ros::ok()){
|
||||
|
||||
|
||||
//json_object.get_command(); //for follower
|
||||
select_formation.goose_formation();
|
||||
//select_formation.goose_formation();
|
||||
PubInfo_object.pub_info(msg);
|
||||
}
|
||||
|
||||
ros::waitForShutdown();
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
#!/usr/bin/env python3
|
||||
#coding:utf-8
|
||||
import rospy
|
||||
from mavros_msgs.msg import Waypoint
|
||||
# from mavros_msgs.msg import Waypoint
|
||||
from diagnostic_msgs.msg import KeyValue
|
||||
|
||||
def callBack(data):
|
||||
print (data.param1)
|
||||
print (data)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
nodeName = 'subscriber_py'
|
||||
rospy.init_node(nodeName)
|
||||
topicName = '/DroneStatus'
|
||||
subscriber = rospy.Subscriber(topicName,Waypoint,callBack) #從topic獲取string再呼叫callback
|
||||
topicName = '/Flight_Information_reciver'
|
||||
subscriber = rospy.Subscriber(topicName,KeyValue,callBack) #從topic獲取string再呼叫callback
|
||||
rospy.spin()
|
||||
Reference in New Issue
Block a user