How to write a SUMO scenario file? - sumo

I am trying to understand what files do I need to build a scenario in SUMO. So far I know how to use NetEdit to generate the network file (net.xml) and the route file which shows the routes of the vehicles (rou.xml). I would like to then determine the actions that my autonomous ego vehicle will make so that it makes specific movements (e.g.: overtaking or changing lanes) after driving for some time and this simulation scenario can be replayed on a simulator. I am not sure how to do this.

Now that you have the net and the route file you are ready to simulate. Depending on your sumo version you can probably start the simulation directly from netedit by choosing "Open in sumo-gui" from the edit menu (or press ctrl+t).
If you want to start a simulation without GUI from the command line, you can do sumo -n mynet.net.xml -r myroutes.rou.xml. You can also save a configuration this way by doing `sumo -n mynet.net.xml -r myroutes.rou.xml -C mycfg.sumocfg. Than you can double click the sumocfg to start the simulation.

Related

How do small teams do secure backups of source code?

First of all, I don't mean version control such as git.
I do use git locally but, I'm trying to determine the best way to do back-ups of source code (as well as other app assets) in case of hardware failure or such.
I was thinking I could set up a script to tar my project folders, and encrypt them with gpg. I would then save the encrypted tar to external hard drives and to 1 or more off-site locations using a service such as amazon drive or dropbox.
Currently, I'm a sole developer so my thinking was that this method should be okay. But I wanted to get some input to make sure I'm doing this the best/most reliable way possible.
If there is a better approach to this that may be more applicable to small teams, then please let me know, as I'm more than happy to do the extra work implementing the approach.
There are much of ways of doing that.
But, if you always work local and you need a simple way of doing that, you may take a look at run scripts if some specific usb device is plugged in.
Meaning that a simple backup script with tar would run if you plug in your specific backup hdd.
Take a look at udev rules in linux.
udev is a generic device manager running as a daemon on a Linux system and listening (via a netlink socket) to uevents the kernel sends out if a new device is initialized or a device is removed from the system. The udev package comes with an extensive set of rules that match against exported values of the event and properties of the discovered device. A matching rule will possibly name and create a device node and run configured programs to set up and configure the device.
Take a look at these posts:
https://unix.stackexchange.com/questions/65891/how-to-execute-a-shellscript-when-i-plug-in-a-usb-device
&
https://askubuntu.com/questions/401390/running-a-script-on-connecting-usb-device
If you plan to go further, to extend the team or even to keep your code for a while in other words, if you want to be professional, I would go with a scalable and reliable tool designed for this: use a real backup and restore tool and don't use scripts. A lot of people, small (and even not so small) companies are doing it and they end up in trouble: maintenance, scalabolity, update, and so on.
There are plenty of backup & restore tools for different purposes and/or platforms, prices and so on. https://en.wikipedia.org/wiki/List_of_backup_software would be a good start :)
Cheers
Werlan

I have CICD running. How can I automate the steps to prepare a release locally?

I already have CICD in Jenkins automated for my team. A push to the master branch will test & deploy my team’s node app to npm. However the steps to prepare get a release are complicated and many, and right now just reside in a text file. I just copy those steps from the text document and paste them into a Unix command line to run them. I want to code something to automate/tool that release prep.
I need to run steps of commands, and pause to confirm.
I need to be able to quit at any step and resume at any step.
I need to alternate between performing steps for the computer and informational steps for displaying to people.
Nice to have:
It would be nice to have steps be relatively human readable in the code.
I would prefer to use someone else's to not roll my own.
I already know JavaScript, Bash, Make, yml
How can I best automate my pre-release steps?
You can just pass all the commands to the shell script like so in unix,
$ vi release.sh
#!/bin/bash
//Release commands here
I need to run steps of commands, and pause to confirm.
You can add the follow piece of code on the commands that you would like conformation before proceeding
echo "Do you want to continue?(yes/no)"
read input
if [ "$input" == "yes" ]
then
echo "continue"
fi
I need to be able to quit at any step and resume at any step.
I'm guessing you mean PAUSE and resume
when your shell script is running and you feel the urge to PAUSE you can use Crtl+Z to PAUSE the script and do whatever you want to do like run other scripts/process or go for a cup of coffee :)
To resume, type
$jobs -->List all jobs
[1]+ Stopped release
run fg(foreground) or bg(background)
Note: have to be in the same active shell for it to work
I need to alternate between performing steps for the computer and
informational steps for displaying to people
Add echo
echo "Going to copy the file from actual location to target location"
cp ACTUAL_LOC/file.txt TARGET_LOC/file.txt
It would be nice to have steps be relatively human readable in the
code.
This totally depends on how well you write the script file :)
I would prefer to use someone else's to not roll my own.
Do You mean rollback in sql or unix commands when a failure happens??

Is it possible to accurately log what applications the user has launched through the linux kernel?

My goal is to write to a file (that the user whenever the user launches an application, such as FireFox) and timestamp the event.
The tricky part is having to do this from the kernel (or a module loaded onto the kernel).
From the research I've done so far (sources listed below), the execve system call seemed the most viable. As it had the filename of the process it was handling which seemed like gold at the time, but I quickly learned that it wasn't as useful as I thought since this system call isn't limited to user-related operations.
So then I thought of using ps -ef as it listed all the current running processes and I would just have to filter through which ones were applications opened by the user.
But the issue with that method is that I would have to poll every X seconds so, it has the potential to miss something if the user launched and closed an application within the time that I didn't call ps -ef.
I've also realized that writing to a file would be a challenge as well, since you don't have access to the standard library from the kernel. So my guess for that would be making use of proc somehow to allow the user to actually access the information that I'm trying to log.
Basically I'm running out of leads and I'd greatly appreciate it if anyone could point me in the right direction.
Thanks.
Sources:
http://tldp.org/LDP/lkmpg/2.6/html/x978.html (not very recent)
https://0xax.gitbooks.io/linux-insides/content/SysCall/syscall-4.html
First, writing to a file or reading a real file from the kernel is a bad idea which is not used in the kernel. There is of course VFS files, like /sys/fs or /proc, but this is a special case and this is allowed.
See this article in Linux Journal,
"Driving Me Nuts - Things You Never Should Do in the Kernel" by Greg Kroach-Hrtman
http://www.linuxjournal.com/article/8110
Every new process that is created in Linux, adds an entry under /proc,
as /proc/pidNum, where pidNum is the Process ID of the new process.
You can find out the name of the new application which was invoked simply by
cat /proc/pidNum/cmdline.
So for example, if your crond daemon has pid 1336, then
$cat /proc/1336/cmdline
will give
cron
And there are ways to monitor adding entries to a folder in Linux.

How to prioritize a particular process on start up?

In Linux, I want a process to be assigned with higher priority than usual. I.e. when a process starts I want it's priority to be set to higher value. I want this to be done implicitly, i.e when the process starts (eg.:on a double click).
For this will I have to change the kernel code (sched.c)?
And are there any tools or packages using which I can see how exactly a process starts and how the priorities are assigned?
Would ptrace ( http://linux.die.net/man/2/ptrace) and strace ( http://linux.die.net/man/1/strace) help me with this?
Assuming you don't want to hack the actual application itself you can always create a custom desktop file which wraps the command with "nice" which will modify the niceness (priority) of the command you'll run.
For example, create a ~/.local/share/applications/myfastapp.desktop which looks like:
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Exec=nice -n -20 /usr/bin/myapp
Name=My App (niced)
Comment=Custom definition for myapp
Have the process call the set_priority() system call in main() to lower it's nice level and raise it's priority. See the man page for details: http://linux.die.net/man/2/setpriority
You can also mark the process as a real time process using sched_setscheduler() but that is a little bit more involved and probably an overkill for what you seek.
You 100% don't need to change the kernel for this :-)

Run script on Fedora screen lock

I'm looking for a way to run a program when locking the screen in Fedora 15 (linux). Basically I want to start running a motion detection program when the screen locks, or I manually hit Ctrl+Alt+L, but I don't know what commands are being run or where to alias my own intermediate step in. I assume it's:
gnome-screensaver-command --lock
but am not sure how to go about this. Anybody know how, or a direction to start looking in?
Edit, since link was in a comment:
This is done with dbus-monitor and described here.
The dbus system advertises screen locking; monitor for ActiveChanged on org.gnome.ScreenSaver. (see http://people.gnome.org/~mccann/gnome-screensaver/docs/gnome-screensaver.html )
e.g. (word-wrapped for clarity)
signal sender=:1.68 -> dest=(null destination)
serial=53 path=/org/gnome/ScreenSaver;
interface=org.gnome.ScreenSaver; member=ActiveChanged
boolean true
Unfortunately, this will require writing more code than just a shell script, I'm afraid; although I'd be curious if you could ask dbus to call your program as a handler for that signal, somehow; otherwise, I suppose you'd just start a daemon process and listen for that signal to be broadcast…