Skip to content

Commit

Permalink
merged integration into rtk_filtering_offset
Browse files Browse the repository at this point in the history
  • Loading branch information
pearlastrid committed Mar 21, 2024
2 parents 37409fb + 881b175 commit a96bfdc
Show file tree
Hide file tree
Showing 39 changed files with 1,261 additions and 554 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ if (NOT APPLE)
mrover_add_esw_bridge_node(brushed_test_bridge src/esw/brushed_test_bridge/*.cpp)
mrover_add_esw_bridge_node(test_arm_bridge src/esw/test_arm_bridge/*.cpp)
mrover_add_esw_bridge_node(pdb_test_bridge src/esw/pdb_test_bridge/*.cpp)
mrover_add_esw_bridge_node(arm_position_test_bridge src/esw/arm_position_test_bridge/*.cpp)
# mrover_add_esw_bridge_node(sa_sensor src/esw/fw/dirt_sensor/dirt_sensor_ros/dirt_sensor_ros.ino)
endif ()

Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ADD --chown=mrover:mrover ./pkg ./pkg
RUN ./ansible.sh ci.yml

USER root
RUN apt-get purge ansible -y && apt-get autoremove -y
# Remove apt cache to free up space in the image
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

Expand Down
Binary file modified bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions cmake/deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ else ()

set(dawn_FOUND TRUE)
else ()
message(WARNING "Dawn not found. If on Ubuntu install with 'sudo apt install -f ./pkg/dawn.deb'. Or build from source with ./scripts/build_dawn.sh")
message(WARNING "Dawn not found. If on Ubuntu install with 'sudo apt install -f ./pkg/libdawn-dev.deb'. Or build from source with ./scripts/build_dawn.sh")
endif ()
endif ()

Expand Down Expand Up @@ -57,7 +57,7 @@ if (NOT manif_FOUND)

set(manif_FOUND TRUE)
else ()
message(FATAL_ERROR "Manif not found. If on Ubuntu install with 'sudo apt install -f ./pkg/manif.deb'. Or build from source with 'submodule update --init deps/manif' and make sure it is non-empty")
message(FATAL_ERROR "Manif not found. If on Ubuntu install with 'sudo apt install -f ./pkg/libmanif-dev.deb'. Or build from source with 'submodule update --init deps/manif' and make sure it is non-empty")
endif ()
endif ()

Expand Down
10 changes: 5 additions & 5 deletions config/esw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ can:
bus: 0
id: 0x15
- name: "joint_a"
bus: 1
bus: 0
id: 0x20
- name: "joint_b"
bus: 1
bus: 0
id: 0x21
- name: "joint_c"
bus: 1
Expand Down Expand Up @@ -105,7 +105,7 @@ can:
bus: 1
id: 0x50
- name: "science"
bus: 1
bus: 0
id: 0x51

brushless_motors:
Expand Down Expand Up @@ -154,7 +154,7 @@ brushless_motors:
limit_1_readjust_position: 494.739 # radians
limit_max_forward_pos: true
limit_max_backward_pos: true
max_forward_pos: 1.0
max_forward_pos: 0.4
max_backward_pos: 0.0
joint_c:
velocity_multiplier: -1.0
Expand Down Expand Up @@ -616,4 +616,4 @@ default_network_iface: "enp0s31f6"

auton_led_driver:
port: "/dev/ttyACM0"
baud: 115200
baud: 115200
4 changes: 2 additions & 2 deletions config/rviz/auton_sim.rviz
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Visualization Manager:
Value: true
right_camera_link:
Value: true
zed2i_left_camera_frame:
zed_left_camera_frame:
Value: true
Marker Alpha: 1
Marker Scale: 1
Expand Down Expand Up @@ -112,7 +112,7 @@ Visualization Manager:
{}
right_camera_link:
{}
zed2i_left_camera_frame:
zed_left_camera_frame:
{}
Update Interval: 0
Value: true
Expand Down
4 changes: 3 additions & 1 deletion config/teleop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ teleop:
sensor_actuator:
multiplier: 1
slow_mode_multiplier: 0.5
xbox_index: 5
cache:
multiplier: 1
xbox_index: 4

drive_controls:
forward_back:
Expand Down
1 change: 0 additions & 1 deletion deps/emsdk
Submodule emsdk deleted from 7815dc
1 change: 0 additions & 1 deletion deps/libde265
Submodule libde265 deleted from 17bb8d
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"dependencies":{"@tsconfig/node18":"^18.2.2","@vitejs/plugin-vue":"^4.4.0","bootstrap":"^4.6.2","bootstrap-vue":"^2.23.1","vite":"^4.4.11","vue":"^3.3.4","vue-router":"^4.2.5"},"devDependencies":{"sass":"^1.69.2"}}
{ "dependencies": { "@tsconfig/node18": "^18.2.2", "@vitejs/plugin-vue": "^4.4.0", "bootstrap": "^4.6.2", "bootstrap-vue": "^2.23.1", "html2canvas": "^1.4.1", "vite": "^4.4.11", "vue": "^3.3.4", "vue-router": "^4.2.5" }, "devDependencies": { "sass": "^1.69.2" } }
4 changes: 2 additions & 2 deletions pkg/libmanif-dev.deb
Git LFS file not shown
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ dependencies = [
"aenum==3.1.15",
"daphne==4.0.0",
"channels==4.0.0",
"PyQt5==5.15.10",
"Pyarrow==15.0.0"
"opencv-python==4.9.0.80",
]

[project.optional-dependencies]
Expand Down
5 changes: 2 additions & 3 deletions scripts/debug_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

from typing import Any
import rospy
from mrover.srv import AdjustMotor, AdjustMotorResponse
from std_srvs.srv import Trigger, TriggerResponse, SetBool, SetBoolResponse
from std_srvs.srv import SetBool, SetBoolResponse

# Change these values for the service name and type definition to test different values
SERVICE_NAME = "enable_arm_laser"
SERVICE_NAME = "science_enable_heater_n0"
SERVICE_TYPE = SetBool


Expand Down
154 changes: 154 additions & 0 deletions src/esw/arm_position_test_bridge/arm_position.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
#include "messaging.hpp"
#include "ros/ros.h"
#include "std_srvs/SetBool.h"
#include <mrover/LED.h>
#include <sensor_msgs/JointState.h>
#include <mrover/Position.h>

#include <chrono>
#include <stdexcept>
#include <thread>

void sleep(int ms);
void set_arm_position(ros::Publisher& publisher, std::vector<float> positions, int delay);

std::vector<double> position_data;

auto arm_position_callback(sensor_msgs::JointState::ConstPtr const& msg) {
ROS_INFO(";)");
position_data = msg->position;
ROS_INFO("hey");
}

void reset_pos(ros::Publisher armPublisher, int delay) {
set_arm_position(armPublisher, {0, 0, 0, 0, 0, 0, 0}, delay);
}

void de_roll(float position, ros::Publisher armPublisher, int delay = 5000) {
set_arm_position(armPublisher, {0, 0, 0, 0, 0, position, 0}, delay);
ROS_INFO("Joint_DE_ROLL: %f", position_data[4]);
reset_pos(armPublisher, delay);
}

void de_pitch(float position, ros::Publisher armPublisher, int delay = 5000) {
set_arm_position(armPublisher, {0, 0, 0, position, 0, 0, 0}, delay);
ROS_INFO("Joint_DE_PITCH: %f", position_data[3]);
reset_pos(armPublisher, delay);
}

int main(int argc, char** argv) {
// Delay between operations
int delay = 5000;
position_data.resize(7);

ros::init(argc, argv, "arm_position_test_bridge");
ros::NodeHandle nh;
ros::Rate rate(10);

ros::Publisher armPublisher = nh.advertise<mrover::Position>("arm_position_cmd", 1);
ros::Subscriber armSubscriber = nh.subscribe<sensor_msgs::JointState>("arm_joint_data", 10, arm_position_callback);

while (ros::ok()) {
/* Arm Position Test */
ROS_INFO("****BEGIN BASIC AUTON ARM POSITION TEST****");


ROS_INFO("MOVE A");

set_arm_position(armPublisher, {0.4, 0, 0, 0, 0, 0, 0}, delay);
ROS_INFO("Joint_A: %f", position_data[0]);
//reset_pos(armPublisher, delay);

// Test forwards limit switch
//set_arm_position(armPublisher, {1, 0, 0, 0, 0, 0, 0}, delay);
//ROS_INFO("Joint_A: %f", position_data[0]);
//reset_pos(armPublisher, delay);

// Test backwards limit switch
//set_arm_position(armPublisher, {-0.4, 0, 0, 0, 0, 0, 0}, delay);
//ROS_INFO("Joint_A: %f", position_data[0]);
//reset_pos(armPublisher, delay);


// ROS_INFO("MOVE B");
// set_arm_position(armPublisher, {0, -0.70, 0, 0, 0, 0, 0}, delay);
// ROS_INFO("Joint_B: %f", position_data[1]);
// reset_pos(armPublisher, delay);

// ROS_INFO("MOVE C");
// set_arm_position(armPublisher, {0, 0, -2.0, 0, 0, 0, 0}, delay);
// ROS_INFO("Joint_C: %f", position_data[2]);
// reset_pos(armPublisher, delay);

// set_arm_position(armPublisher, {0, 0, 1.7, 0, 0, 0, 0}, delay);
// ROS_INFO("Joint_C: %f", position_data[2]);
// reset_pos(armPublisher, delay);

// ROS_INFO("MOVE DE PITCH");
// float test_de_pitch_positions[4] = {2.35, -2.35, 1.17, -1.17};
// for(float value : test_de_pitch_positions) {
// de_pitch(value, armPublisher);
// }

// ROS_INFO("MOVE DE ROLL");
// float test_de_roll_positions[4] = {6.28, -6.28, 3.14, -3.14};
// for(float value : test_de_roll_positions){
// de_roll(value, armPublisher);
// }
ROS_INFO("****END BASIC ARM POSITION TEST****");
// ROS_INFO("****BEGIN COMPLEX AUTON ARM POSITION TEST****");

// ROS_INFO("BOTH DE");
// for(int i = 0; i < 4; i++){
// set_arm_position(armPublisher, {0,0,0,0,test_de_pitch_positions[i],test_de_roll_positions[i],0}, delay);
// ROS_INFO("Joint_DE_ROLL: %f", position_data[4]);
// ROS_INFO("Joint_DE_PITCH: %f", position_data[3]);
// reset_pos(armPublisher, delay);
// }

// // Joint A: [0.0, 1.0]
// // Joint B: [-0.78540, 0.0]
// // Joint C: [-2.094, 1.745] 220 degrees of motion
// // Joint DE-Pitch: [-2.268, 2.268]
// // Joint DE-Roll: [-inf,inf]
// ROS_INFO("A,B,C");
// //min position
// set_arm_position(armPublisher, {0,-0.78,-2.0,0,0,0,0}, delay);
// ROS_INFO("Joint_A: %f", position_data[0]);
// ROS_INFO("Joint_B: %f", position_data[1]);
// ROS_INFO("Joint_C: %f", position_data[2]);
// reset_pos(armPublisher, delay);

// // max position
// set_arm_position(armPublisher, {0.9,0.0,1.7,0,0,0,0}, delay);
// ROS_INFO("Joint_A: %f", position_data[0]);
// ROS_INFO("Joint_B: %f", position_data[1]);
// ROS_INFO("Joint_C: %f", position_data[2]);
// reset_pos(armPublisher, delay);

// set_arm_position(armPublisher, {0.3,-0.32,-1.2,0,0,0,0}, delay);
// ROS_INFO("Joint_A: %f", position_data[0]);
// ROS_INFO("Joint_B: %f", position_data[1]);
// ROS_INFO("Joint_C: %f", position_data[2]);
// ROS_INFO("****END COMPLEX AUTON ARM POSITION TEST****");
}

