GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/sot-tiago-steel-controller.cpp Lines: 0 29 0.0 %
Date: 2022-09-12 09:50:59 Branches: 0 110 0.0 %

Line Branch Exec Source
1
/*
2
 * Copyright 2018,
3
 *
4
 * Joseph Mirabel
5
 *
6
 * LAAS, CNRS
7
 *
8
 * This file is part of TIAGOController.
9
 * TIAGOController is a free software,
10
 *
11
 */
12
13
#include <pinocchio/fwd.hpp>
14
#include <sot/core/debug.hh>
15
16
/* TiagoSteel is the instance of TIAGO named "steel" */
17
#define ROBOTNAME std::string("TIAGOSTEEL")
18
19
#include "sot-tiago-steel-controller.hh"
20
21
const std::string SoTTiagoSteelController::LOG_PYTHON_TIAGOSTEEL =
22
    "/tmp/TiagoSteelController_python.out";
23
24
SoTTiagoSteelController::SoTTiagoSteelController()
25
    : SoTTiagoController(ROBOTNAME), withWheels_(false) {
26
  ros::NodeHandle nh;
27
  nh.getParam("/sot_controller/use_mobile_base", withWheels_);
28
  ROS_INFO_STREAM("Loading SoT Tiago steel controller with"
29
                  << (withWheels_ ? "" : "out") << " wheel");
30
  if (withWheels_) {
31
    // Control wheels in velocity.
32
    // 6 and 7 correspond to left and right wheel joints.
33
    device_->setLeftWheelIndex(6);
34
    device_->setRightWheelIndex(7);
35
  }
36
  /// Read /sot_controller/dt to know what is the control period
37
  if (nh.hasParam("/sot_controller/dt")) {
38
    double dt;
39
    nh.getParam("/sot_controller/dt", dt);
40
    device_->setTimeStep(dt);
41
    ROS_INFO_STREAM("Set Tiago control period to: " << dt);
42
  }
43
  startupPython();
44
  interpreter_->startRosService();
45
}
46
47
void SoTTiagoSteelController::startupPython() {
48
  SoTTiagoController::startupPython();
49
  std::ofstream aof(LOG_PYTHON_TIAGOSTEEL.c_str());
50
  runPython(aof, "import dynamic_graph.sot.tiago.steel.prologue",
51
            *interpreter_);
52
  if (withWheels_)
53
    runPython(aof,
54
              "robot = dynamic_graph.sot.tiago.steel.prologue.makeRobot "
55
              "(with_wheels=True)",
56
              *interpreter_);
57
  else
58
    runPython(aof,
59
              "robot = dynamic_graph.sot.tiago.steel.prologue.makeRobot "
60
              "(with_wheels=False)",
61
              *interpreter_);
62
  aof.close();
63
}
64
65
extern "C" {
66
dgsot::AbstractSotExternalInterface *createSotExternalInterface() {
67
  return new SoTTiagoSteelController();
68
}
69
}
70
71
extern "C" {
72
void destroySotExternalInterface(dgsot::AbstractSotExternalInterface *p) {
73
  delete p;
74
}
75
}