Skip to content

Commit

Permalink
Merge branch 'master' into force_mode_arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
URJala authored Oct 2, 2024
2 parents 83662d6 + 173f193 commit 9ca40b0
Show file tree
Hide file tree
Showing 10 changed files with 794 additions and 95 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
Changelog for package ur_client_library
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1.4.0 (2024-09-10)
------------------
* Ensure that the targets are reachable within the robots limits (`#184 <https://github.com/UniversalRobots/Universal_Robots_Client_Library/issues/184>`_)
* Analog domain (`#211 <https://github.com/UniversalRobots/Universal_Robots_Client_Library/issues/211>`_)
* Fix clang compilation error (`#210 <https://github.com/UniversalRobots/Universal_Robots_Client_Library/issues/210>`_)
* Moved reset of speed slider to correct teardown function, so that it … (`#206 <https://github.com/UniversalRobots/Universal_Robots_Client_Library/issues/206>`_)
…resets between each test.
* [doc] Fix syntax in example.rst (`#207 <https://github.com/UniversalRobots/Universal_Robots_Client_Library/issues/207>`_)
* [doc] Migrate documentation to sphinx (`#95 <https://github.com/UniversalRobots/Universal_Robots_Client_Library/issues/95>`_)
* Contributors: Felix Exner, Mads Holm Peters, Remi Siffert, URJala

1.3.7 (2024-06-03)
------------------
* [ci] Update CI
Expand Down
48 changes: 34 additions & 14 deletions examples/full_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,20 @@ int main(int argc, char* argv[])

g_my_driver->startRTDECommunication();

double increment = 0.01;
// Increment depends on robot version
double increment_constant = 0.0005;
if (g_my_driver->getVersion().major < 5)
{
increment_constant = 0.002;
}
double increment = increment_constant;

bool passed_slow_part = false;
bool passed_fast_part = false;
bool first_pass = true;
bool passed_negative_part = false;
bool passed_positive_part = false;
URCL_LOG_INFO("Start moving the robot");
while (!(passed_slow_part && passed_fast_part))
urcl::vector6d_t joint_target = { 0, 0, 0, 0, 0, 0 };
while (!(passed_positive_part && passed_negative_part))
{
// Read latest RTDE package. This will block for a hard-coded timeout (see UrDriver), so the
// robot will effectively be in charge of setting the frequency of this loop.
Expand All @@ -139,28 +147,40 @@ int main(int argc, char* argv[])
throw std::runtime_error(error_msg);
}

// Simple motion command of last joint
if (g_joint_positions[5] > 3)
if (first_pass)
{
joint_target = g_joint_positions;
first_pass = false;
}

// Open loop control. The target is incremented with a constant each control loop
if (passed_positive_part == false)
{
passed_fast_part = increment > 0.01 || passed_fast_part;
increment = -3; // this large jump will activate speed scaling
increment = increment_constant;
if (g_joint_positions[5] >= 2)
{
passed_positive_part = true;
}
}
else if (g_joint_positions[5] < -3)
else if (passed_negative_part == false)
{
passed_slow_part = increment < 0.01 || passed_slow_part;
increment = 0.02;
increment = -increment_constant;
if (g_joint_positions[5] <= 0)
{
passed_negative_part = true;
}
}
g_joint_positions[5] += increment;
joint_target[5] += increment;
// Setting the RobotReceiveTimeout time is for example purposes only. This will make the example running more
// reliable on non-realtime systems. Use with caution in productive applications.
bool ret = g_my_driver->writeJointCommand(g_joint_positions, comm::ControlMode::MODE_SERVOJ,
bool ret = g_my_driver->writeJointCommand(joint_target, comm::ControlMode::MODE_SERVOJ,
RobotReceiveTimeout::millisec(100));
if (!ret)
{
URCL_LOG_ERROR("Could not send joint command. Is the robot in remote control?");
return 1;
}
URCL_LOG_DEBUG("data_pkg:\n%s", data_pkg->toString());
URCL_LOG_DEBUG("data_pkg:\n%s", data_pkg->toString().c_str());
}
else
{
Expand Down
7 changes: 6 additions & 1 deletion include/ur_client_library/rtde/rtde_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "ur_client_library/rtde/data_package.h"
#include "ur_client_library/comm/stream.h"
#include "ur_client_library/queue/readerwriterqueue.h"
#include "ur_client_library/ur/datatypes.h"
#include <thread>
#include <mutex>

Expand Down Expand Up @@ -118,10 +119,14 @@ class RTDEWriter
*
* \param output_pin The pin to change
* \param value The new value, it should be between 0 and 1, where 0 is 4mA and 1 is 20mA.
* \param type The domain for the output can be eitherAnalogOutputType::CURRENT or AnalogOutputType::VOLTAGE or
* AnalogOutputType::SET_ON_TEACH_PENDANT. In the latter case the domain is left untouched and the domain configured
* on the teach pendant will be used.
*
* \returns Success of the package creation
*/
bool sendStandardAnalogOutput(uint8_t output_pin, double value);
bool sendStandardAnalogOutput(uint8_t output_pin, double value,
const AnalogOutputType type = AnalogOutputType::SET_ON_TEACH_PENDANT);

/*!
* \brief Creates a package to request setting a new value for an input_bit_register
Expand Down
7 changes: 7 additions & 0 deletions include/ur_client_library/ur/datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ enum class SafetyStatus : int8_t // Only available on 3.10/5.4
SYSTEM_THREE_POSITION_ENABLING_STOP = 13
};

enum class AnalogOutputType : int8_t
{
SET_ON_TEACH_PENDANT = -1,
CURRENT = 0,
VOLTAGE = 1
};

inline std::string robotModeString(const RobotMode& mode)
{
switch (mode)
Expand Down
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>ur_client_library</name>
<version>1.3.7</version>
<version>1.4.0</version>
<description>Standalone C++ library for accessing Universal Robots interfaces. This has been forked off the ur_robot_driver.</description>
<author>Thomas Timm Andersen</author>
<author>Simon Rasmussen</author>
Expand Down
Loading

0 comments on commit 9ca40b0

Please sign in to comment.