static int Main(string[] args)
        {
            bool   shouldShowHelp    = false;
            string robot_info_file   = null;
            string robot_name        = null;
            bool   wait_signal       = false;
            bool   electric_gripper  = false;
            bool   vacuum_gripper    = false;
            string gripper_info_file = null;
            string gripper_name      = null;

            var options = new OptionSet {
                { "robot-info-file=", "the robot info YAML file", n => robot_info_file = n },
                { "robot-name=", "override the robot device name", n => robot_name = n },
                { "h|help", "show this message and exit", h => shouldShowHelp = h != null },
                { "electric-gripper", "rethink electric gripper is attached", n => electric_gripper = n != null },
                { "vacuum-gripper", "rethink vacuum gripper is attached", n => vacuum_gripper = n != null },
                { "gripper-info-file=", "gripper info file", n => gripper_info_file = n },
                { "gripper-name=", "override the gripper device name", n => gripper_name = n },
                { "wait-signal", "wait for POSIX sigint or sigkill to exit", n => wait_signal = n != null }
            };

            List <string> extra;

            try
            {
                // parse the command line
                extra = options.Parse(args);
            }
            catch (OptionException e)
            {
                // output some error message
                Console.Write("SawyerRobotRaconteurDriver: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `SawyerRobotRaconteurDriver --help' for more information.");
                return(1);
            }

            if (shouldShowHelp)
            {
                Console.WriteLine("Usage: SawyerRobotRaconteurDriver [Options+]");
                Console.WriteLine();
                Console.WriteLine("Options:");
                options.WriteOptionDescriptions(Console.Out);
                return(0);
            }

            if (robot_info_file == null)
            {
                Console.WriteLine("error: robot-info-file must be specified");
                return(1);
            }

            if (vacuum_gripper && electric_gripper)
            {
                throw new ArgumentException("--vacuum-gripper and --electric-gripper are mutually exclusive");
            }

            Tuple <RobotInfo, LocalIdentifierLocks> robot_info = null;
            Tuple <ToolInfo, LocalIdentifierLocks>  tool_info  = null;
            SawyerRobot    robot   = null;
            ISawyerGripper gripper = null;


            try
            {
                robot_info = RobotInfoParser.LoadRobotInfoYamlWithIdentifierLocks(robot_info_file, robot_name);

                ros_csharp_interop.ros_csharp_interop.init_ros(args, "sawyer_robotraconteur_driver", false);

                if (electric_gripper || vacuum_gripper)
                {
                    tool_info = ToolInfoParser.LoadToolInfoYamlWithIdentifierLocks(gripper_info_file, gripper_name);
                    tool_info.Item1.device_info.parent_device      = robot_info.Item1.device_info.device;
                    tool_info.Item1.device_info.device_origin_pose = new NamedPose
                    {
                        parent_frame = new Identifier {
                            name = "right_hand", uuid = new com.robotraconteur.uuid.UUID
                            {
                                uuid_bytes = new byte[16]
                            }
                        },
                        pose = new Pose {
                            orientation = new Quaternion {
                                w = 1
                            }
                        }
                    };
                }

                robot = new SawyerRobot(robot_info.Item1, "");
                if (electric_gripper)
                {
                    gripper = new SawyerElectricGripper(tool_info.Item1, "right_gripper", "");
                    gripper._start_tool();
                }
                else if (vacuum_gripper)
                {
                    gripper = new SawyerVacuumGripper(tool_info.Item1, "right_vacuum_gripper", "");
                    gripper._start_tool();
                }

                robot._start_robot();
                using (var node_setup = new ServerNodeSetup("sawyer_robot", 58653, args))
                {
                    var robot_service_ctx = RobotRaconteurNode.s.RegisterService("robot", "com.robotraconteur.robotics.robot", robot);
                    robot_service_ctx.SetServiceAttributes(AttributesUtil.GetDefaultServiceAtributesFromDeviceInfo(robot_info.Item1.device_info));
                    if (gripper != null)
                    {
                        var tool_service_ctx = RobotRaconteurNode.s.RegisterService("gripper", "com.robotraconteur.robotics.tool", gripper);
                        tool_service_ctx.SetServiceAttributes(AttributesUtil.GetDefaultServiceAtributesFromDeviceInfo(tool_info.Item1.device_info));
                    }

                    if (!wait_signal)
                    {
                        Console.WriteLine("Press enter to exit");
                        Console.ReadKey();
                    }
                    else
                    {
                        UnixSignal[] signals = new UnixSignal[] {
                            new UnixSignal(Mono.Unix.Native.Signum.SIGINT),
                            new UnixSignal(Mono.Unix.Native.Signum.SIGTERM),
                        };

                        Console.WriteLine("Press Ctrl-C to exit");
                        // block until a SIGINT or SIGTERM signal is generated.
                        int which = UnixSignal.WaitAny(signals, -1);

                        Console.WriteLine("Got a {0} signal, exiting", signals[which].Signum);
                    }
                }
            }
            finally
            {
                robot_info?.Item2?.Dispose();
                tool_info?.Item2?.Dispose();
                robot?.Dispose();
                gripper?.Dispose();
            }

            return(0);
        }
