Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some fixes #7714

Merged
merged 1 commit into from
Aug 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Tools/generate_microRTPS_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def get_absolute_path(arg_parse_dir):
# 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
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion Tools/px_generate_uorb_topic_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 8 additions & 8 deletions msg/templates/uorb/msg.cpp.template
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions msg/templates/urtps/RtpsTopics.cpp.template
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;

Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions msg/templates/urtps/RtpsTopics.h.template
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion msg/templates/urtps/microRTPS_agent.cpp.template
Original file line number Diff line number Diff line change
Expand Up @@ -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]@

Expand Down
4 changes: 2 additions & 2 deletions msg/templates/urtps/msg.idl.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 27 additions & 24 deletions src/modules/micrortps_bridge/micrortps_client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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(
Expand Down