All posts by RaceRay

Written by

"Enthusiastic Sim-Racer from the north of germany. I write here about web development, hardware, software and latest motion simulator technologies."

phpinfo in XenForo

XenForo 1.2 You ll find the phpinfo() when you log into your admin panel and than add the following parameter to the admin url admin.php?tools/phpinfo

There is no direct link to it in the admin panel, so thats a really “nice to know”.

MySql String replace with REPLACE()

[gard]
Often i have to replace clearly identifiable strings (strings, text) with a new string in a MySQL column. Either its possible to use php, read the DB content and use str_replace() for string replacement, there is a much better way:

Thank God, MySQL offers a native REPLACE() function therefore:

REPLACE(str,from_str,to_str)

Returns the string str with all occurrences of the string from_str replaced by the string to_strREPLACE()performs a case-sensitive match when searching for from_str.

In this example i replace all appearance of the string [youtube] with an empty string in the column xf_post of my XenForo database:

UPDATE xf_post SET message = REPLACE(message, '[/youtube]', '') WHERE message LIKE '%[/youtube]%';

[gard]

 

2DOF Motion Simulator with truck wiper motor playseat

In this article, you will find the step-by-step tutorial you can follow to achieve a DIY 2DOF simulator for 700€ : dozen of pictures, videos…

This is the link to my original post from Gamoover:
http://www.gamoover.net/Forums/index.php?topic=27617.0

Same link: English translated by google
[gard]

The concept:

A dynamic simulator which integrates the driver, the seat, pedals and steering wheel (but not the screens!)
The two axes (2DOF: Two Degrees of Freedom) are Roll and Pitch.

The principle is inspired by the commercial model from Frex http://www.frex.com
but with gearmotors (wiper motor + rod) replacing the electric linear actuators.

A glogal overview of the electrical stuff:
RacingMat-electrical setup

Simtools

This simulator requires an additional software to extract games telemetry data and send the data to the motors: Simtools can be downloaded here

Two computers:

Pc #1 (graphic card “7970 lightning”, Windows 7) :

– The car games (Dirt3, rFactorLite and Richard Burns Rally)
– SimTools GameEngine

PC #2 (Recycling) connected via a crossover cable RJ45 to PC #1

– SimTools GameManager

Electronic cards : Arduino + Motomonster

An Arduino card linked to computer #2 with a USB cable.
The Arduino controls the MotoMonster shield “motor driver board”.

The power board Sparkfun “MotoMonster” drives the two motors (12V 47A = 575W) according to the instructions of the Arduino (5V 5mA = 25 mW).

For simplicity, the motor driver board is equivalent to 4 relays:

driving the right motor forward this means mounting the right side,
driving the right motor in the other direction this means lowering the right side,
driving the left motor forward this means mounting the left side,
driving the left motor in the other direction this means lowering the left side,

An arduino program (C language)

This program interprets the data sent via serial port by SimTools and sends it to the motor control board.
It performs a feedback control by reading the values of the potentiometer coupled to the motors :
-> The actual position is compared to the setpoint, and this will create a new updated order sent to the MotoMonster card.

This feedback loop is performed every 80 ms.

12V power supply and DC motors

A heavy 12V Power Supply Unit about 30A. Electric Motors

2 Truck Wiper Motors for actuating the movable platform, with their positioning potentiometer (for feedback).

 

Structure in rectangular steel tube:

 

– the frame
the frame rests on the ground and supports the movable platform via a motor drive shaft (U joint).

– the moving part: the “cockpit”

– A true racing bucket seat (tubular). The fiber seats are lighter but more expensive.
– A harness! important to feel the seat movements and for realism of immersion
– Force Feedback steering wheel and pedals

The dimensions

Here are the quotations to give you an idea :

The step-by-step pictures:

Structure

It was very convenient to have the bucket seat’s mounting plate: I drilled the structure easily!

