Permalink
Browse files

moved Model::Move into ModelPosition::Move. Now only position models …

…can have velocity (makes code more simple)
  • Loading branch information...
1 parent bc4d761 commit 78cb1d5eb46274b75713ba4e39697af960dc1f27 @rtv committed Nov 5, 2011
View
@@ -1,8 +1,8 @@
PROJECT(Stage)
SET( V_MAJOR 4 )
-SET( V_MINOR 0 )
-SET( V_BUGFIX 1 )
+SET( V_MINOR 1 )
+SET( V_BUGFIX dev )
SET( VERSION ${V_MAJOR}.${V_MINOR}.${V_BUGFIX} )
SET( APIVERSION ${V_MAJOR}.${V_MINOR} )
View
@@ -64,9 +64,14 @@ void Stg::Gl::draw_array( float x, float y, float w, float h,
void Stg::Gl::draw_string( float x, float y, float z, const char *str )
{
- // glRasterPos2f( x, y );
- // printf( "[%.2f %.2f %.2f] string %u %s\n", x,y,z,(unsigned int)strlen(str), str );
- gl_draw( str, x, y ); // fltk function
+ glRasterPos2f( x, y );
+
+ GLboolean b;
+ glGetBooleanv( GL_CURRENT_RASTER_POSITION_VALID, &b );
+
+ //printf( "[%.2f %.2f %.2f] %d string %u %s\n", x,y,z, (int)b, (unsigned int)strlen(str), str );
+
+ if( b ) gl_draw( str, x, y ); // fltk function
}
void Stg::Gl::draw_string_multiline( float x, float y, float w, float h, const char *str, Fl_Align align )
View
@@ -5,7 +5,7 @@
/** @defgroup model
The basic model simulates an object with basic properties; position,
- size, velocity, color, visibility to various sensors, etc. The basic
+ size, color, visibility to various sensors, etc. The basic
model also has a body made up of a list of lines. Internally, the
basic model is used as the base class for all other model types. You
can use the basic model to simulate environmental objects.
@@ -22,7 +22,6 @@
pose [ 0.0 0.0 0.0 0.0 ]
size [ 0.1 0.1 0.1 ]
origin [ 0.0 0.0 0.0 0.0 ]
- velocity [ 0.0 0.0 0.0 0.0 ]
update_interval 100
@@ -66,24 +65,11 @@
- origin [ x:<float> y:<float> z:<float> heading:<float> ]\n
specify the position of the object's center, relative to its pose
-
- - velocity [ x:<float> y:<float> z:<float> heading:<float>
- omega:<float> ]\n Specify the initial velocity of the model. Note
- that if the model hits an obstacle, its velocity will be set to
- zero.
- update_interval int (defaults to 100) The amount of simulated
time in milliseconds between calls to Model::Update(). Controls
the frequency with which this model's data is generated.
- - velocity_enable int (defaults to 0)\n Most models ignore their
- velocity state. This saves on processing time since most models
- never have their velocity set to anything but zero. Some
- subclasses (e.g. ModelPosition) change this default as they are
- expecting to move. Users can specify a non-zero value here to
- enable velocity control of this model. This achieves the same as
- calling Model::VelocityEnable()
-
- color <string>\n specify the color of the object using a color
name from the X11 database (rgb.txt)
@@ -144,13 +130,6 @@
easy to define objects in a single local coordinate system.
*/
-// todo
-// - friction <float>\n Determines the proportion of velocity lost
-// per second. For example, 0.1 would mean that the object would lose
-// 10% of its speed due to friction per second. A value of zero (the
-// default) means this model can not be pushed around (infinite
-// friction).
-
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
@@ -310,8 +289,6 @@ Model::Model( World* world,
type(type),
event_queue_num(0),
used(false),
- velocity(),
- velocity_enable(false),
watts(0.0),
watts_give(0.0),
watts_take(0.0),
@@ -739,10 +716,7 @@ void Model::Startup( void )
event_queue_num = thread_safe ? world->GetEventQueue( this ) : 0;
world->Enqueue( event_queue_num, interval, this, UpdateWrapper, NULL );
-
- if( velocity_enable )
- world->EnableVelocity( this );
-
+
if( FindPowerPack() )
world->EnableEnergy( this );
@@ -755,8 +729,6 @@ void Model::Shutdown( void )
CallCallbacks( CB_SHUTDOWN );
world->DisableEnergy( this );
- world->DisableVelocity( this );
- velocity_enable = false;
// allows data visualizations to be cleared.
NeedRedraw();
@@ -896,60 +868,6 @@ void Model::UpdateCharge()
}
-void Model::Move( void )
-{
- if( velocity.IsZero() )
- return;
-
- if( disabled )
- return;
-
- // convert usec to sec
- const double interval( (double)world->sim_interval / 1e6 );
-
- // find the change in velcity due to our acceleration vector
- // velocity.x *= 1.0 + acceleration.x * interval;
- //velocity.y *= 1.0 + acceleration.y * interval;
- //velocity.z *= 1.0 + acceleration.z * interval;
- //velocity.a *= 1.0 + acceleration.a * interval;
-
- // find the change of pose due to our velocity vector
- const Pose p( velocity.x * interval,
- velocity.y * interval,
- velocity.z * interval,
- normalize( velocity.a * interval ));
-
- // the pose we're trying to achieve (unless something stops us)
- const Pose newpose( pose + p );
-
- // stash the original pose so we can put things back if we hit
- const Pose startpose( pose );
-
- pose = newpose; // do the move provisionally - we might undo it below
-
- const unsigned int layer( world->updates%2 );
-
- UnMapWithChildren( layer ); // remove from all blocks
- MapWithChildren( layer ); // render into new blocks
-
- if( TestCollision() ) // crunch!
- {
- // put things back the way they were
- // this is expensive, but it happens _very_ rarely for most people
- pose = startpose;
- UnMapWithChildren( layer );
- MapWithChildren( layer );
-
- SetStall(true);
- }
- else
- {
- world->dirty = true; // need redraw
- SetStall(false);
- }
-}
-
-
void Model::UpdateTrail()
{
// get the current item and increment the counter
@@ -76,11 +76,11 @@ ModelActuator::ModelActuator( World* world,
this->SetWatts( WATTS_BASE );
// sensible position defaults
- this->SetVelocity( Velocity(0,0,0,0) );
+ //this->SetVelocity( Velocity(0,0,0,0) );
this->SetBlobReturn(true);
// Allow the models to move
- VelocityEnable();
+ //VelocityEnable();
}
@@ -282,7 +282,8 @@ void ModelActuator::Update( void )
PRINT_ERR1( "unrecognized actuator type %d", actuator_type );
}
- this->SetVelocity( outvel );
+ // TODO - deal with velocity
+ //this->SetVelocity( outvel );
//this->GPoseDirtyTree();
PRINT_DEBUG4( " Set Velocity: [ %.4f %.4f %.4f %.4f ]\n",
outvel.x, outvel.y, outvel.z, outvel.a );
@@ -305,7 +306,7 @@ void ModelActuator::Shutdown( void )
// safety features!
goal = 0;
- velocity.Zero();
+ // velocity.Zero();
Model::Shutdown();
}
View
@@ -137,31 +137,31 @@ int Model::SetParent( Model* newparent)
return 0; //ok
}
-// get the model's velocity in the global frame
-Velocity Model::GetGlobalVelocity() const
-{
- const Pose gpose(GetGlobalPose());
- const double cosa(cos(gpose.a));
- const double sina(sin(gpose.a));
+// // get the model's velocity in the global frame
+// Velocity Model::GetGlobalVelocity() const
+// {
+// const Pose gpose(GetGlobalPose());
+// const double cosa(cos(gpose.a));
+// const double sina(sin(gpose.a));
- return Velocity( velocity.x * cosa - velocity.y * sina,
- velocity.x * sina + velocity.y * cosa,
- velocity.z,
- velocity.a );
-}
-
-// set the model's velocity in the global frame
-void Model::SetGlobalVelocity( const Velocity& gv )
-{
- const Pose gpose = GetGlobalPose();
- const double cosa(cos(gpose.a));
- const double sina(sin(gpose.a));
+// return Velocity( velocity.x * cosa - velocity.y * sina,
+// velocity.x * sina + velocity.y * cosa,
+// velocity.z,
+// velocity.a );
+// }
+
+// // set the model's velocity in the global frame
+// void Model::SetGlobalVelocity( const Velocity& gv )
+// {
+// const Pose gpose = GetGlobalPose();
+// const double cosa(cos(gpose.a));
+// const double sina(sin(gpose.a));
- this->SetVelocity( Velocity( gv.x * cosa + gv.y * sina,
- -gv.x * sina + gv.y * cosa,
- gv.z,
- gv.a ));
-}
+// this->SetVelocity( Velocity( gv.x * cosa + gv.y * sina,
+// -gv.x * sina + gv.y * cosa,
+// gv.z,
+// gv.a ));
+// }
// get the model's position in the global frame
Pose Model::GetGlobalPose() const
@@ -179,23 +179,6 @@ Pose Model::GetGlobalPose() const
return global_pose;
}
-void Model::VelocityEnable()
-{
- velocity_enable = true;
- world->EnableVelocity(this);
-}
-
-void Model::VelocityDisable()
-{
- velocity_enable = false;
- world->DisableVelocity( this );
-}
-
-void Model::SetVelocity( const Velocity& val )
-{
- velocity = val;
- CallCallbacks( CB_VELOCITY );
-}
// set the model's pose in the local frame
void Model::SetPose( const Pose& newpose )
View
@@ -98,8 +98,6 @@ void Model::Load()
if( wf->PropertyExists( wf_entity, "pose" ))
SetPose( GetPose().Load( wf, wf_entity, "pose" ) );
- if( wf->PropertyExists( wf_entity, "velocity" ))
- SetVelocity( GetVelocity().Load( wf, wf_entity, "velocity" ));
if( wf->PropertyExists( wf_entity, "color" ))
{
@@ -178,8 +176,6 @@ void Model::Load()
if( res != this->map_resolution )
SetMapResolution( res );
- velocity_enable = wf->ReadInt( wf_entity, "enable_velocity", velocity_enable );
-
if( wf->PropertyExists( wf_entity, "friction" ))
{
this->SetFriction( wf->ReadFloat(wf_entity, "friction", this->friction ));
Oops, something went wrong.

0 comments on commit 78cb1d5

Please sign in to comment.