Jacek S

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 38 total)
  • Author
    Posts
  • in reply to: Battery indicator #5324
    Author Image
    Jacek S
    Participant

    Hi,

    From the lego mindstorm source code:

    #define BATT_INDICATOR_HIGH 7500 //!< Battery indicator high [mV]
    #define BATT_INDICATOR_LOW 6200 //!< Battery indicator low [mV]

    #define ACCU_INDICATOR_HIGH 7500 //!< Rechargeable battery indicator high [mV]
    #define ACCU_INDICATOR_LOW 7100 //!< Rechargeable battery indicator low [mV]

    Jacek

    in reply to: Simple web server – Lego 42029 MOD #5231
    Author Image
    Jacek S
    Participant

    Hi Anders,

    Thanks. Here is a source code: https://bitbucket.org/stepienj/ev3webpanel

    Jacek

    in reply to: Webserver #5167
    Author Image
    Jacek S
    Participant

    Hi Again,

    Most of the time it takes 134 ms but every 5-10 sec I have the situation from the screen shoot.
    This is all:

    
        public class JoyPos
        {
            public float X { get; set; }
            public float Y { get; set; }
        }
    
        public class TruckInfo
        {
            public int Speed { get; set; }
            public float WheelPos { get; set; }
        }
    
        public class TruckModule : NancyModule
        {
    
            //Motor motor = new Motor(MotorPort.OutA);
    
            public TruckModule() : base("/truck")
            {
                Get["/info"] = x => Response.AsJson(Info);
    
                Post["/joypos"] = x => 
                {
                    return "";
                };
            }
    
            public TruckInfo Info
            {
                get { return new TruckInfo() {Speed = 10}; }
            }
        }
    

    On HttpListener I have latency ~50ms (I seen max 120ms) and the startup time about 5sec

    Jacek

    in reply to: Webserver #5164
    Author Image
    Jacek S
    Participant

    Hi Again,

    I have created own simple HTTP server. Now I have great performance 🙂

    
        class Program
        {
            static void Main(string[] args)
            {
                HttpListener httpListener = new HttpListener();
                httpListener.Prefixes.Add("http://*:9090/");
                httpListener.Start();
                var run = true;
                (new ButtonEvents()).EscapePressed += () => run = false;
                while (run)
                {
                   var context = httpListener.GetContext();
                   Process(context);
                }
            }
    
            public static string RootPath
            {
                get
                {
                    string filePath = new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath;
                    return Path.GetDirectoryName(filePath) + "/" ;
                }
            }
    
            static string GetContentType(string ext)
            {
                switch (ext.ToLower())
                {
                    case ".js":
                        return "text/javascript";
                    case ".htm":
                    case ".html":
                        return "text/html";
                    case ".png":
                        return "image/png";
                    case ".jpg":
                        return "image/jpg";
                    case ".css":
                        return "text/css";
    
                    default:
                        return "application/octet-stream";
                }
            }
    
            private static void Process(HttpListenerContext context)
            {
                string reqPath = context.Request.Url.AbsolutePath;
                //Console.WriteLine(reqPath);
                if (reqPath == "/truck/joypos")
                {
                    context.Response.StatusCode = 200;
                    context.Response.Close();
                    return;
                }
                reqPath = Path.Combine(RootPath, reqPath.Substring(1));
                if (!File.Exists(reqPath))
                {
                    context.Response.StatusCode = 404;
                    context.Response.Close();
                    return;
                }
                var contentType = GetContentType(Path.GetExtension(reqPath));
                context.Response.Headers[HttpResponseHeader.ContentType] = contentType;
                var content = File.ReadAllBytes(reqPath);
                context.Response.OutputStream.Write(content, 0, content.Length);
                context.Response.Close();
            }
        }
    

    Jacek

    in reply to: Webserver #5162
    Author Image
    Jacek S
    Participant

    Hi Again,

    Now my handler body is empty:

    
                Post["/joypos"] = x => 
                {
                    return "";
                };
    

    Look at the attached network log.

    Jacek

    Attachments:
    You must be logged in to view attached files.
    in reply to: Rubik's cube solver #5161
    Author Image
    Jacek S
    Participant

    Hi Again,

    Oh, sorry for misunderstanding and thank you for info. I didn’t know that button is pooled every 50ms. (I never looked at this source code)

    Jacek

    in reply to: Webserver #5160
    Author Image
    Jacek S
    Participant

    Hi,

    Yes, I forgot to remove this. I will do more tests today.

    Jacek

    in reply to: Webserver #5155
    Author Image
    Jacek S
    Participant

    Hi

    The starting time is the next thing that I don’t like.
    Yes I’m sure, I did many tests yesterday. My test program is configured to send ajax posts with 250ms breaks (when the position of joystick is changed). This means that Nancy on the brick have problem with handling 4 requests per second.

    handler code:

    
                Post["/joypos"] = x => 
                {
                    JoyPos pos = this.Bind();
                    LcdConsole.WriteLine("X:{0} Y:{1}",pos.X,pos.Y);
                    var speed = (sbyte) (pos.Y > 100 ? 100 : pos.Y < -100 ? 100 : pos.Y);
                    if (speed == 0) 
                        motor.Off();
                    else 
                        motor.SetSpeed(speed);
                    return Response.AsJson(pos);
                };
    

    poster code:

    
    var timer = $.timer(function () {
        if (Math.abs(x - lastx) > 5 || Math.abs(y - lasty) > 5) {
            lastx = x;
            lasty = y;
            $.post("/truck/joypos", { X: x, Y: y});
        }
    });
    timer.set({ time: 250, autostart: true });
    
    • This reply was modified 9 years, 10 months ago by Author ImageJacek S.
    in reply to: Rubik's cube solver #5154
    Author Image
    Jacek S
    Participant

    Hi,

    I didn’t try AOT. Poll for button is not a part of the main loop, is only when the sensor is moved to the start position.
    The most performance issue is the binaryformatter and deserializing 4mb file (data for algorithm) that takes about 2-3 minutes then algorithm calculates solution within 3 seconds. Maybe the low class sd card is the problem?

    Jacek

    in reply to: Webserver #5151
    Author Image
    Jacek S
    Participant

    Hi Anders,

    I have used the Nancy framework for my javascript touchscreen joystick controller project. The Nancy self hosted server is used to host all static content like html and js files and the rest service where the joystick position is posted from javascript (all is hosted on the ev3 brick). Unfortunately the Nancy server performance is very poor. Often the delay between ajax post and the handler reaction takes 1-2sec. It can’t be used for realtime steering. I was thinking about using HttpListener class. Do you have any experience with this class on the brick?

    Jacek

    in reply to: Rubik's cube solver #5149
    Author Image
    Jacek S
    Participant

    Hi,

    Thank you. Feel free to put the sources in the monobrick github.

    Jacek

    in reply to: Rubik's cube solver #5108
    Author Image
    Jacek S
    Participant
    in reply to: Can the color sensor detect orange? #5055
    Author Image
    Jacek S
    Participant

    Hi,

    Source codes are on the github https://github.com/Larsjep/monoev3
    There is an option “Download as zip” (be sure the branch is set to master). Unpack and open the solution. Then just click Build.

    Jacek

    in reply to: Can the color sensor detect orange? #5051
    Author Image
    Jacek S
    Participant

    Hi Auctor,

    You need to compile firmware lib from the master branch. Because I added this functionality a week ago.
    Then this should work:

    
                EV3ColorSensor colorSensor = new EV3ColorSensor(SensorPort.In2);
                RGBColor rgbColor = colorSensor.ReadRGB();
                Color color = Color.FromArgb(rgbColor.Red, rgbColor.Green, rgbColor.Blue);
                var hue = (int) color.GetHue();
                var bright = (int) (color.GetBrightness()*100);
    

    Then look: http://en.wikipedia.org/wiki/Hue

    in reply to: Rubik's cube solver #5021
    Author Image
    Jacek S
    Participant

    Hi Anders,

    Sure, but is not ready yet. It needs some modifications and code cleaning. Also there are still problems with motor movement waithandle in the base repo. Now this working only with my modified firmware lib.
    Yes, I will prepare a better video to youtube.

    Jacek

Viewing 15 posts - 1 through 15 (of 38 total)
Posted in

Make a donation