Power Drill and a conical tool to adjust the hole to good diameter
Take care to ensure the shaft ‘s squareness : it has to be vertical !
http://gamoovernet.pixhotel.fr/pics_gamoovernet690px/20130401124851-RacingMat-cardan-et-chassis-3-.JPG

Then I crossed the bars at 45 ° to triangulate my frame :

The gimbal (U joint) is blocked in rotation along the yaw axis.

the gimbal assembly:

which gives this 🙂


and this

XenForo Nginx rewrite rules configuration for friendly url

[gard]
Use the following configuration file to run your XenForo forum installation delivered by the Nginx webserver with friendly urls:

The rules are very simple:

Open your nginx.conf (You often in /etc/nginx):

Inside the server block {} insert two location related sections:

location / {
try_files $uri $uri/ /index.php?$uri&$args;
}

location ~ /(internal_data|library) {
internal;
}

The first location block specifies the url rewriting process. The second location part prevents external access to the internal XenForo related data structures. Thats for security purposes of the forum installation.

If you forum is located within a subfolder like e.g. domain.com/forum or domain.com/community just add the name of the subfolder to the location parts:

location /forum/ {
try_files $uri $uri/ /forum/index.php?$uri&$args;
}

location ~ /forum/(internal_data|library) {
internal;
}

Restart the nginx webserver.

All done. Your XenForo installation should be running fine now with search engine friendly urls like domain.com/forum/this-is-my-post.2
[gard]

Disable author meta box for specific pages and posts – WordPress

[gard]
Sometimes its necessary to give your posts or pages switches to turn on and off specific template elements on your site. WordPress makes it really easy:

 

If not already done, activate the Custom fields on the Screen Options menue at the upper right corner of your post:

Add New Post ‹ XSimulator — WordPress

Than create any field and value, e.g.:
Name: hide-author
Value: 0

You can call the name as you want it. We define it in the template next.

custom fields in WordPress

 

Now we open content.php and go to line 60:

<?php     if ( is_single() && get_the_author_meta( 'description' ) && is_multi_author() ) :?>
			<?php get_template_part( 'author-bio' ); ?>
		 <?php endif; ?>

Change it so something like:

if ( is_single() && get_post_meta($post->ID,  'hide-author', true) != '1') :
                    ?>
			<?php get_template_part( 'author-bio' ); ?>
		<?php endif; ?>

As you can see, you can grab  the new custom field and create a condition with:

 get_post_meta($post->ID,  'hide-author', true) != '1')

Now you can specify in all your posts and pages if you like to disable or enable the author box. Very easy!
[gard]

 

SimTools Quickstart

Quickstart Guide for SimTools!

Guide for SimTools 2 will be updated soon!

Following this, step after step, is a quick way to achieve your first basic functional setup and make your simulator come alive.

For detailed explanation use the complete user guide:
http://www.xsimulator.net/simtools-complete-documentation/

Find a russian translated version at:
http://mal4x.ru/viewtopic.php?f=6&t=379

A LITTLE ABOUT SIMTOOLS

SimTools is designed to be a simple set of tools that work together to get motion simulators up and running as fast as possible while still giving the user all of the customizations and flexibility they may need.

One really cool thing SimTools will allow you to do is  “Live Tuning of Profiles”! Create a profile for a game and then tune the profile to perfection while playing the game!
You don’t have to stop the game to make changes to the profile being used!

A LITTLE ABOUT THIS GUIDE…

Just follow this step-by-step guide from points 1 to 10 and you will make your simulator move accordingly to the default profile! Enjoy!

Requirements

a) Mandatory :

  • Windows XP, Windows 7, Windows 8
  • Microsoft .NET 4

b) Optional :

  • A second computer connected to your Game computer makes fine tuning very comfortable. But it’s optional.
  • (Directly Connected Network Cards with a crossover cable for best performance!)

Installation To do list

Please follow these all of these steps consecutively:

