Changeset 377 in flair-src for trunk/lib


Ignore:
Timestamp:
Dec 16, 2020, 9:40:44 AM (12 months ago)
Author:
Sanahuja Guillaume
Message:

ugv update

Location:
trunk/lib
Files:
6 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairMeta/src/Uav.cpp

    r215 r377  
    2121#include <GridLayout.h>
    2222#include <DataPlot1D.h>
    23 #include <VrpnClient.h>
    2423#include <Ahrs.h>
    2524#include <Imu.h>
     
    3130#include <Matrix.h>
    3231#include "MetaUsRangeFinder.h"
    33 #include "MetaVrpnObject.h"
     32
    3433
    3534using std::string;
  • trunk/lib/FlairMeta/src/Uav.h

    r215 r377  
    1111 */
    1212
    13 #ifndef HDSUAV_H
    14 #define HDSUAV_H
     13#ifndef UAV_H
     14#define UAV_H
    1515
    1616#include <Object.h>
    17 #include <UsRangeFinder.h>
    1817
    1918namespace flair {
     
    103102} // end namespace meta
    104103} // end namespace flair
    105 #endif // HDSUAV_H
     104#endif // UAV_H
  • trunk/lib/FlairSensorActuator/src/SimulatedUgvControls.cpp

    r376 r377  
    3131namespace actuator {
    3232
    33 SimulatedUgvControls::SimulatedUgvControls(const IODevice *parent,string name, uint32_t modelId,uint32_t deviceId)
    34     : UgvControls(parent,name) {
     33SimulatedUgvControls::SimulatedUgvControls(string name, uint32_t modelId,uint32_t deviceId)
     34    : UgvControls(name) {
    3535 
    36   shmem = new SharedMem((Thread *)this, ShMemName(modelId, deviceId),2 * sizeof(float)+sizeof(Time));
     36  shmem = new SharedMem(this, ShMemName(modelId, deviceId),2 * sizeof(float)+sizeof(Time));
    3737 
    3838  buf=(char*)malloc(2 * sizeof(float)+sizeof(Time));
     
    5757void SimulatedUgvControls::SetControls(float speed,float turn) {
    5858  float *values=(float*)buf;
    59   buf[0]=speed;
    60   buf[1]=turn;
     59  values[0]=speed;
     60  values[1]=turn;
    6161  Time time=GetTime();
    6262  memcpy(buf+2 * sizeof(float),&time,sizeof(Time));
     
    6767  output->GetMutex();
    6868  for (int i = 0; i < 2; i++) {
    69     output->SetValueNoMutex(i, 0, buf[i]);
     69    output->SetValueNoMutex(i, 0, values[i]);
    7070  }
    7171  output->ReleaseMutex();
  • trunk/lib/FlairSensorActuator/src/SimulatedUgvControls.h

    r376 r377  
    3636  * Construct a SimulatedUgvControls.
    3737  *
    38   * \param parent parent
    3938  * \param name name
    4039  * \param modelId Model id
    4140  * \param deviceId Imu id of the Model
    4241  */
    43   SimulatedUgvControls(const core::IODevice *parent,std::string name,
     42  SimulatedUgvControls(std::string name,
    4443          uint32_t modelId,uint32_t deviceId);
    4544
     
    5049  ~SimulatedUgvControls();
    5150
    52 private:
    53  
    5451  /*!
    5552  * \brief Set controls values
     
    6158  */
    6259  void SetControls(float speed,float turn);
     60private:
     61 
    6362 
    6463  char *buf;
  • trunk/lib/FlairSensorActuator/src/UgvControls.cpp

    r376 r377  
    1818#include "UgvControls.h"
    1919#include <Matrix.h>
     20#include <FrameworkManager.h>
     21#include <Tab.h>
     22#include <DataPlot1D.h>
    2023
    2124using namespace flair::core;
     25using namespace flair::gui;
    2226
    2327using std::string;
     
    2630namespace actuator {
    2731
    28 UgvControls::UgvControls(const IODevice *parent, string name)
    29     : IODevice(parent, name) {
     32UgvControls::UgvControls(string name)
     33    : IODevice(getFrameworkManager(), name) {
     34  mainTab = new Tab(getFrameworkManager()->GetTabWidget(), name);
    3035 
    3136  MatrixDescriptor *desc = new MatrixDescriptor(2, 1);
     
    4247
    4348void UgvControls::UseDefaultPlot(void) {
    44  
     49  DataPlot1D *speedPlot = new DataPlot1D(mainTab->NewRow(), "speed", -1, 1);
     50  speedPlot->AddCurve(output->Element(0));
     51  DataPlot1D *turnPlot = new DataPlot1D(mainTab->LastRowLastCol(), "turn", -1, 1);
     52  turnPlot->AddCurve(output->Element(1));
    4553}
    4654
  • trunk/lib/FlairSensorActuator/src/UgvControls.h

    r376 r377  
    1818namespace flair {
    1919namespace core {
    20 class Matrix;
     20  class Matrix;
     21}
     22namespace gui {
     23  class Tab;
    2124}
    2225}
     
    3538  * \brief Constructor
    3639  *
    37   * Construct a UgvControls.
     40  * Construct a UgvControls. It will be child of the FrameworkManager.
    3841  *
    39   * \param parent parent
    4042  * \param name name
    4143  */
    42   UgvControls(const core::IODevice *parent, std::string name);
     44  UgvControls(std::string name);
    4345
    4446  /*!
     
    6365  core::Matrix *Output(void) const;
    6466 
     67  /*!
     68  * \brief Set controls values
     69  *
     70  * \param speed speed value
     71  * \param turn turn value
     72  */
     73  virtual void SetControls(float speed,float turn)=0;
     74 
    6575protected:
    6676  core::Matrix *output;
     
    7585  */
    7686  void UpdateFrom(const core::io_data *data){};
    77 
    78   /*!
    79   * \brief Set controls values
    80   *
    81   * \param speed speed value
    82   * \param turn turn value
    83   */
    84   virtual void SetControls(float speed,float turn)=0;
    8587 
    86 
     88  gui::Tab *mainTab;
    8789};
    8890} // end namespace actuator
  • trunk/lib/FlairSimulator/src/TwoWheelRobot.cpp

    r376 r377  
    5050  m = new DoubleSpinBox(setup_tab->NewRow(), "mass (kg):", 0, 20, 0.1,1,0.2);
    5151  size = new DoubleSpinBox(setup_tab->NewRow(), "size (m):", 0, 20, 0.1,1,0.1);
     52  t_speed = new DoubleSpinBox(setup_tab->NewRow(), "translational speed (m/s):",
     53                              0, 5, 0.1);
     54  r_speed = new DoubleSpinBox(setup_tab->NewRow(), "rotational speed (deg/s):",
     55                              0, 180, 10);
    5256 
    5357 
     
    5660  bodyColorG = new SpinBox(visual_tab->LastRowLastCol(), "arm color (G):", 0, 255, 1,0);
    5761  bodyColorB = new SpinBox(visual_tab->LastRowLastCol(), "arm color (B):", 0, 255, 1,0);
     62 
     63 
    5864 
    5965  controls = new SimuUgvControls(this, name, modelId,0);
     
    155161
    156162  controls->GetControls(&speed,&turn,&motorTime);
    157           
     163         
    158164  // compute quaternion from W
    159165  // Quaternion derivative: dQ = 0.5*(  Q*Qw)
    160166  state[0].W.x=0;
    161167  state[0].W.y=0;
    162   state[0].W.z=turn;
     168  state[0].W.z=turn*r_speed->Value();
    163169  Quaternion dQ = state[-1].Quat.GetDerivative(state[0].W);
    164170
     
    167173  state[0].Quat.Normalize();
    168174
    169   Vector3D<double> dir = Vector3D<double>(speed,0,0);
     175  Vector3D<double> dir = Vector3D<double>(speed*t_speed->Value(),0,0);
    170176  dir.Rotate(state[0].Quat);
    171177  state[0].Pos = state[-1].Pos + dT() * dir;
  • trunk/lib/FlairSimulator/src/TwoWheelRobot.h

    r375 r377  
    6464#endif
    6565  gui::SpinBox *bodyColorR,*bodyColorG,*bodyColorB;
    66   gui::DoubleSpinBox *size,*m;
     66  gui::DoubleSpinBox *size,*m,*t_speed,*r_speed;
    6767  actuator::SimuUgvControls *controls;
    6868
Note: See TracChangeset for help on using the changeset viewer.