Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ros2 executive #817

Open
wants to merge 35 commits into
base: ros2
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b19c25c
Initial executive work.
kbrowne15 Mar 3, 2023
87e66c8
More executive work.
kbrowne15 Mar 9, 2023
028f698
Merge branch 'ros2' into ros2-executive
kbrowne15 Mar 27, 2023
69a7e71
More executive progress
kbrowne15 Mar 30, 2023
00b3244
More executive work
kbrowne15 Mar 31, 2023
35569b3
Executive is compiling.
kbrowne15 Apr 3, 2023
0043cfd
Started working on the executive tools.
kbrowne15 Apr 3, 2023
ec15ce9
Finished executive data to disk tool.
kbrowne15 Apr 3, 2023
f4ecd6a
Merge branch 'ros2' into ros2-executive
kbrowne15 Apr 3, 2023
a971482
More executive tools work.
kbrowne15 Apr 3, 2023
1335853
More progress
kbrowne15 Apr 3, 2023
3514e4c
COnverted 2 more executive tools to ros2
kbrowne15 Apr 4, 2023
1ae1fc4
Converted the executive simple move tool to ros2
kbrowne15 Apr 5, 2023
a4db604
More progress.
kbrowne15 Apr 6, 2023
dd60358
More progress
kbrowne15 Apr 10, 2023
340f1ba
More teleop tool progress
kbrowne15 Apr 11, 2023
0bdf416
Finished converting executive tools to ros2
kbrowne15 Apr 17, 2023
d1ff874
Transformed sys_monitor, needed to not start in FAULT mode
ana-GT Jun 1, 2024
49ede36
Hanging in pmc driver
ana-GT Jun 3, 2024
fa0cf5f
Deleted most Debug messages. ConfigClient works when adding a new nod…
ana-GT Jun 4, 2024
d94d9dd
Put back the configClient Set function in executive and deleted debug…
ana-GT Jun 4, 2024
e9c6613
Added executive
ana-GT Jun 4, 2024
4837921
Delete more debug messages
ana-GT Jun 5, 2024
1502d6c
Added lines to pull gazebo >= 11.13, which supports wideanglecamera f…
ana-GT Jun 5, 2024
59e1080
Added fix on time calculation that was making EKF come with wrong tim…
ana-GT Jun 5, 2024
8e18178
Cleaned up code. Works for undock and motion. Cameras are also visible
ana-GT Jun 5, 2024
0515af6
Added initial changes for ns. Still failing in the spawn
ana-GT Jun 6, 2024
7cbb0fa
Added spawn for ns and no-ns
ana-GT Jun 6, 2024
4a35aa8
Works for namespaced bumble and non-ns robot
ana-GT Jun 6, 2024
ca478be
Merge pull request #1 from traclabs/ros2_executive_ns
ana-GT Jun 6, 2024
b5f5452
Forgot to add the namespace for synthetic
ana-GT Jun 6, 2024
c8360ed
Merge branch 'ros2_executive_ns' into ros2_executive
ana-GT Jun 6, 2024
ef66e54
Merge remote-tracking branch 'upstream/ros2' into ros2_executive
ana-GT Dec 11, 2024
08a8c2c
Added time at the end of assertFault
ana-GT Dec 11, 2024
9b154a7
Merge pull request #2 from traclabs/sync/merge_latest_nasa_ros2
ana-GT Dec 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Converted the executive simple move tool to ros2
  • Loading branch information
kbrowne15 committed Apr 5, 2023
commit 1ae1fc4eeff2fe610f3762f7be06147079f42794
73 changes: 39 additions & 34 deletions management/executive/tools/simple_move.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,68 +16,73 @@
* under the License.
*/

#include <ros/ros.h>

#include <ff_msgs/CommandArg.h>
#include <ff_msgs/CommandConstants.h>
#include <ff_msgs/CommandStamped.h>
#include <ff_msgs/AckCompletedStatus.h>
#include <ff_msgs/AckStamped.h>
#include <ff_msgs/AckStatus.h>
#include <ff_common/ff_names.h>
#include <ff_common/ff_ros.h>

#include <ff_msgs/msg/command_arg.hpp>
#include <ff_msgs/msg/command_constants.hpp>
#include <ff_msgs/msg/command_stamped.hpp>
#include <ff_msgs/msg/ack_completed_status.hpp>
#include <ff_msgs/msg/ack_stamped.hpp>
#include <ff_msgs/msg/ack_status.hpp>

#include <string>

FF_DEFINE_LOGGER("simple_move")

std::string unique_cmd_id;