first: downloads

  1. ATTENTION: Microsoft Dot Net 4.0 is mandatory. So it is required that you start by installing it now http://www.microsoft.com/en-us/download/details.aspx?id=17851
  2. Make sure your Windows screen text is set to 100%. (Instructions can be found here)
  3. Install SimTools
  4. Download the Plugins related to your favorites Games which can be found in the resource section.
  5. Do not unzip the plugin files! They are used as is.
  6. As for “Life For Speedtm” this is preset into SimTools, you can download the demo version of Life For Speedtm here: http://www.lfs.net/?page=downloads
  7. You must run the game at least once in order to successfully patch it for Output.

second: SimTools installation in detail

  • Download the latest version [here]
  • Extract and run SimTools
  • The typical installation directory is “C:Program Files (x86)SimTools
  • Select Full Installation if you run only one PC. (If you have a dual-PC setup, you have to run the installation program on both PCs individually. In that case, select GameManager installation on the PC that runs the game; Select GameEngine installation on the PC, the controllers are connected to.)
  • Select Launch GameEngine and Launch GameManager at this point in time prior to clicking Finish on the last screen of the installation routine. This will allow you to become familiar with the application but if you plan to use more games than Life for Speedtm please close both Game Manager and Game Engine before proceeding.
  • You will get now 4 executables: Game Engine, Game Manager, Game PluginUpdater, Uninstall.

Plugin import

  • Check in the System Tray for Game Engine and Game Manager and make sure they are not running. If so please close them before proceeding.
  • Run the GamePlugin Updater.
    Sim Tools Icons
  • This program can be found also in the SimTools directory (most probably C:Program Files(x86)SimTools SimTools_PluginUpdate.exe)
  • Drag&drop the plugin-zipped file into the PluginUpdater. There will be a confirmation if the plugin installed correctly. 
  • If you use a 2 PC setup, Install the plugin on both PC’s
  • Once this is successful, the profile will be available within Game Engine and Game Manager.
  • Close SimTools GamePlugin Updater.

Patching the game

  • Run GameManager and GameEngine Note: If issues arise in patching games right click on the icons and select “Run as Administrator“.
  • If the GamaManager window doesn’t open automatically, double-click on the tray icon for the GameManager to open the GameManager window
  • Select the game you want to play from the Game Selection drop-down list.
  • Press “Patching” to first patch the sim program. Follow the instructions of the individual plugin and then press Patch Game.
  • There should be a confirmation message when the game is patched correctly (“Patch Installed!”).

Successfully Patched a Game

Setting up Simulator axis

a) Definitions

If your simulator is powered by several actuators. Consider that each actuator is seen by Sim Tools as an Axis. SimTools can extract up to 9 telemetry data (“DOF 1” to “DOF 9”) from the games and can handle up to 6 actuators (“Axis1” to “Axis6”).
This step in the tutorial will let you indicate to Sim Tools the data mixing to operate before sending instructions to your simulator’s interface along to your simulator configuration. Some standard configuration is preset: e.g “SimForce GT” is a seat mover with two motors connected to the back of your seat.

b) Setting up the “Default” axis assignments

First, we must define the “Default” settings that we want SimTools to use, later you can customize this.

  • Right-click on the GameEngine tray icon
  • Click on the Axis Assignments button
  • Under Game List drop-down (Axis Assignment 1) select Default

Select Default Axis - Game Engine

 

  • Click on the Axis Assignments second tab
  • Select a preset from the Presets drop-down list for your simulator

Selecting a Preset

The tab automatically switches back to Axis Assignments Tab 1

  • Select Default from the Game List and click on Save Settings

This is a first very basic setup showing just the roll and pitch from the game.

With more experience, you can also add some % of Surge to simulate acceleration and braking or Heave for road bumpiness.

c) Warning

Be sure to set up your “Default” Axis Assignments profile as this becomes the first game profile when you install a new game plugin:

  1. When using Output Testing, the Axis Assignments Profile that is used is the “Default” profile. If you have not set up this profile, you will not get any output.
  2. The “Default” profile is also copied for each new game installed as a starting place for the Axis Assignments for the new game.

Remember:

  • Axis 1 to 6 are the motors of your simulator
  • DOF 1 to 9 are the game data extracted by the plugin

