diff --git a/arduino/loadcell/loadcell.ino b/arduino/loadcell/loadcell.ino index fa0eb200e5e06f6139b1125b207d722a06fcf4f8..71753ed98653c159e52a2a4f52a009e92ea1cc4e 100644 --- a/arduino/loadcell/loadcell.ino +++ b/arduino/loadcell/loadcell.ino @@ -6,10 +6,10 @@ const int LOADCELL_DOUT_PIN = 2; const int LOADCELL_SCK_PIN = 3; -const float calibration_weight = 4.9; +const float calibration_weight = 4900.0; float zero_reading, load_reading; -const float calibration_factor = -479404.84; +const float calibration_factor = -99.52; HX711 scale; @@ -25,26 +25,11 @@ void setup() { // default "128" (Channel A) is used here. scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN); - //Serial.print("offset: "); - //Serial.print(scale.get_offset(), DEC); - //Serial.print("\t scale: "); - //Serial.println(scale.get_scale(), DEC); - - //Serial.println("tare the scale. in 3 sec. Make sure it is unloaded"); - delay(3); - // determine the offset - setup: no load scale.tare(); // sets the offset value within scale to current value of reading zero_reading = scale.read_average(10); //average over 10 vales - //scale.set_scale(); - //scale.get_units(10); - - //Serial.print("offset: "); - //Serial.print(scale.get_offset(), DEC); - //Serial.print("\t scale: "); - //Serial.println(scale.get_scale(), DEC); //delay(2); @@ -55,28 +40,13 @@ void setup() { //} //load_reading = scale.read_average(10); - /*Serial.print("zero and load reading: "); - Serial.print(zero_reading, DEC); - Serial.print(" "); - Serial.println(load_reading, DEC);*/ + //scale.set_scale((load_reading - zero_reading)/calibration_weight); // this value is obtained by calibrating the scale with known weights; see the README for details //incomingByte = Serial.read(); // clear the receive buffer by assigning value to var //Serial.print("the calibration factor is: "); //Serial.println(load_reading - zero_reading/calibration_weight); -/* - Serial.println("set scale...."); - Serial.print("offset: "); - Serial.print(scale.get_offset(), DEC); - Serial.print("\t scale: "); - Serial.println(scale.get_scale(), DEC); - - Serial.print("get_value: "); - Serial.print(scale.get_value()); - Serial.print("\t get_units: "); - Serial.println(scale.get_units()); -*/ scale.set_scale(calibration_factor); //Serial.println("load cell is setup. Start reading now..."); diff --git a/python/abb_egm_pyclient/abb_egm_pyclient/feedback/control_final.py b/python/abb_egm_pyclient/abb_egm_pyclient/feedback/control_final.py index 4c63f96893a48cd5b2994b8c018bcffac3b1e8a8..027c0725c17491f6daf52e15495830f35e1ba53c 100644 --- a/python/abb_egm_pyclient/abb_egm_pyclient/feedback/control_final.py +++ b/python/abb_egm_pyclient/abb_egm_pyclient/feedback/control_final.py @@ -58,7 +58,7 @@ egm_client_R = EGMClient(port=UDP_PORT_RIGHT) egm_client_L = EGMClient(port=UDP_PORT_LEFT) yumi_right = invKin.Yumi("/home/joschua/Coding/forceControl/master-project/c++/models/urdf/yumi_right.urdf") -yumi_right.set_operationPoint(1.0) +yumi_right.set_operationPoint(5.0) yumi_right.set_kp(0.05) yumi_right.set_hybridControl(False) yumi_right.set_transitionTime(3.0) diff --git a/python/serial_interface/readSerial.py b/python/serial_interface/readSerial.py index 3e84ed0b2468e5e6faf51b9b2eabb8d220252c80..db1f7b212673c0e7041ece70836664e1c5d0ab9b 100644 --- a/python/serial_interface/readSerial.py +++ b/python/serial_interface/readSerial.py @@ -9,7 +9,6 @@ Instructions how to use this: 4. readings that are sent from arduino are read and ready for processing ''' - # find active ports ports = serial.tools.list_ports.comports() arduino = serial.Serial() @@ -36,30 +35,12 @@ arduino.flushInput() while not arduino.in_waiting: pass -#print("Mount the calibration weight to the load cell and then hit ENTER") -#print("message from arduino: " + arduino.readline().decode('utf-8').rstrip('\n')) -#print("message from arduino: " + arduino.readline().decode('utf-8').rstrip('\n')) -#input() -#arduino.write(bytes('0', 'utf-8')) - -#sleep(1) -time_prev = time() -timestamp = time() while True: if arduino.in_waiting: # get the number of bytes in the input buffer packet = arduino.readline() # type: bytes - time_diff = time() - time_prev str_receive = packet.decode('utf-8').rstrip('\n') - print(str_receive) - force = float(str_receive) - #print(f"force as float is {force}") - #print("serial freq: " + str(1/time_diff)) - time_prev = time() - #arduino.flushInput() - print(time()) - sleep(1/80) + force = float(str_receive)/1000.0 + print(force) + - if (time() - timestamp) >= (1.0/80.0): - print(time()-timestamp) - timestamp = time()