void AckCallback(ff_msgs::AckStampedConstPtr const& Ack) {
void AckCallback(ff_msgs::msg::AckStamped::SharedPtr const Ack) {
// Check if the ack corresponds to the command we sent
if (Ack->cmd_id == unique_cmd_id) {
// Check if command hasn't completed
if (Ack->completed_status.status == ff_msgs::AckCompletedStatus::NOT) {
ROS_INFO("Move command is being executed and has not completed.");
if (Ack->completed_status.status == ff_msgs::msg::AckCompletedStatus::NOT) {
FF_INFO("Move command is being executed and has not completed.");
return; // Return so we don't shut down prematurely
} else if (Ack->completed_status.status == ff_msgs::AckCompletedStatus::OK) {
} else if (Ack->completed_status.status ==
ff_msgs::msg:::AckCompletedStatus::OK) {
// Command completed successfully
ROS_INFO("Move command completed successfully!");
FF_INFO("Move command completed successfully!");
} else { // Command failed
ROS_INFO("Move command failed! Message: %s", Ack->message.c_str());
FF_INFO("Move command failed! Message: %s", Ack->message.c_str());
}
}

// Command finshed so exit
ros::shutdown();
rclcpp::shutdown();
}

int main(int argc, char** argv) {
ros::init(argc, argv, "teleop_pub");
ros::NodeHandle nh;
rclcpp::init(argc, argv);
NodeHandle nh;

if (argc <= 1) {
ROS_ERROR("Error! Must provide x, y, and z as arguments!");
FF_ERROR("Error! Must provide x, y, and z as arguments!");
return -1;
}

// Make publisher to publish the command
ros::Publisher cmd_publisher;
cmd_publisher = nh.advertise<ff_msgs::CommandStamped>(TOPIC_COMMAND, 10);
Publisher<ff_msgs::msg::CommandStamped> cmd_publisher =
FF_CREATE_PUBLISHER(nh, ff_msgs::msg::CommandStamped, TOPIC_COMMAND, 10);

// Make subscriber to receive command acks to see if the command completed
// successfully
ros::Subscriber ack_subscriber;
ack_subscriber = nh.subscribe(TOPIC_MANAGEMENT_ACK, 10, &AckCallback);
Subscriber<ff_msgs::msg::AckStamped> ack_subscriber =
FF_CREATE_SUBSCRIBER(nh,
ff_msgs::msg::AckStamped,
TOPIC_MANAGEMENT_ACK,
10,
std::bind(&AckCallback, std::placeholders::_1));

// Make ros command message to send to the executive
ff_msgs::CommandStamped move_cmd;

move_cmd.header.stamp = ros::Time::now();
ff_msgs::msg::CommandStamped move_cmd;

// Command names listed in CommandConstants.h
move_cmd.cmd_name = ff_msgs::CommandConstants::CMD_NAME_SIMPLE_MOVE6DOF;
move_cmd.cmd_name = ff_msgs::msg::CommandConstants::CMD_NAME_SIMPLE_MOVE6DOF;

// Command id needs to be a unique id that you will use make sure the command
// was executed, usually a combination of username and timestamp
unique_cmd_id = "guest_science" + std::to_string(move_cmd.header.stamp.sec);
unique_cmd_id = "guest_science" + std::to_string(nh->get_clock()->now());
move_cmd.cmd_id = unique_cmd_id;

// Source of the command, set to guest_science so that the system knows that
Expand All @@ -92,24 +97,24 @@ int main(int argc, char** argv) {

// Set frame to be world, although I don't believe frame is being used so you
// can really set it to anything
move_cmd.args[0].data_type = ff_msgs::CommandArg::DATA_TYPE_STRING;
move_cmd.args[0].data_type = ff_msgs::msg::CommandArg::DATA_TYPE_STRING;
move_cmd.args[0].s = "world";

// Set location where you want Astrobee to go to
move_cmd.args[1].data_type = ff_msgs::CommandArg::DATA_TYPE_VEC3d;
move_cmd.args[1].data_type = ff_msgs::msg::CommandArg::DATA_TYPE_VEC3d;
move_cmd.args[1].vec3d[0] = atof(argv[1]); // x
move_cmd.args[1].vec3d[1] = atof(argv[2]); // y
move_cmd.args[1].vec3d[2] = atof(argv[3]); // z (This axis may not currently work

// Tolerance not used! If you want to set the tolerance, you need to use the
// set operational limits command. I set tolerance to 0
move_cmd.args[2].data_type = ff_msgs::CommandArg::DATA_TYPE_VEC3d;
move_cmd.args[2].data_type = ff_msgs::msg::CommandArg::DATA_TYPE_VEC3d;
move_cmd.args[2].vec3d[0] = 0;
move_cmd.args[2].vec3d[1] = 0;
move_cmd.args[2].vec3d[2] = 0;

// Target attitude, quaternion, only the first 4 values are used
move_cmd.args[3].data_type = ff_msgs::CommandArg::DATA_TYPE_MAT33f;
move_cmd.args[3].data_type = ff_msgs::msg::CommandArg::DATA_TYPE_MAT33f;
move_cmd.args[3].mat33f[0] = 0;
move_cmd.args[3].mat33f[1] = 0;
move_cmd.args[3].mat33f[2] = 0;
Expand All @@ -121,9 +126,9 @@ int main(int argc, char** argv) {
move_cmd.args[3].mat33f[8] = 0;

// Send command
cmd_publisher.publish(move_cmd);
cmd_publisher->publish(move_cmd);

ROS_INFO("waiting for executive to execute the command...");
ros::spin();
FF_INFO("waiting for executive to execute the command...");
rclcpp::spin();
return 0;
}