POV-Ray : Newsgroups : povray.binaries.animations : Re: Robot Insect legs with 2 & 3 segments (735kB MPG) : Re: Robot Insect legs with 2 & 3 segments (735kB MPG) Server Time
19 Jul 2024 02:19:06 EDT (-0400)
  Re: Robot Insect legs with 2 & 3 segments (735kB MPG)  
From: Guenter
Date: 20 Aug 2003 23:45:57
Message: <3f444075$1@news.povray.org>
Hi Chris,

I broke this problem up into two pieces.  The first one is a macro that
determines the exact location of the foot for each clock tick.  The second
macro determines the locations of the joints.  You're right,  the exact
location of the foot during a step forward does not need to be very accurite
in height.  I just used a sin function.  The two segment macro determines
the joint location via a 2D formula.  The three segment macro determine the
joint locations by sweeping the angles and trial and error.  Using this
method I get two degrees of motion at the hip and 1 degree per joint..

Thanks for the input.

Below is today's version of the first macro that determines the foot
location

// WalkLeg( )
//      This takes the inputs, calculates the end of leg position
//      with regard to clock and phase.  We don't care anything
//      about joints here.
//
// Inputs
//      clk - clock
//      LegStride       - how far Foot moves in +x direction
//      LegStepHeight   - how high Foot moves in +y direction
//      LegDownPct      - precentage of cycle Foot is down
//      LegPhase        - what's Foot starting phase, 0-1 == 0-360 degrees
//
// Input/Outputs
//      vFoot - Foot postion at clock=0 and phase=0
//              returns Foot position after clock and phase adjustments
//
#macro WalkLeg( clk, vFoot, LegStride, LegStepHeight, LegDownPct, LegPhase )
    #declare pclk = clk;
    #declare pclk = clk + LegPhase/360;
    #declare pclk = pclk - int(pclk);

    // first we calculate the x position
    #switch( pclk )
        #range(0,LegDownPct/2)                  // pushing forward
            #declare vFoot = vFoot - < pclk*LegStride, 0,0>;
            #break;
        #range(LegDownPct/2, 1-LegDownPct/2)    // stepping forward
            #declare m = LegStride/(1-LegDownPct);
            #declare b = -(LegDownPct/2)*LegStride/(1-LegDownPct);
            #declare vFoot = vFoot + <m*pclk+b - pclk*LegStride , 0,0>;
            #break;
        #range(1-LegDownPct/2, 1.0)             // pulling forward
            #declare vFoot = vFoot + <(1-pclk)*LegStride, 0, 0>;
            #break;
        #else
    #end

    // then we calculate the y (height) position
    #switch( pclk )
        #range(0,LegDownPct/2)                  // it's down
            #break;
        #range(LegDownPct/2, 1-LegDownPct/2)    // lift during stepping
forward
            #declare vFoot = vFoot +
<0,LegStepHeight*sin((pclk-LegDownPct/2)*pi/(1-LegDownPct)), 0>;
            #break;
        #range(1-LegDownPct/2, 1.0)             // it's down again
            #break;
        #else
    #end

#end


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.