示例#2
0
        static int Main(string[] args)
        {
            var now = RobotRaconteurNode.s.NowUTC;

            bool   shouldShowHelp          = false;
            string robot_info_file         = null;
            bool   left_arm                = false;
            bool   right_arm               = false;
            bool   left_electric_gripper   = false;
            bool   right_electric_gripper  = false;
            string left_gripper_info_file  = null;
            string right_gripper_info_file = null;

            var options = new OptionSet {
                { "robot-info-file=", n => robot_info_file = n },
                { "left-arm", n => left_arm = n != null },
                { "right-arm", n => right_arm = n != null },
                { "left-electric-gripper", n => left_electric_gripper = n != null },
                { "right-electric-gripper", n => right_electric_gripper = n != null },
                { "left-gripper-info-file=", n => left_gripper_info_file = n },
                { "right-gripper-info-file=", n => right_gripper_info_file = n },
                { "h|help", "show this message and exit", h => shouldShowHelp = h != null }
            };

            List <string> extra;

            try
            {
                // parse the command line
                extra = options.Parse(args);
            }
            catch (OptionException e)
            {
                // output some error message
                Console.Write("BaxterRobotRaconteurDriver: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `BaxterRobotRaconteurDriver --help' for more information.");
                return(1);
            }

            if (shouldShowHelp)
            {
                Console.WriteLine("Usage: BaxterRobotRaconteurDriver [Options+]");
                Console.WriteLine();
                Console.WriteLine("Options:");
                options.WriteOptionDescriptions(Console.Out);
                return(0);
            }

            if (robot_info_file == null)
            {
                Console.WriteLine("error: robot-info-file must be specified");
                return(1);
            }

            string nodename = "baxter_robot";

            BaxterRobotArmSelection arm_selection;

            if ((!left_arm && !right_arm) || right_arm && left_arm)
            {
                arm_selection = BaxterRobotArmSelection.both;
            }
            else if (left_arm)
            {
                arm_selection = BaxterRobotArmSelection.left;
                nodename      = "baxter_robot_left_arm";
            }
            else if (right_arm)
            {
                arm_selection = BaxterRobotArmSelection.right;
                nodename      = "baxter_robot_right_arm";
            }
            else
            {
                throw new ArgumentException("Invalid arm selection");
            }

            ushort port = 58660;

            if (arm_selection == BaxterRobotArmSelection.right)
            {
                port = 58661;
            }

            Tuple <RobotInfo, LocalIdentifierLocks> robot_info      = null;
            Tuple <ToolInfo, LocalIdentifierLocks>  left_tool_info  = null;
            Tuple <ToolInfo, LocalIdentifierLocks>  right_tool_info = null;

            BaxterRobot           robot         = null;
            BaxterElectricGripper left_gripper  = null;
            BaxterElectricGripper right_gripper = null;

            try
            {
                robot_info = RobotInfoParser.LoadRobotInfoYamlWithIdentifierLocks(robot_info_file);
                if (left_electric_gripper)
                {
                    left_tool_info = ToolInfoParser.LoadToolInfoYamlWithIdentifierLocks(left_gripper_info_file);
                    left_tool_info.Item1.device_info.parent_device      = robot_info.Item1.device_info.device;
                    left_tool_info.Item1.device_info.device_origin_pose = new NamedPose
                    {
                        parent_frame = new Identifier {
                            name = "left_hand"
                        },
                        pose = new Pose {
                            orientation = new Quaternion {
                                w = 1
                            }
                        }
                    };
                }
                if (right_electric_gripper)
                {
                    right_tool_info = ToolInfoParser.LoadToolInfoYamlWithIdentifierLocks(right_gripper_info_file);
                    right_tool_info.Item1.device_info.parent_device      = robot_info.Item1.device_info.device;
                    right_tool_info.Item1.device_info.device_origin_pose = new NamedPose
                    {
                        parent_frame = new Identifier {
                            name = "right_hand"
                        },
                        pose = new Pose {
                            orientation = new Quaternion {
                                w = 1
                            }
                        }
                    };
                }

                ros_csharp_interop.ros_csharp_interop.init_ros(args, "baxter_robotraconteur_driver", true);

                robot = new BaxterRobot(robot_info.Item1, arm_selection, "");
                robot._start_robot();

                if (left_tool_info != null)
                {
                    left_gripper = new BaxterElectricGripper(left_tool_info.Item1, "left_gripper", "");
                    left_gripper._start_tool();
                }

                if (right_tool_info != null)
                {
                    right_gripper = new BaxterElectricGripper(right_tool_info.Item1, "right_gripper", "");
                    right_gripper._start_tool();
                }

                using (var node_setup = new ServerNodeSetup(nodename, port, args))
                {
                    RobotRaconteurNode.s.RegisterService("robot", "com.robotraconteur.robotics.robot", robot);
                    if (left_gripper != null)
                    {
                        RobotRaconteurNode.s.RegisterService("left_gripper", "com.robotraconteur.robotics.tool", left_gripper);
                    }
                    if (right_gripper != null)
                    {
                        RobotRaconteurNode.s.RegisterService("right_gripper", "com.robotraconteur.robotics.tool", right_gripper);
                    }

                    Console.WriteLine("Press enter to exit");
                    Console.ReadKey();
                }
            }
            finally
            {
                robot_info?.Item2?.Dispose();
                left_tool_info?.Item2?.Dispose();
                right_tool_info?.Item2?.Dispose();
                robot?.Dispose();
                left_gripper?.Dispose();
                right_gripper?.Dispose();
            }

            return(0);
        }
        static int Main(string[] args)
        {
            bool   shouldShowHelp  = false;
            string robot_info_file = null;

            var options = new OptionSet {
                { "robot-info-file=", n => robot_info_file = n },
                { "h|help", "show this message and exit", h => shouldShowHelp = h != null }
            };

            List <string> extra;

            try
            {
                // parse the command line
                extra = options.Parse(args);
            }
            catch (OptionException e)
            {
                // output some error message
                Console.Write("MotomanHSCRobotRaconteurDriver: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `MotomanHSCRobotRaconteurDriver --help' for more information.");
                return(1);
            }

            if (shouldShowHelp)
            {
                Console.WriteLine("Usage: MotomanHSCRobotRaconteurDriver [Options+]");
                Console.WriteLine();
                Console.WriteLine("Options:");
                options.WriteOptionDescriptions(Console.Out);
                return(0);
            }

            if (robot_info_file == null)
            {
                Console.WriteLine("error: robot-info-file must be specified");
                return(1);
            }


            var robot_info = RobotInfoParser.LoadRobotInfoYamlWithIdentifierLocks(robot_info_file);

            using (robot_info.Item2)
            {
                using (var robot = new MotomanHSCRobot(robot_info.Item1))
                {
                    robot._start_robot();
                    using (var node_setup = new ServerNodeSetup("Motoman_robot", 58651, args))
                    {
                        RobotRaconteurNode.s.RegisterService("robot", "com.robotraconteur.robotics.robot", robot);


                        Console.WriteLine("Press enter to exit");
                        Console.ReadKey();
                    }
                }
            }

            return(0);
        }
