public static string GetMessageClassPath(string inFilePath, string outPath)
        {
            string rosPackageName = MessageAutoGen.GetRosPackageName(inFilePath);
            string outFolder      = MessageAutoGen.GetMessageOutFolder(outPath, rosPackageName);
            string extension      = Path.GetExtension(inFilePath);
            string className      = MsgAutoGenUtilities.CapitalizeFirstLetter(Path.GetFileNameWithoutExtension(inFilePath));

            return(Path.Combine(outFolder, "msg", className + ".cs"));
        }
Esempio n. 2
0
        public static string[] GetActionClassPaths(string inFilePath, string outPath)
        {
            string rosPackageName = MessageAutoGen.GetRosPackageName(inFilePath);
            string outFolder      = MessageAutoGen.GetMessageOutFolder(outPath, rosPackageName);
            string extension      = Path.GetExtension(inFilePath);
            string className      = MsgAutoGenUtilities.CapitalizeFirstLetter(Path.GetFileNameWithoutExtension(inFilePath)) + MsgAutoGenUtilities.ActionClassSuffix;

            string[] result = new string[types.Length];
            for (int Idx = 0; Idx < types.Length; ++Idx)
            {
                result[Idx] = Path.Combine(outFolder, "action", className + types[Idx] + ".cs");
            }
            return(result);
        }
        public static List <string> GenerateSingleService(string inPath, string outPath, string rosPackageName = "", bool verbose = false)
        {
            // If no ROS package name is provided, extract from path
            if (rosPackageName.Equals(""))
            {
                rosPackageName = MessageAutoGen.GetRosPackageName(inPath);
            }

            outPath = Path.Combine(outPath, MsgAutoGenUtilities.ResolvePackageName(rosPackageName));

            string inFileName = Path.GetFileNameWithoutExtension(inPath);

            if (verbose)
            {
                Console.WriteLine("Parsing: " + inPath);
                Console.WriteLine("Output Location: " + outPath);
            }

            MessageTokenizer            tokenizer     = new MessageTokenizer(inPath, new HashSet <string>(MsgAutoGenUtilities.builtInTypesMapping.Keys));
            List <List <MessageToken> > listsOfTokens = tokenizer.Tokenize();

            if (listsOfTokens.Count != 2)
            {
                throw new MessageParserException("Unexpected number of sections. Service should have 2 sections.");
            }

            List <string> warnings = new List <string>();

            for (int i = 0; i < listsOfTokens.Count; i++)
            {
                List <MessageToken> tokens = listsOfTokens[i];

                // Service is made up of request and response
                string className = inFileName + MsgAutoGenUtilities.ServiceClassSuffix + types[i];

                MessageParser parser = new MessageParser(
                    tokens,
                    outPath,
                    rosPackageName,
                    "srv",
                    MsgAutoGenUtilities.builtInTypesMapping,
                    MsgAutoGenUtilities.builtInTypesDefaultInitialValues,
                    className,
                    subtopic: i == 0 ? MessageSubtopic.Default : MessageSubtopic.Response);
                parser.Parse();
                warnings.AddRange(parser.GetWarnings());
            }
            return(warnings);
        }