forked from Archive/PX4-Autopilot
Fixes for manual bridge generation
Fix for some forgot .cxx extensions Fix for 'print' python 2 3 compatibility Fix for topic ID type change
This commit is contained in:
parent
c05ea542d9
commit
c5e2745a19
|
@ -74,8 +74,8 @@ if len(sys.argv) <= 1:
|
|||
# Parse arguments
|
||||
args = parser.parse_args()
|
||||
msg_folder = get_absolute_path(args.msgdir)
|
||||
msg_files_send = args.send
|
||||
msg_files_receive = args.receive
|
||||
msg_files_send = [get_absolute_path(msg) for msg in args.send]
|
||||
msg_files_receive = [get_absolute_path(msg) for msg in args.receive]
|
||||
agent = args.agent
|
||||
client = args.client
|
||||
del_tree = args.del_tree
|
||||
|
@ -162,22 +162,22 @@ def generate_agent(out_dir):
|
|||
# Final steps to install agent
|
||||
mkdir_p(agent_out_dir + "/fastrtpsgen")
|
||||
os.chdir(agent_out_dir + "/fastrtpsgen")
|
||||
for idl_file in glob.glob( agent_out_dir + "/idl/*.idl"):
|
||||
ret = os.system(fastrtpsgen_path + " -example x64Linux2.6gcc " + idl_file)
|
||||
for idl_file in glob.glob(agent_out_dir + "/idl/*.idl"):
|
||||
ret = subprocess.call(fastrtpsgen_path + " -d " + agent_out_dir + "/fastrtpsgen -example x64Linux2.6gcc " + idl_file, shell=True)
|
||||
if ret:
|
||||
raise Exception("fastrtpsgen not found. Specify the location of fastrtpsgen with the -f flag")
|
||||
|
||||
rm_wildcard(agent_out_dir + "/fastrtpsgen/*PubSubMain.cpp")
|
||||
rm_wildcard(agent_out_dir + "/fastrtpsgen/*PubSubMain*")
|
||||
rm_wildcard(agent_out_dir + "/fastrtpsgen/makefile*")
|
||||
rm_wildcard(agent_out_dir + "/fastrtpsgen/*Publisher*")
|
||||
rm_wildcard(agent_out_dir + "/fastrtpsgen/*Subscriber*")
|
||||
for f in glob.glob(agent_out_dir + "/fastrtpsgen/*.cxx"):
|
||||
os.rename(f, f.replace(".cxx", ".cpp"))
|
||||
cp_wildcard(agent_out_dir + "/fastrtpsgen/*", agent_out_dir)
|
||||
if os.path.isdir(agent_out_dir + "/fastrtpsgen"):
|
||||
shutil.rmtree(agent_out_dir + "/fastrtpsgen")
|
||||
cp_wildcard(urtps_templates_dir + "/microRTPS_transport.*", agent_out_dir)
|
||||
os.rename(agent_out_dir + "/microRTPS_agent_CMakeLists.txt", agent_out_dir + "/CMakeLists.txt")
|
||||
mkdir_p(agent_out_dir + "/build")
|
||||
|
||||
return 0
|
||||
|
||||
def rm_wildcard(pattern):
|
||||
|
|
|
@ -165,7 +165,7 @@ def generate_idl_file(filename_msg, outputdir, templatedir, includepath):
|
|||
def generate_uRTPS_general(filename_send_msgs, filename_received_msgs,
|
||||
outputdir, templatedir, includepath, template_name):
|
||||
"""
|
||||
Generates source file by UART msg content
|
||||
Generates source file by msg content
|
||||
"""
|
||||
em_globals_list = []
|
||||
if filename_send_msgs:
|
||||
|
|
|
@ -84,18 +84,18 @@ ORB_DEFINE(@multi_topic, struct @uorb_struct, @(struct_size-padding_end_size),
|
|||
@{
|
||||
|
||||
def print_info(field):
|
||||
print "type: ", field.type, "name: ", field.name, "base_type: ", \
|
||||
print("type: ", field.type, "name: ", field.name, "base_type: ", \
|
||||
field.base_type, "field.is_array:", ('0', '1')[field.is_array], " array_len: ", field.array_len, \
|
||||
"is_builtin:", ('0', '1')[field.is_builtin], "is_header:", ('0', '1')[field.is_header]
|
||||
"is_builtin:", ('0', '1')[field.is_builtin], "is_header:", ('0', '1')[field.is_header])
|
||||
|
||||
def print_level_info(fields):
|
||||
for field in fields:
|
||||
print_info(field)
|
||||
if (not field.is_builtin):
|
||||
print "\n"
|
||||
print("\n")
|
||||
children_fields = get_children_fields(field.base_type, search_path)
|
||||
print_level_info(children_fields)
|
||||
print "\n"
|
||||
print("\n")
|
||||
|
||||
def walk_through_parsed_fields():
|
||||
print_level_info(spec.parsed_fields())
|
||||
|
@ -111,9 +111,9 @@ def add_serialize_functions(fields, scope_name):
|
|||
if (not field.is_header):
|
||||
if (field.is_builtin):
|
||||
if (not field.is_array):
|
||||
print "\tserialize"+str(get_serialization_type_name(field.type))+"(input->"+scope_name+str(field.name)+", microCDRWriter);"
|
||||
print("\tserialize"+str(get_serialization_type_name(field.type))+"(input->"+scope_name+str(field.name)+", microCDRWriter);")
|
||||
else:
|
||||
print "\tserialize"+str(get_serialization_type_name(field.base_type))+"Array(input->"+scope_name+str(field.name)+", "+str(field.array_len)+", microCDRWriter);"
|
||||
print("\tserialize"+str(get_serialization_type_name(field.base_type))+"Array(input->"+scope_name+str(field.name)+", "+str(field.array_len)+", microCDRWriter);")
|
||||
else:
|
||||
name = field.name
|
||||
children_fields = get_children_fields(field.base_type, search_path)
|
||||
|
@ -129,10 +129,10 @@ def add_deserialize_functions(fields, scope_name):
|
|||
if (not field.is_header):
|
||||
if (field.is_builtin):
|
||||
if (not field.is_array):
|
||||
print "\tdeserialize"+str(get_serialization_type_name(field.type))+"(&output->"+scope_name+str(field.name)+", microCDRReader);"
|
||||
print("\tdeserialize"+str(get_serialization_type_name(field.type))+"(&output->"+scope_name+str(field.name)+", microCDRReader);")
|
||||
else:
|
||||
for i in xrange(field.array_len):
|
||||
print "\tdeserialize"+str(get_serialization_type_name(field.base_type))+"(&output->"+scope_name+str(field.name)+ str('[%d]' %i) +", microCDRReader);"
|
||||
print("\tdeserialize"+str(get_serialization_type_name(field.base_type))+"(&output->"+scope_name+str(field.name)+ str('[%d]' %i) +", microCDRReader);")
|
||||
else:
|
||||
name = field.name
|
||||
children_fields = get_children_fields(field.base_type, search_path)
|
||||
|
|
|
@ -83,7 +83,7 @@ bool RtpsTopics::init()
|
|||
}
|
||||
|
||||
@[if send_topics]@
|
||||
void RtpsTopics::publish(char topic_ID, char data_buffer[], size_t len)
|
||||
void RtpsTopics::publish(uint8_t topic_ID, char data_buffer[], size_t len)
|
||||
{
|
||||
switch (topic_ID)
|
||||
{
|
||||
|
@ -106,7 +106,7 @@ void RtpsTopics::publish(char topic_ID, char data_buffer[], size_t len)
|
|||
@[end if]@
|
||||
@[if recv_topics]@
|
||||
|
||||
bool RtpsTopics::hasMsg(char *topic_ID)
|
||||
bool RtpsTopics::hasMsg(uint8_t *topic_ID)
|
||||
{
|
||||
if (nullptr == topic_ID) return false;
|
||||
|
||||
|
@ -134,7 +134,7 @@ bool RtpsTopics::hasMsg(char *topic_ID)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool RtpsTopics::getMsg(const char topic_ID, eprosima::fastcdr::Cdr &scdr)
|
||||
bool RtpsTopics::getMsg(const uint8_t topic_ID, eprosima::fastcdr::Cdr &scdr)
|
||||
{
|
||||
bool ret = false;
|
||||
switch (topic_ID)
|
||||
|
|
|
@ -64,11 +64,11 @@ class RtpsTopics {
|
|||
public:
|
||||
bool init();
|
||||
@[if send_topics]@
|
||||
void publish(char topic_ID, char data_buffer[], size_t len);
|
||||
void publish(uint8_t topic_ID, char data_buffer[], size_t len);
|
||||
@[end if]@
|
||||
@[if recv_topics]@
|
||||
bool hasMsg(char *topic_ID);
|
||||
bool getMsg(const char topic_ID, eprosima::fastcdr::Cdr &scdr);
|
||||
bool hasMsg(uint8_t *topic_ID);
|
||||
bool getMsg(const uint8_t topic_ID, eprosima::fastcdr::Cdr &scdr);
|
||||
@[end if]@
|
||||
|
||||
private:
|
||||
|
|
|
@ -229,7 +229,7 @@ int main(int argc, char** argv)
|
|||
int received = 0, loop = 0;
|
||||
int length = 0, total_read = 0;
|
||||
bool receiving = false;
|
||||
char topic_ID = 255;
|
||||
uint8_t topic_ID = 255;
|
||||
std::chrono::time_point<std::chrono::steady_clock> start, end;
|
||||
@[end if]@
|
||||
|
||||
|
|
|
@ -61,9 +61,9 @@ def get_idl_type_name(field_type):
|
|||
def add_msg_field(field):
|
||||
if (not field.is_header):
|
||||
if (not field.is_array):
|
||||
print '\t' + str(get_idl_type_name(field.type)) + ' ' + field.name + ';'
|
||||
print('\t' + str(get_idl_type_name(field.type)) + ' ' + field.name + ';')
|
||||
else:
|
||||
print '\t' + str(get_idl_type_name(field.base_type)) + ' ' + field.name + '[' +str(field.array_len)+ '];'
|
||||
print('\t' + str(get_idl_type_name(field.base_type)) + ' ' + field.name + '[' +str(field.array_len)+ '];')
|
||||
|
||||
def add_msg_fields():
|
||||
# sort fields (using a stable sort) as in the declaration of the type
|
||||
|
|
|
@ -31,10 +31,13 @@
|
|||
#
|
||||
############################################################################
|
||||
|
||||
find_program(FASTRTPSGEN fastrtpsgen)
|
||||
if(NOT FASTRTPSGEN)
|
||||
message(WARNING "WARNING: Unable to find fastrtpsgen")
|
||||
set(GENERATE_RTPS_BRIDGE off)
|
||||
if(NOT GENERATE_RTPS_BRIDGE MATCHES "off")
|
||||
find_program(FASTRTPSGEN fastrtpsgen
|
||||
PATHS $ENV{FASTRTPSGEN_DIR})
|
||||
if(NOT FASTRTPSGEN)
|
||||
message(WARNING "WARNING: Unable to find fastrtpsgen")
|
||||
set(GENERATE_RTPS_BRIDGE off)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(GENERATE_RTPS_BRIDGE MATCHES "off")
|
||||
|
@ -79,28 +82,28 @@ else()
|
|||
if (NOT "${config_rtps_send_topics}" STREQUAL "" OR NOT "${config_rtps_receive_topics}" STREQUAL "")
|
||||
set(topic_bridge_files_out microRTPS_client.cpp microRTPS_transport.cpp microRTPS_transport.h)
|
||||
|
||||
set(send_topic_files_opt)
|
||||
if (NOT "${send_topic_files}" STREQUAL "")
|
||||
set(send_topic_opt "-s")
|
||||
endif()
|
||||
set(send_topic_files_opt)
|
||||
if (NOT "${send_topic_files}" STREQUAL "")
|
||||
set(send_topic_opt "-s")
|
||||
endif()
|
||||
|
||||
set(receive_topic_files_opt)
|
||||
if (NOT "${receive_topic_files}" STREQUAL "")
|
||||
set(receive_topic_opt "-r")
|
||||
endif()
|
||||
set(receive_topic_files_opt)
|
||||
if (NOT "${receive_topic_files}" STREQUAL "")
|
||||
set(receive_topic_opt "-r")
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT ${topic_bridge_files_out}
|
||||
COMMAND ${PYTHON_EXECUTABLE}
|
||||
${PX4_SOURCE_DIR}/Tools/generate_microRTPS_bridge.py
|
||||
-f $ENV{FASTRTPSGEN_DIR}
|
||||
${send_topic_opt} ${send_topic_files}
|
||||
${receive_topic_opt} ${receive_topic_files}
|
||||
-t ${topic_msg_path}
|
||||
-u ${msg_out_path}
|
||||
DEPENDS ${DEPENDS} ${send_topic_files} ${receive_topic_files}
|
||||
COMMENT "Generating RTPS topic bridge"
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_command(OUTPUT ${topic_bridge_files_out}
|
||||
COMMAND ${PYTHON_EXECUTABLE}
|
||||
${PX4_SOURCE_DIR}/Tools/generate_microRTPS_bridge.py
|
||||
-f $ENV{FASTRTPSGEN_DIR}
|
||||
${send_topic_opt} ${send_topic_files}
|
||||
${receive_topic_opt} ${receive_topic_files}
|
||||
-t ${topic_msg_path}
|
||||
-u ${msg_out_path}
|
||||
DEPENDS ${DEPENDS} ${send_topic_files} ${receive_topic_files}
|
||||
COMMENT "Generating RTPS topic bridge"
|
||||
VERBATIM
|
||||
)
|
||||
endif()
|
||||
|
||||
px4_add_module(
|
||||
|
|
Loading…
Reference in New Issue