示例#4
0
        static int Main(string[] args)
        {
            bool   shouldShowHelp  = false;
            string robot_info_file = null;
            string robot_name      = null;
            ushort tcp_port        = 58653;
            string node_name       = "gazebo_robot";
            string model_name      = null;
            string gazebo_url      = null;

            var options = new OptionSet {
                { "robot-info-file=", n => robot_info_file = n },
                { "robot-name=", "override the robot device name", n => robot_name = n },
                { "model-name=", "the gazebo model to control", n => model_name = n },
                { "gazebo-url=", "url for the Robot Raconteur Gazebo plugin", n => gazebo_url = n },
                { "h|help", "show this message and exit", h => shouldShowHelp = h != null }
            };

            List <string> extra;

            try
            {
                // parse the command line
                extra = options.Parse(args);
            }
            catch (OptionException e)
            {
                // output some error message
                Console.Write("GazeboModelRobotRaconteurDriver: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `GazeboModelRobotRaconteurDriver --help' for more information.");
                return(1);
            }

            if (shouldShowHelp)
            {
                Console.WriteLine("Usage: GazeboModelRobotRaconteurDriver [Options+]");
                Console.WriteLine();
                Console.WriteLine("Options:");
                options.WriteOptionDescriptions(Console.Out);
                return(0);
            }

            if (robot_info_file == null)
            {
                Console.WriteLine("error: robot-info-file must be specified");
                return(1);
            }

            if (model_name == null)
            {
                Console.WriteLine("error: model-name must be specified");
                return(1);
            }

            if (gazebo_url == null)
            {
                Console.WriteLine("error: gazebo_url must be specified");
                return(1);
            }

            var robot_info = RobotInfoParser.LoadRobotInfoYamlWithIdentifierLocks(robot_info_file, robot_name);

            robot_info.Item1.robot_capabilities &= (uint)(RobotCapabilities.jog_command | RobotCapabilities.position_command | RobotCapabilities.trajectory_command);

            RobotOperationalMode robot_op_mode = RobotOperationalMode.auto;
            var robot_class = robot_info.Item1?.device_info?.device_classes?.Find(x => x?.class_identifier?.name == "robot");

            if (robot_class?.subclasses != null)
            {
                if (robot_class.subclasses.Contains("cobot"))
                {
                    robot_op_mode = RobotOperationalMode.cobot;
                }
            }


            using (robot_info.Item2)
            {
                using (var node_setup = new ServerNodeSetup(node_name, tcp_port, args))
                {
                    using (var robot = new GazeboRobot(robot_info.Item1, gazebo_url, model_name, robot_op_mode))
                    {
                        robot._start_robot();
                        var robot_service_ctx = RobotRaconteurNode.s.RegisterService("robot", "com.robotraconteur.robotics.robot", robot);
                        robot_service_ctx.SetServiceAttributes(AttributesUtil.GetDefaultServiceAtributesFromDeviceInfo(robot_info.Item1.device_info));

                        Console.WriteLine("Press enter to exit");
                        Console.ReadKey();
                    }
                }
            }

            return(0);
        }