return 0;
}

void sleep(int ms) {
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
}

void set_arm_position(ros::Publisher& publisher, std::vector<float> positions, int delay) {
mrover::Position armMsg;
// TODO: figure out how to set allen_key and gripper to nan
armMsg.names = {"joint_a", "joint_b", "joint_c", "joint_de_pitch", "joint_de_roll", "allen_key", "gripper"};
armMsg.positions = positions;
ROS_INFO("[0]: %f, [1]: %f, [2]: %f", armMsg.positions[0], armMsg.positions[1], armMsg.positions[2]);

for (int i = 0; i < delay; i += 50) {
sleep(50);
publisher.publish(armMsg);
}
}
5 changes: 3 additions & 2 deletions src/esw/arm_translator_bridge/arm_translator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace mrover {
assert(mJointDEPitchIndex == mJointDE0Index);
assert(mJointDERollIndex == mJointDE1Index);
assert(mArmHWNames.size() == mRawArmNames.size());

ROS_INFO("hi");
for (std::size_t i = 0; i < mRawArmNames.size(); ++i) {
if (i != mJointDEPitchIndex && i != mJointDERollIndex) {
assert(mArmHWNames.at(i) == mRawArmNames.at(i));
Expand Down Expand Up @@ -188,6 +188,7 @@ namespace mrover {
}

auto ArmTranslator::processPositionCmd(Position::ConstPtr const& msg) -> void {
ROS_INFO("msg: %f", msg->positions[0]);
if (mRawArmNames != msg->names || mRawArmNames.size() != msg->positions.size()) {
ROS_ERROR("Position requests for arm is ignored!");
return;
Expand Down Expand Up @@ -215,7 +216,7 @@ namespace mrover {
// joint a convert linear position (meters) to radians
auto joint_a_pos = convertLinPos(msg->positions.at(mJointAIndex), mJointALinMult.get());
position.positions.at(mJointAIndex) = joint_a_pos;

mPositionPub->publish(position);
}

Expand Down
4 changes: 2 additions & 2 deletions src/esw/motor_library/brushless.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ namespace mrover {
throw std::runtime_error("Velocity multiplier can't be 0!");
}

mMinVelocity = RadiansPerSecond{xmlRpcValueToTypeOrDefault<double>(brushlessMotorData, "min_velocity", -1.0)};
mMaxVelocity = RadiansPerSecond{xmlRpcValueToTypeOrDefault<double>(brushlessMotorData, "max_velocity", 1.0)};
mMinVelocity = RadiansPerSecond{xmlRpcValueToTypeOrDefault<double>(brushlessMotorData, "min_velocity", -0.01)};
mMaxVelocity = RadiansPerSecond{xmlRpcValueToTypeOrDefault<double>(brushlessMotorData, "max_velocity", 0.01)};

mMinPosition = Radians{xmlRpcValueToTypeOrDefault<double>(brushlessMotorData, "min_position", -1.0)};
mMaxPosition = Radians{xmlRpcValueToTypeOrDefault<double>(brushlessMotorData, "max_position", 1.0)};
Expand Down
Loading

0 comments on commit a96bfdc

Please sign in to comment.