Communicating with the simulator

Sim Tools supports up to 6 different interfaces!

They are selectable in the 6 tabs
Interface 1 – Interface 6.

a) How many interfaces are needed?

For a 2 DOF “SimForceGT”, there is only need for 1 interface if you use an arduino board which is able to drive 2 actuators.

The following steps are only for example purposes and treat the Arduino and JRK interfaces. There are another interface available, e.g. SimAxe or Kangaroo Controller. Look in the forum for more information about it.

Example setup for Arduino:

[gard]
Arduino is connected to Windows COM3
SimTools “Interface 1” sends to COM3 the concatenated information of Axis 1 and of Axis 2.

Arduino will dispatch the data sending Axis 1 orders to Actuator 1 and Axis 2 orders to Actuator 2

arduino

Example setup for JRK interface

You need 2 JRK 12v12 boards. Each JRK drives its own actuator

  • JRK1 connected to COM4
  • SimTools “interface 1” sends the information for axis 1 to COM4
  • JRK1 sends commands of axis 1 to actuator 1.
  • JRK2 connected to COM6
  • SimTools “interface 2” sends the information for axis 2 to COM6
  • JRK2 sends commands of axis 2 to actuator 2.

Refer to Eaorobbie’s post here for step by step startupjrk

b) Possible types of interfaces 

Basically, you will use “USB Serial interface” to control your Arduino or JRKs.
(NET interfaces are used for LAN connected interfaces: this is not described in this Quick Starting guide).

Click on the Interface Settings button.

Setting the Interface Output Type

  • Select Interface 1 to set up your first interface.
  • Select the Output Type – typically “SER”

c) JRK Game Engine interface settings

  • If you are using JRK’s select JRK 12bit from the Presets drop-down list. Otherwise, select the correct ComPort settings as provided by your controller manual.
  • Select the ComPort your controller is connected to.

jrk ser1

Click on Save

  • Select Interface 2nd tab
  • Again, select SER and the correct ComPort settings as before with Interface
  • Enter <Axis2> in the Interface – Output!

jrk ser2

Click Save

d) ARDUINO Game Engine interface settings

Interface 1 only:

GE arduino SER

d) SCN5 Game Engine interface settings

Thanks @nclabs

  • Click on Interface Settings, Interface1, Output Type and select SCN.
  • Under ComPort, select one of the COM ports connected to you SCN5 (if you don’t know it, check the Control Panel on Windows, under the COM Port section).
  • Under Packet Rate select 10 ms.
  • Under Assignment Axis, select Axis 1.
  • With the Speed bar, you can adjust the speed of the actuator, select a temporary value of 10.000 (value that you can increase after some testing).
  • With the Acceleration bar you can adjust the acceleration of the actuator, select a temporary value of 500 (same thing here, you can increase it after).
  • Now do the same thing with the Interface2, using the other COM port, and selecting Axis 2 under Assigned Axis (important!).
  • Last thing. Click on Axis Assignment, Axis Limiting and, to any axis connected with a SCN actuator, select a value of 90%. This is very important to preserve your actuator in the long term. Not doing this can lead to mechanical damage.

Moving your Simulator (with mouse controller)

Let’s move your simulator without any game input with simply using your mouse!

Its is recommended to test first manually your simulator before testing any game output.

  1. Plug in your serial connection between your computer and your simulator.
    For example, a USB cable between your computer and your arduino/JRK 12
  2. Game Engine / Output Testing

GE Output1

Click on Turn on
Select Axis Output

Now, choose an Axis and slide gently the slider with your mouse!
As an Axis corresponds to an actuator, you will see the selected actuator moving!
Axis limitation is not active for this testing purpose.

The smoothness depends on the refresh rate (try below 10 ms).

Checking the direction of movements

Now we need to test that the simulator behaves correctly: if the game plugin sends “tilt left”, the simulator has to tilt left and not right!

You can invert the motor wiring … or invert the DOF in the “Axis Assignments”  😉