示例#5
0
        static int Main(string[] args)
        {
            bool   shouldShowHelp  = false;
            string robot_info_file = null;
            bool   wait_signal     = false;
            string robot_name      = null;

            var options = new OptionSet {
                { "robot-info-file=", n => robot_info_file = n },
                { "robot-name=", "override the robot device name", n => robot_name = n },
                { "h|help", "show this message and exit", h => shouldShowHelp = h != null },
                { "wait-signal", "wait for POSIX sigint or sigkill to exit", n => wait_signal = n != null }
            };

            List <string> extra;

            try
            {
                // parse the command line
                extra = options.Parse(args);
            }
            catch (OptionException e)
            {
                // output some error message
                Console.Write("ABBRobotRaconteurDriver: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `ABBRobotRaconteurDriver --help' for more information.");
                return(1);
            }

            if (shouldShowHelp)
            {
                Console.WriteLine("Usage: ABBRobotRaconteurDriver [Options+]");
                Console.WriteLine();
                Console.WriteLine("Options:");
                options.WriteOptionDescriptions(Console.Out);
                return(0);
            }

            if (robot_info_file == null)
            {
                Console.WriteLine("error: robot-info-file must be specified");
                return(1);
            }


            var robot_info = RobotInfoParser.LoadRobotInfoYamlWithIdentifierLocks(robot_info_file, robot_name);

            using (robot_info.Item2)
            {
                using (var robot = new ABBRobot(robot_info.Item1))
                {
                    robot._start_robot();
                    using (var node_setup = new ServerNodeSetup("ABB_robot", 58651, args))
                    {
                        var service_ctx = RobotRaconteurNode.s.RegisterService("robot", "com.robotraconteur.robotics.robot", robot);
                        service_ctx.SetServiceAttributes(RobotRaconteur.Companion.Util.AttributesUtil.GetDefaultServiceAtributesFromDeviceInfo(robot_info.Item1.device_info));

                        if (!wait_signal)
                        {
                            Console.WriteLine("Press enter to exit");
                            Console.ReadKey();
                        }
                        else
                        {
                            UnixSignal[] signals = new UnixSignal[] {
                                new UnixSignal(Mono.Unix.Native.Signum.SIGINT),
                                new UnixSignal(Mono.Unix.Native.Signum.SIGTERM),
                            };

                            Console.WriteLine("Press Ctrl-C to exit");
                            // block until a SIGINT or SIGTERM signal is generated.
                            int which = UnixSignal.WaitAny(signals, -1);

                            Console.WriteLine("Got a {0} signal, exiting", signals[which].Signum);
                        }
                    }
                }
            }

            return(0);
        }