Skip to content

Commit

Permalink
Merge pull request #3 from mahilab/dev
Browse files Browse the repository at this point in the history
Merge dev branch
  • Loading branch information
epezent authored Jan 22, 2019
2 parents 1094f07 + 37fcd1a commit 25942c4
Show file tree
Hide file tree
Showing 172 changed files with 2,711 additions and 820 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ file (GLOB SRC_BASE
file(GLOB SRC_COMMUNICATIONS
"${CMAKE_SOURCE_DIR}/include/MEL/Communications/*.hpp"
"${CMAKE_SOURCE_DIR}/src/MEL/Communications/*.cpp"
"${CMAKE_SOURCE_DIR}/src/MEL/Communications/Detail/*.h"
"${CMAKE_SOURCE_DIR}/src/MEL/Communications/Detail/*.c"
)

file(GLOB SRC_CORE
Expand Down Expand Up @@ -256,7 +258,7 @@ endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3") # all warnings
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") # warning level 4
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") # warning level 4
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") # multicore build
endif()

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
MIT License

MEL - Mechatronics Engine & Library
Copyright (c) 2018 Mechatronics and Haptic Interfaces Lab - Rice University
Copyright (c) 2019 Mechatronics and Haptic Interfaces Lab - Rice University

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion bindings/c#/MelNet.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// MIT License
//
// MEL - Mechatronics Engine & Library
// Copyright (c) 2018 Mechatronics and Haptic Interfaces Lab - Rice University
// Copyright (c) 2019 Mechatronics and Haptic Interfaces Lab - Rice University
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion bindings/c#/MelShare.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// MIT License
//
// MEL - Mechatronics Engine & Library
// Copyright (c) 2018 Mechatronics and Haptic Interfaces Lab - Rice University
// Copyright (c) 2019 Mechatronics and Haptic Interfaces Lab - Rice University
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/MelNet.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2018 Mechatronics and Haptic Interfaces Lab - Rice University
# Copyright (c) 2019 Mechatronics and Haptic Interfaces Lab - Rice University
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/MelShare.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2018 Mechatronics and Haptic Interfaces Lab - Rice University
# Copyright (c) 2019 Mechatronics and Haptic Interfaces Lab - Rice University
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/Mutex.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2018 Mechatronics and Haptic Interfaces Lab - Rice University
# Copyright (c) 2019 Mechatronics and Haptic Interfaces Lab - Rice University
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 3 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mel_example(ctrl_c_handling)
mel_example(datalog)
mel_example(filter)
mel_example(options)
mel_example(pid)
mel_example(lockables)
mel_example(ring_buffer)
mel_example(logger)
Expand All @@ -22,6 +23,7 @@ mel_example(melshare)
mel_example(chat)
mel_example(comms_server)
mel_example(virtual_daq)
mel_example(serial)

if(WIN32)
mel_example(limiter)
Expand All @@ -34,6 +36,7 @@ if(QUANSER)
mel_example(q8usb_loopback)
mel_example(haptic_paddle)
mel_example(overview)
mel_example(ati_sensor)
endif()

if(NI_ARM)
Expand Down
94 changes: 94 additions & 0 deletions examples/ex_ati_sensor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// MIT License
//
// MEL - Mechatronics Engine & Library
// Copyright (c) 2019 Mechatronics and Haptic Interfaces Lab - Rice University
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// Author(s): Evan Pezent ([email protected])

#include <MEL/Daq/Quanser/Q8Usb.hpp>
#include <MEL/Core/Timer.hpp>
#include <MEL/Communications/MelShare.hpp>
#include <MEL/Core/Console.hpp>
#include <MEL/Devices/AtiSensor.hpp>
#include <MEL/Devices/Windows/Keyboard.hpp>

using namespace mel;

ctrl_bool stop(false);
bool handler(CtrlEvent event) {
if (event == CtrlEvent::CtrlC)
stop = true;
return true;
}

int main(int argc, char* argv[]) {

// register CTRL-C handler
register_ctrl_handler(handler);

// create and open Q8
Q8Usb q8;
q8.open();

// create ATI sensor
AtiSensor ati;
ati.set_channels(q8.AI[{0, 1, 2, 3, 4, 5}]);
ati.load_calibration("FT12345.cal");

// alternatively, the calibration can set explicitly
// AtiSensor::Calibration cal;
// cal.Fx = { 0.01517, 0.01800, -0.02466, -1.69832, 0.05208, 1.68355 };
// cal.Fy = { 0.07231, 2.01105, -0.02110, -0.95833, -0.05133, -0.99616 };
// cal.Fz = { 1.86652, -0.03457, 1.90079, -0.02482, 1.89478, -0.03528 };
// cal.Tx = { 0.37651, 12.19008, 10.54613, -5.96091, -10.70737, -5.83644 };
// cal.Ty = { -12.07505, 0.17459, 6.36129, 10.18467, 5.70347, -10.34754 };
// cal.Tz = { 0.09187, 7.34562, 0.09166, 6.92461, 0.52790, 7.07804 };
// ati.set_calibration(cal);

// make MelShares for scoping
MelShare ms_volts("ati_volts");
MelShare ms_force("ati_force");
MelShare ms_torque("ati_torque");

// enable Q8Usb
q8.enable();

// make timer
Timer timer(hertz(1000));

// start sampling loop
while (!stop) {

// update input
q8.AI.update();

// zero ATI if user presses Z key
if (Keyboard::is_key_pressed(Key::Z))
ati.zero();

// write voltages, forces, and torques to MelShares for scoping
ms_volts.write_data({ q8.AI[0], q8.AI[1], q8.AI[2], q8.AI[3], q8.AI[4], q8.AI[5] });
ms_force.write_data({ ati.get_force(AxisX), ati.get_force(AxisY), ati.get_force(AxisZ) });
ms_torque.write_data(ati.get_torques());

// wait timer
timer.wait();
}

// disable and close Q8
q8.disable();
q8.close();

return 0;

}
2 changes: 1 addition & 1 deletion examples/ex_chat.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// MIT License
//
// MEL - Mechatronics Engine & Library
// Copyright (c) 2018 Mechatronics and Haptic Interfaces Lab - Rice University
// Copyright (c) 2019 Mechatronics and Haptic Interfaces Lab - Rice University
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/ex_comms_server.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// MIT License
//
// MEL - Mechatronics Engine & Library
// Copyright (c) 2018 Mechatronics and Haptic Interfaces Lab - Rice University
// Copyright (c) 2019 Mechatronics and Haptic Interfaces Lab - Rice University
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/ex_ctrl_c_handling.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// MIT License
//
// MEL - Mechatronics Engine & Library
// Copyright (c) 2018 Mechatronics and Haptic Interfaces Lab - Rice University
// Copyright (c) 2019 Mechatronics and Haptic Interfaces Lab - Rice University
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/ex_datalog.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// MIT License
//
// MEL - Mechatronics Engine & Library
// Copyright (c) 2018 Mechatronics and Haptic Interfaces Lab - Rice University
// Copyright (c) 2019 Mechatronics and Haptic Interfaces Lab - Rice University
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/ex_filter.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// MIT License
//
// MEL - Mechatronics Engine & Library
// Copyright (c) 2018 Mechatronics and Haptic Interfaces Lab - Rice University
// Copyright (c) 2019 Mechatronics and Haptic Interfaces Lab - Rice University
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
53 changes: 20 additions & 33 deletions examples/ex_haptic_paddle.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// MIT License
//
// MEL - Mechatronics Engine & Library
// Copyright (c) 2018 Mechatronics and Haptic Interfaces Lab - Rice University
// Copyright (c) 2019 Mechatronics and Haptic Interfaces Lab - Rice University
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -43,23 +43,17 @@ using namespace mel;
class HallEffectSensor : public PositionSensor {
public:
/// Constructor
HallEffectSensor(const std::string& name,
AnalogInput::Channel ai,
HallEffectSensor(AnalogInput::Channel ai,
double gain = 0.0,
double offset = 0.0)
: PositionSensor(name), ai_(ai), gain_(gain), offset_(offset) { }
: ai_(ai), gain_(gain), offset_(offset) { }

/// Gets the position of the hall effect sensor in [rad]
double get_position() override {
position_ = ai_.get_value() * gain_ + offset_;
return position_;
}

private:

bool on_enable() override { return true; }
bool on_disable() override { return true; }

public:
AnalogInput::Channel ai_; ///< voltage read from hall effect sensor
double gain_; ///< calibration gain [rad/V]
Expand All @@ -85,14 +79,30 @@ class HapticPaddle : public Robot {
// init motor
motor_("pitman_9434", 0.0229, amp_, Limiter(1.8821, 12.0, seconds(1))),
// init position sensor
position_sensor_("honeywell_ss49et", ai),
position_sensor_(ai),
// init virtual velocity sensor
velocity_sensor_("honeywell_ss49et", position_sensor_)
{
// create joint
add_joint(Joint("paddle_joint_0", &motor_, 0.713 / 6.250, &position_sensor_, 1.0,
&velocity_sensor_, 1.0, {-50 * DEG2RAD, 50 * DEG2RAD},
500 * DEG2RAD, 1.0));
// load calibration
std::ifstream file;
file.open("calibration.txt");
if (file.is_open()) {
// read in previous calibration
double gain, offset;
file >> gain >> offset;
position_sensor_.offset_ = offset * DEG2RAD;
position_sensor_.gain_ = gain * DEG2RAD;
LOG(Info) << "Imported Haptic Paddle hall effect sensor calibration";
file.close();
}
else {
file.close();
calibrate();
}
}

/// Interactively calibrates the hall effect sensor in the console
Expand Down Expand Up @@ -120,29 +130,6 @@ class HapticPaddle : public Robot {
file.close();
}

private:

/// Overrides the default Robot::enable function with some custom logic
bool on_enable() override {
// load calibration
std::ifstream file;
file.open("calibration.txt");
if (file.is_open()) {
// read in previous calibration
double gain, offset;
file >> gain >> offset;
position_sensor_.offset_ = offset * DEG2RAD;
position_sensor_.gain_ = gain * DEG2RAD;
LOG(Info) << "Imported Haptic Paddle hall effect sensor calibration";
file.close();
}
else {
file.close();
calibrate();
}
return true;
}

private:
Amplifier amp_;
Motor motor_;
Expand Down
2 changes: 1 addition & 1 deletion examples/ex_keyboard.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// MIT License
//
// MEL - Mechatronics Engine & Library
// Copyright (c) 2018 Mechatronics and Haptic Interfaces Lab - Rice University
// Copyright (c) 2019 Mechatronics and Haptic Interfaces Lab - Rice University
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/ex_limiter.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// MIT License
//
// MEL - Mechatronics Engine & Library
// Copyright (c) 2018 Mechatronics and Haptic Interfaces Lab - Rice University
// Copyright (c) 2019 Mechatronics and Haptic Interfaces Lab - Rice University
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/ex_lockables.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// MIT License
//
// MEL - Mechatronics Engine & Library
// Copyright (c) 2018 Mechatronics and Haptic Interfaces Lab - Rice University
// Copyright (c) 2019 Mechatronics and Haptic Interfaces Lab - Rice University
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/ex_logger.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// MIT License
//
// MEL - Mechatronics Engine & Library
// Copyright (c) 2018 Mechatronics and Haptic Interfaces Lab - Rice University
// Copyright (c) 2019 Mechatronics and Haptic Interfaces Lab - Rice University
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/ex_math.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// MIT License
//
// MEL - Mechatronics Engine & Library
// Copyright (c) 2018 Mechatronics and Haptic Interfaces Lab - Rice University
// Copyright (c) 2019 Mechatronics and Haptic Interfaces Lab - Rice University
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/ex_melnet.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// MIT License
//
// MEL - Mechatronics Engine & Library
// Copyright (c) 2018 Mechatronics and Haptic Interfaces Lab - Rice University
// Copyright (c) 2019 Mechatronics and Haptic Interfaces Lab - Rice University
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit 25942c4

Please sign in to comment.