With the slider, we will manually make sure that it is rolling and pitching in the right directions.

For this example we find

Roll : 100% – Tilts Left
Roll : – 100% – Tilts Right
Pitch : 100% – Tilts Forwards
Pitch : – 100% – Tilts Backwards

We have to follow the coordinate system that is in place in the Sim Tools Plugin API reference – see http://www.xsimulator.net/co-ordinate-system/

We know from that in Virtual Axis when it Tilts Left – Roll is all the way Left
Tilts Right – Roll is all the way Right
Tilts Forward – Pitch is all the way Left
Tilts Backwards – Pitch is all the way Right

Virtual Axis can be found next to the “Axis Testing” tab and can  be turned on by pressing “Turn On”

So to correct to the coord’s we need to invert the Roll and invert the Pitch or our games will not produce the right directions of movement.

Once we have this all set up including Heave, Sway and Surge we can then go on and patch a game and begin to test the motion and fine tune it to your Sim.

Visualizing game´s data extraction

Click on Output Testing.
Don’t connect the motors yet.

  • Click on Virtual Axes and on Turn on.
  • Run the game.

If everything is set-up correctly the sliders should be moving.
You can now see that SimTools can read the Game data!

GE output virtual

Note: If you only want to test the slider movements and don’t have 6 ComPorts, just write
<Axis1><Axis2><Axis3><Axis4><Axis5><Axis6>
into the Interface – Output line.

 

Starting your Simulator

[gard]
A) security approach

The first step, the Security approach: in order to preserve your hardware, begin the test by lowering the range and the intensity

  • Via the GameEngine / Axis Assignments / Axis Limiting: reduced to 50%

ge3 50%

  • Via the GameManager, open the “Profile Editor” window in the Game tab / Main settings: put the Main Level to 20% to preserve your actuators

gm5 50%

 

B) The second step, starting the sequence:

  1. Launch Game Engine
  2. Launch Game Manager, select the Game Profile in the drop-down menu
  3. Launch the game, start a race! The playseat comes alive…

C) Increase the levels: 

– Don’t Skip –
Increase the levels until simulator’s movements are satisfying.

For Best Performance, make sure the profiles Main Level is back to 100%. Also make sure that your simulator Axes Limiting are set back to 100% once you are all setup. SCN actuators may want to leave the Axes Limiting at 90% to avoid damage to the actuators rod ends.  

Conclusion

Congratulations, you have now completed the Quick Start Manual!

To learn more

Please refer to Complete Documentation
http://www.xsimulator.net/simtools-complete-documentation

Three and multi columns responsive css layout

One of the best source for a responsive easy adaptable responsive multi column layout is http://www.responsivegridsystem.com

It´s not a bloated framework, neither a boilerplate or similar. It´s just a little bunch of very smart code to create a responsive div layout. I´ll use it at the frontpage of XSimulator.net.

Just a example for a responsive three column layout:

HTML:

<div class="col span_1_of_3">Column 1</div>
<div class="col span_1_of_3">Column 2</div>
<div class="col span_1_of_3">Column 3</div>

CSS

/* Reset - Responsive first */

.col:first-child {
margin-left: 0;
}
.col {
display: block;
float: left;
margin: 1% 0 1% 1.6%;
}
.span_1_of_3 {
width: 31.7%;
}

/* non responsive */
@media (max-width: 643px) {
.span_1_of_3 {
            width: 100%;
        }
        .col {
            margin: 1% 0 1% 0%;
        }
}

Result: (Scale your browser to see it responsive):

Column 1
Column 2
Column 3

Get it:
http://www.responsivegridsystem.com/

WordPress breadcrumbs without plugin

Open your theme functions.php and add the following code:

function xsimu_breadcrumb() {
        echo ' <ul id="breadcrumbs">';
    if (!is_home()) {
        echo '<li> <a href="';
        echo get_option('home');
        echo '">';
        echo 'Home';
        echo "</a><span class='separator'>»</span></li>";
        if (is_category() || is_single()) {
            echo ' <li>';
            the_category('<span class="separator">»</span></li><li> ');
            if (is_single()) {
                echo "</li><li><span class='separator'>»</span>";
                the_title();
                echo '</li>';
            }
        } elseif (is_page()) {
            echo '<li>';
            echo the_title();
            echo '</li>';
        }
    }
    elseif (is_tag()) {single_tag_title();}
    elseif (is_day()) {echo"<li>Archive for "; the_time('F jS, Y'); echo'</li>';}
    elseif (is_month()) {echo"<li>Archive for "; the_time('F, Y'); echo'</li>';}
    elseif (is_year()) {echo"<li>Archive for "; the_time('Y'); echo'</li>';}
    elseif (is_author()) {echo"<li>Author Archive"; echo'</li>';}
    elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "<li>Blog Archives"; echo'</li>';}
    elseif (is_search()) {echo"<li>Search Results"; echo'</li>';}
    echo '</ul>';
}

Add the following function in one of your templates. Most times you will use the header.php

<?php xsimu_breadcrumb(); ?>

Congratulations. You are done;)

Pagination for WordPress without Plugin

When i started the creating process of this theme i considered to integrate one of the popular WordPress plugins for pagination. I than  decided to publish the XSimulator theme for free and i felt that it could lead to any problems and issues for someone else to make a similar looking theme when the requirements  are a lot of different plugins he must install first. Fortunately i found a great programmed script which is very easy to implement and powerful.

Open your functions.php and create a new function:

/* Adds pagination 
 * 
 * @since XSimulator 1.0
 * @param $range total list of pages 
 * @param $range count of maximum page links from left and right side of the current page link.
 * @bool $show_one_page_hint shows a text like: page 1 of 6
 * @bool $show_one_pager Do not show nav arrows
 * 
 */
function xsimu_pagination($range = 3, $show_one_pager = true, $show_page_hint = false)
{
    global $wp_query;
    $num_of_pages = (int)$wp_query->max_num_pages;

    if(!is_single() && $num_of_pages > 1)
    {
        $current_page = get_query_var('paged') === 0 ? 1 : get_query_var('paged');
        $num_of_display_pages = ($range * 2) + 1;        

        $output = '<div id="pagination">';

        if($show_page_hint)
        {
            $output .= '<span>Page ' . $current_page . ' of ' . $num_of_pages . '</span>';
        }

		if($current_page > 2 && $current_page > $range + 1 && $num_of_display_pages < $num_of_pages)
		{
			$output .= '<a href="' . get_pagenum_link(1) . '" title="Page 1 - Latest article">«</a>';
		}
		if($show_one_pager && $current_page > 1)
		{
			$output .= '<a href="' . get_pagenum_link($current_page - 1) . '" title="Page ' . ($current_page - 1) . ' - Latest Artikel">‹</a>';
		}

		for($i = 1; $i <= $num_of_pages; $i++)
		{
			if($i < $current_page + $range + 1 && $i > $current_page - $range - 1)
            {
				if($current_page === $i)
				{
					$output .= '<span class="current">' . $i . '</span>';
				}
				else
				{
					$output .= '<a href="' . get_pagenum_link($i) . '" title="Page ' . $i . '" >' . $i . '</a>';
				}
            }
		}

		if($show_one_pager && $current_page < $num_of_pages)
		{
			$output .= '<a href="' . get_pagenum_link($current_page + 1) . '" title="Page ' . ($current_page + 1) . ' - Older article">›</a>';
		}
		if($current_page < $num_of_pages - 1 && $current_page + $range < $num_of_pages && $num_of_display_pages < $num_of_pages)
		{
			$output .= '<a href="' . get_pagenum_link($num_of_pages) . '" title="Page ' . $num_of_pages . ' - Older article">»</a>';
		}

		$output .= '</div>';

        return $output;

    }
}

Open the template file where you want to publish your pagination. E.g. category.php

echo xsimu_pagination(2, true, false);

You´re ready:)

Thanks to the author of the original script on the page smart-webentwicklung.de