Skip to content

Commit 48e072e

Browse files
committed
Use enable_external_ft_sensor on old software versions
In the past there was enable_external_ft_sensor which had an error. On really old robot software versions where the fixed ft_rtde_input_enable command is not available, we have to fall back to that.
1 parent 641f876 commit 48e072e

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

resources/external_control.urscript

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,21 @@ thread script_commands():
803803
str_cat(sensor_mass, str_cat(", ",
804804
str_cat(to_str(sensor_offset), str_cat(", ",
805805
str_cat(to_str(sensor_cog), ")"))))))))
806+
{% if ROBOT_SOFTWARE_VERSION >= v5.9.1 %}
806807
ft_rtde_input_enable(enabled, sensor_mass, sensor_offset, sensor_cog)
808+
{% elif ROBOT_SOFTWARE_VERSION < v5.0.0 %}
809+
{% if ROBOT_SOFTWARE_VERSION >= v3.14.1 %}
810+
ft_rtde_input_enable(enabled, sensor_mass, sensor_offset, sensor_cog)
811+
{% else %}
812+
# PolyScope earlier than 3.14.1
813+
# This has a known error that the resulting torques are computed with opposite sign.
814+
enable_external_ft_sensor(enabled, sensor_mass, sensor_offset, sensor_cog)
815+
{% endif %}
816+
{% else %}
817+
# PolyScope 5.0.0 - 5.9.0
818+
# This has a known error that the resulting torques are computed with opposite sign.
819+
enable_external_ft_sensor(enabled, sensor_mass, sensor_offset, sensor_cog)
820+
{% endif %}
807821
end
808822
end
809823
end

tests/test_script_reader.cpp

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#include <gtest/gtest.h>
3434
#include "ur_client_library/control/script_reader.h"
3535
#include "ur_client_library/ur/version_information.h"
36+
#include "ur_client_library/control/reverse_interface.h"
37+
#include "ur_client_library/control/trajectory_point_interface.h"
3638

3739
#include <fstream>
3840

@@ -446,4 +448,45 @@ TEST_F(ScriptReaderTest, Example)
446448
processed_script = reader.readScriptFile(existing_script_file, data);
447449
expected_script = " textmsg(\"torque control is a very cool feature!\")";
448450
EXPECT_EQ(processed_script, expected_script);
449-
}
451+
}
452+
453+
TEST_F(ScriptReaderTest, TestParsingExternalControl)
454+
{
455+
std::string existing_script_file = "../resources/external_control.urscript";
456+
457+
ScriptReader reader;
458+
ScriptReader::DataDict data;
459+
data["BEGIN_REPLACE"] = "";
460+
data["JOINT_STATE_REPLACE"] = std::to_string(urcl::control::ReverseInterface::MULT_JOINTSTATE);
461+
data["TIME_REPLACE"] = std::to_string(urcl::control::TrajectoryPointInterface::MULT_TIME);
462+
data["SERVO_J_REPLACE"] = "lookahead_time=0.03, gain=2000";
463+
data["SERVER_IP_REPLACE"] = "1.2.3.4";
464+
data["SERVER_PORT_REPLACE"] = "50001";
465+
data["TRAJECTORY_SERVER_PORT_REPLACE"] = "50003";
466+
data["SCRIPT_COMMAND_SERVER_PORT_REPLACE"] = "50004";
467+
468+
data["ROBOT_SOFTWARE_VERSION"] = urcl::VersionInformation::fromString("3.12.1");
469+
std::string processed_script = reader.readScriptFile(existing_script_file, data);
470+
std::string expected_pattern = "enable_external_ft_sensor(enabled, sensor_mass, sensor_offset, sensor_cog)";
471+
EXPECT_NE(processed_script.find(expected_pattern), std::string::npos);
472+
473+
data["ROBOT_SOFTWARE_VERSION"] = urcl::VersionInformation::fromString("5.8.0");
474+
processed_script = reader.readScriptFile(existing_script_file, data);
475+
expected_pattern = "enable_external_ft_sensor(enabled, sensor_mass, sensor_offset, sensor_cog)";
476+
EXPECT_NE(processed_script.find(expected_pattern), std::string::npos);
477+
478+
data["ROBOT_SOFTWARE_VERSION"] = urcl::VersionInformation::fromString("3.14.1");
479+
processed_script = reader.readScriptFile(existing_script_file, data);
480+
expected_pattern = "ft_rtde_input_enable(enabled, sensor_mass, sensor_offset, sensor_cog)";
481+
EXPECT_NE(processed_script.find(expected_pattern), std::string::npos);
482+
483+
data["ROBOT_SOFTWARE_VERSION"] = urcl::VersionInformation::fromString("5.9.1");
484+
processed_script = reader.readScriptFile(existing_script_file, data);
485+
expected_pattern = "ft_rtde_input_enable(enabled, sensor_mass, sensor_offset, sensor_cog)";
486+
EXPECT_NE(processed_script.find(expected_pattern), std::string::npos);
487+
488+
data["ROBOT_SOFTWARE_VERSION"] = urcl::VersionInformation::fromString("10.7.0");
489+
processed_script = reader.readScriptFile(existing_script_file, data);
490+
expected_pattern = "ft_rtde_input_enable(enabled, sensor_mass, sensor_offset, sensor_cog)";
491+
EXPECT_NE(processed_script.find(expected_pattern), std::string::npos);
492+
}

0 commit comments

Comments
 (0)