Writing English sentences to program Autonomous

I did this purely for the fun of it.
https://vexforum.com/attachment.php?attachmentid=5353&stc=1&d=1329950702
Yes, it actually works and compiles and runs, etc. See attachments below.
EasierC.jpg
EnglishC.zip (48.7 KB)

That’s really cool. I remember that I wrote a javascript script to do this with ROBOTC a while back. No one really found it too helpful though. Do you find that people like using this type of interface?

I haven’t tried to get anyone to use it. I’ve showed it to some of my teams and they think it’s amazingly easy, but I still prefer using functions than typing text. I guess the easy part about it to them is being able to understand it without any unfamiliar symbols or understanding C in general.

Sorry I do not have easyc capabilities this moment. How did you get that to work? Did you have to do a ton of other or stuff or did you literally just drag in C code blocks and write stuff in?

// UserInclude.h : header file
#ifndef USERINCLUDE_H_
#define USERINCLUDE_H_
typedef void (*ActionFunc)(double SpeedPercent);
typedef struct Event_t
{
    unsigned long when;
    ActionFunc ToDo;
    double Param;
    struct Event_t *next;
} Event;
extern Event *event;
void add_event(double Time, ActionFunc Action, double SpeedPercent);
#define At add_event(
#define seconds
#define move ,
#define make ,
#define up , +
#define down , -
#define forward , +
#define backward , -
#define left , -
#define right , +
#define with
#define percent
#define speed );
#define stop , 0);
//At <Time> seconds move <ActionFunc> <up/down/etc...> with <SpeedPercent> percent speed
//At <Time> seconds make <ActionFunc> stop
void Execute(void);
#define End Execute();
#endif // USERINCLUDE_H_
// UserSource.c : implementation file
#include "Main.h"
#include "stdlib.h"
Event *event = 0;
void add_event(double Time, ActionFunc Action, double SpeedPercent)
{
    if(!event)
    {
        event = (Event*)malloc(sizeof(Event));
        event->when = Time*1000;
        event->ToDo = Action;
        event->Param = SpeedPercent;
        event->next = 0;
        return;
    }
    Event *evt = event;
    while(evt->next) evt = evt->next;
    evt->next = (Event*)malloc(sizeof(Event));
    evt->next->when = Time*1000;
    evt->next->ToDo = Action;
    evt->next->Param = SpeedPercent;
    evt->next->next = 0;
}
void Execute(void)
{
    Event *evt = event;
    unsigned long time = 0;
    while(evt)
    {
        Wait(evt->when - time);
        time = evt->when;
        evt->ToDo(evt->Param);
        evt = evt->next;
    }
    if(!event) return;
    evt = event;
    while(evt->next)
    {
        Event *t = evt;
        evt = evt->next;
        free(t);
    }
    event = 0;
}

There may or may not be issues. I certainly could have done this entirely differently without the need for the crazy structure I am using.

That is very very clever! Good job on making that! :wink:

Next, if you want even more functionality, you can add commands like until, and sensor input. Basically to make it more natural language-like. So users can type in, “go forward until sensor 3 is hit. Then turn left and wait for 300 milliseconds.” It sounds hard, but it’s not terribly difficult, just tedious. (I’m not sure about EasyC, because, as I said, I did this in javascript). You might also want to check out ROBOTC’s “Natural Language” interface.

I think at that point I am better off making it take it as a string literal and parse it than trying to use my current system of #defines to make a function call.

This is a very innovative interface you’ve created. If your only team members that are well-versed in the code are sick on the day of a tournament, then the others can still program the robot if they need to. Kudos!