Skip to content

Commit

Permalink
Updates from UxVCtrl V404
Browse files Browse the repository at this point in the history
  • Loading branch information
lebarsfa committed Dec 13, 2023
1 parent 750a389 commit 274268e
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 51 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ jobs:
shell: cmd

j2:
name: Windows MinGW 8.1.0 x64
runs-on: windows-2019
name: Windows MinGW 11.2.0 x64
runs-on: windows-2022
steps:
- uses: actions/checkout@v3
- run: cmake -G "MSYS Makefiles" -D CMAKE_BUILD_TYPE=Release . && cmake --build . --parallel
shell: bash

j3:
name: Windows MinGW 8.1.0 x86
runs-on: windows-2019
name: Windows MinGW 11.2.0 x86
runs-on: windows-2022
steps:
- uses: actions/checkout@v3
- run: |
choco install -y -r --no-progress mingw --version=8.1.0 --force --x86
choco install -y -r --no-progress mingw --version=11.2.0.07112021 --force --x86
choco install -y -r --no-progress make --force --x86
echo C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw32\bin>>%GITHUB_PATH%
shell: cmd
Expand All @@ -43,8 +43,8 @@ jobs:
# - run: cmake -D CMAKE_BUILD_TYPE=Release . && cmake --build . --parallel

j5:
name: Ubuntu 18.04
runs-on: ubuntu-18.04
name: Ubuntu 22.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- run: cmake . && cmake --build .
Expand Down Expand Up @@ -72,13 +72,13 @@ jobs:
- run: make && make clean && cmake -D CMAKE_BUILD_TYPE=Release . && cmake --build .

j9:
name: Ubuntu 20.04 Qt
runs-on: ubuntu-20.04
name: Ubuntu 22.04 Qt
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- run: |
sudo apt-get -q update || true # Allowed to fail...
sudo apt-get -y install qt5-default
sudo apt-get -y install qtbase5-dev qtchooser
- run: qmake && make

j10:
Expand Down
17 changes: 11 additions & 6 deletions OSCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,23 @@ _ Mac OS : __APPLE__
_ Windows CE : WINCE
See also https://sourceforge.net/p/predef/wiki/Architectures/.
*/

#ifdef _WIN32
// Set the default target Windows version to Windows XP, unless we use Borland C++ Builder 5
// for which it is set to Windows 2000.
// Set the default target Windows version to at least Windows XP, unless we use
// Borland C++ Builder 5 for which it is set to Windows 2000.
# ifdef __BORLANDC__
# ifndef _WIN32_WINNT
# if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x0500
# endif // _WIN32_WINNT
# endif // !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)
# else
# ifndef _WIN32_WINNT
# if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0501)
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x0501
# endif // _WIN32_WINNT
# endif // !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0501)
# endif // __BORLANDC__
#endif // _WIN32

Expand Down Expand Up @@ -147,6 +151,7 @@ _ Windows CE : WINCE
// To fix...

#pragma GCC diagnostic ignored "-Wwrite-strings"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
//#if (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4))
//#pragma GCC diagnostic push
//#endif // (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4))
Expand Down
28 changes: 14 additions & 14 deletions P33x.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ inline int InitP33x(P33X* pP33x)
uint8 writebuf[4];
uint8 crc_h = 0;
uint8 crc_l = 0;
int devclass = 0;
int group = 0;
int year = 0;
int week = 0;
int buf = 0;
int stat = 0;
//int devclass = 0;
//int group = 0;
//int year = 0;
//int week = 0;
//int buf = 0;
//int stat = 0;

writebuf[0] = (uint8)0xfa; // device address = 250
writebuf[1] = (uint8)0x30; // function 48
Expand Down Expand Up @@ -114,12 +114,12 @@ inline int InitP33x(P33X* pP33x)
return EXIT_FAILURE;
}

devclass = readbuf[2];
group = readbuf[3];
year = readbuf[4];
week = readbuf[5];
buf = readbuf[6];
stat = readbuf[7];
//devclass = readbuf[2];
//group = readbuf[3];
//year = readbuf[4];
//week = readbuf[5];
//buf = readbuf[6];
//stat = readbuf[7];

//PRINT_DEBUG_MESSAGE_OSUTILS(("Device ID : %d.%d\n", devclass, group));
//PRINT_DEBUG_MESSAGE_OSUTILS(("Firmware version : %d.%d\n", year, week));
Expand All @@ -144,7 +144,7 @@ inline int ReadChannelP33x(P33X* pP33x, uint8 Channel, float* pValue)
uint8 crc_h = 0;
uint8 crc_l = 0;
uFloat_P33X value;
int stat = 0;
//int stat = 0;

writebuf[0] = (uint8)0xfa; // device address = 250
writebuf[1] = (uint8)0x49; // function 73
Expand Down Expand Up @@ -198,7 +198,7 @@ inline int ReadChannelP33x(P33X* pP33x, uint8 Channel, float* pValue)
value.c[2] = readbuf[3];
value.c[1] = readbuf[4];
value.c[0] = readbuf[5];
stat = readbuf[6];
//stat = readbuf[6];

*pValue = value.v;

Expand Down
30 changes: 15 additions & 15 deletions ReadMe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ Hardware-CPP

Change the device path and other parameters in the configuration files if necessary and comment/uncomment lines in Main.cpp depending on the device you wish to test. Mind the line endings in the configuration files depending on the OS (use e.g. the command dos2unix *.txt to convert line endings for Linux)!

Hardware support :
- Hokuyo : Hokuyo URG-04LX-UG01 laser telemeter.
- IM483I : Intelligent Motion Systems IM483I step motor controller.
- MDM : Tritech Micron Data Modem (or other kinds of simple RS232 modems).
- MES : Tritech Micron Echosounder.
- MT : Xsens MTi, MTi-G AHRS.
- NMEADevice (superseded by ublox) : GPS, Furuno WS200 weather station.
- P33x : Keller pressure sensor PAA-33x.
- PathfinderDVL : TRDI Pathfinder DVL.
- Pololu : Pololu Mini Maestro 6, 18, 24 servo controllers, Pololu Jrk (preliminary support).
- RazorAHRS : SparkFun 9DOF Razor IMU (flash firmware from https://github.com/lebarsfa/razor-9dof-ahrs if needed).
- RPLIDAR : RPLIDAR A1, A2, A3 laser telemeters.
- Seanet : Tritech Micron Sonar, Tritech MiniKing Sonar.
- SSC-32 : Lynxmotion SSC-32, SSC-32u servo controllers.
- ublox : ublox GPS, Furuno WS200 weather station, or other NMEA-compatible devices with supported NMEA sentences.
Hardware support:
- Hokuyo: Hokuyo URG-04LX-UG01 laser telemeter.
- IM483I: Intelligent Motion Systems IM483I step motor controller.
- MDM: Tritech Micron Data Modem (or other kinds of simple RS232 modems).
- MES: Tritech Micron Echosounder.
- MT: Xsens MTi, MTi-G AHRS.
- NMEADevice (superseded by ublox): GPS, Furuno WS200 weather station.
- P33x: Keller pressure sensor PAA-33x.
- PathfinderDVL: TRDI Pathfinder DVL.
- Pololu: Pololu Mini Maestro 6, 18, 24 servo controllers, Pololu Jrk (preliminary support).
- RazorAHRS: SparkFun 9DOF Razor IMU (flash firmware from https://github.com/lebarsfa/razor-9dof-ahrs if needed).
- RPLIDAR: RPLIDAR A1, A2, A3 laser telemeters.
- Seanet: Tritech Micron Sonar, Tritech MiniKing Sonar.
- SSC-32: Lynxmotion SSC-32, SSC-32u servo controllers.
- ublox: ublox GPS, Furuno WS200 weather station, or other NMEA-compatible devices with supported NMEA sentences.

See also https://github.com/ENSTABretagneRobotics/Hardware-MATLAB, https://github.com/ENSTABretagneRobotics/Hardware-Python , https://github.com/ENSTABretagneRobotics/Hardware-Java , https://github.com/ENSTABretagneRobotics/Android .
101 changes: 95 additions & 6 deletions Roboteq.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,11 +620,10 @@ inline int GetValueRoboteq(ROBOTEQ* pRoboteq, int operatingItem, int index, int*

/*
Set selected PWM channels.
For example, if a servomotor is connected to channel 2, set pws[2] to 1500 to put it at a neutral state, 1000 in
one side or 2000 in the other side, and set selectedchannels[2] to 1. The channel needs to be configured as servo
output in Maestro Control Center. If it is configured as digital output, bit = (pws[2] >= 1500)? 1 : 0;.
For example, if a motor is connected to channel 2, set pws[2] to 1500 to put it at a neutral state, 1000 in
one direction or 2000 in the other direction, and set selectedchannels[2] to 1.
ROBOTEQ* pRoboteq : (INOUT) Valid pointer to a structure corresponding to a Roboteq Maestro.
ROBOTEQ* pRoboteq : (INOUT) Valid pointer to a structure corresponding to a Roboteq.
int* selectedchannels : (IN) Valid pointer to a table of NB_CHANNELS_PWM_ROBOTEQ elements to indicate which channels
should be considered in pws (0 to ignore the channel or 1 to select it).
int* pws : (IN) Valid pointer to a table of NB_CHANNELS_PWM_ROBOTEQ elements with the desired pulse width for each
Expand Down Expand Up @@ -670,7 +669,7 @@ inline int SetAllPWMsRoboteq(ROBOTEQ* pRoboteq, int* selectedchannels, int* pws)

//printf("%d %d %d %d %d\n", channel, pws_tmp[channel], pRoboteq->LastPWs[channel], abs(pws_tmp[channel]-pRoboteq->LastPWs[channel]), pRoboteq->ThresholdPWs[channel]);

res = (res || SetCommandRoboteq(pRoboteq, _GO_ROBOTEQ, channel+1, (pws_tmp[channel]-DEFAULT_MID_PW_ROBOTEQ)*(DEFAULT_MAX_PW_ROBOTEQ-DEFAULT_MIN_PW_ROBOTEQ)/1000));
res = (res || SetCommandRoboteq(pRoboteq, _GO_ROBOTEQ, channel+1, 2*(pws_tmp[channel]-DEFAULT_MID_PW_ROBOTEQ)*(DEFAULT_MAX_PW_ROBOTEQ-DEFAULT_MIN_PW_ROBOTEQ)/1000));

nbselectedchannels++;
}
Expand All @@ -696,7 +695,7 @@ inline int SetAllPWMsRoboteq(ROBOTEQ* pRoboteq, int* selectedchannels, int* pws)
/*
Set rightthrusterchan and leftthrusterchan PWM channels as thrusters inputs.
ROBOTEQ* pRoboteq : (INOUT) Valid pointer to a structure corresponding to a Roboteq Maestro.
ROBOTEQ* pRoboteq : (INOUT) Valid pointer to a structure corresponding to a Roboteq.
double urt : (IN) Desired right thruster input (in [-1;1]).
double ult : (IN) Desired left thruster input (in [-1;1]).
Expand All @@ -723,6 +722,96 @@ inline int SetThrustersRoboteq(ROBOTEQ* pRoboteq, double urt, double ult)
return SetAllPWMsRoboteq(pRoboteq, selectedchannels, pws);
}

/*
Set 1 actuator
ROBOTEQ* pRoboteq : (INOUT) Valid pointer to a structure corresponding to a Roboteq.
double u_1 : (IN) Desired actuator input (in [-1;1]).
Return : EXIT_SUCCESS or EXIT_FAILURE if there is an error.
*/
inline int Set1ActuatorRoboteq(ROBOTEQ* pRoboteq, double u_1)
{
int selectedchannels[NB_CHANNELS_PWM_ROBOTEQ];
int pws[NB_CHANNELS_PWM_ROBOTEQ];

memset(selectedchannels, 0, sizeof(selectedchannels));
memset(pws, 0, sizeof(pws));

// Convert u (in [-1;1]) into Roboteq pulse width (in us).
pws[0] = DEFAULT_MID_PW_ROBOTEQ+(int)(u_1*(DEFAULT_MAX_PW_ROBOTEQ-DEFAULT_MIN_PW_ROBOTEQ)/2.0);

pws[0] = max(min(pws[0], DEFAULT_MAX_PW_ROBOTEQ), DEFAULT_MIN_PW_ROBOTEQ);

selectedchannels[0] = 1;

return SetAllPWMsRoboteq(pRoboteq, selectedchannels, pws);
}

/*
Set 2 actuators. Warning: not all Roboteq boards can handle 2 actuators.
ROBOTEQ* pRoboteq : (INOUT) Valid pointer to a structure corresponding to a Roboteq.
double u_1 : (IN) Desired actuator input (in [-1;1]).
double u_2 : (IN) Desired actuator input (in [-1;1]).
Return : EXIT_SUCCESS or EXIT_FAILURE if there is an error.
*/
inline int Set2ActuatorsRoboteq(ROBOTEQ* pRoboteq, double u_1, double u_2)
{
int selectedchannels[NB_CHANNELS_PWM_ROBOTEQ];
int pws[NB_CHANNELS_PWM_ROBOTEQ];

memset(selectedchannels, 0, sizeof(selectedchannels));
memset(pws, 0, sizeof(pws));

// Convert u (in [-1;1]) into Roboteq pulse width (in us).
pws[0] = DEFAULT_MID_PW_ROBOTEQ+(int)(u_1*(DEFAULT_MAX_PW_ROBOTEQ-DEFAULT_MIN_PW_ROBOTEQ)/2.0);
pws[1] = DEFAULT_MID_PW_ROBOTEQ+(int)(u_2*(DEFAULT_MAX_PW_ROBOTEQ-DEFAULT_MIN_PW_ROBOTEQ)/2.0);

pws[0] = max(min(pws[0], DEFAULT_MAX_PW_ROBOTEQ), DEFAULT_MIN_PW_ROBOTEQ);
pws[1] = max(min(pws[1], DEFAULT_MAX_PW_ROBOTEQ), DEFAULT_MIN_PW_ROBOTEQ);

selectedchannels[0] = 1;
selectedchannels[1] = 1;

return SetAllPWMsRoboteq(pRoboteq, selectedchannels, pws);
}

/*
Set 3 actuators. Warning: not all Roboteq boards can handle 3 actuators.
ROBOTEQ* pRoboteq : (INOUT) Valid pointer to a structure corresponding to a Roboteq.
double u_1 : (IN) Desired actuator input (in [-1;1]).
double u_2 : (IN) Desired actuator input (in [-1;1]).
double u_3 : (IN) Desired actuator input (in [-1;1]).
Return : EXIT_SUCCESS or EXIT_FAILURE if there is an error.
*/
inline int Set3ActuatorsRoboteq(ROBOTEQ* pRoboteq, double u_1, double u_2, double u_3)
{
int selectedchannels[NB_CHANNELS_PWM_ROBOTEQ];
int pws[NB_CHANNELS_PWM_ROBOTEQ];

memset(selectedchannels, 0, sizeof(selectedchannels));
memset(pws, 0, sizeof(pws));

// Convert u (in [-1;1]) into Roboteq pulse width (in us).
pws[0] = DEFAULT_MID_PW_ROBOTEQ+(int)(u_1*(DEFAULT_MAX_PW_ROBOTEQ-DEFAULT_MIN_PW_ROBOTEQ)/2.0);
pws[1] = DEFAULT_MID_PW_ROBOTEQ+(int)(u_2*(DEFAULT_MAX_PW_ROBOTEQ-DEFAULT_MIN_PW_ROBOTEQ)/2.0);
pws[2] = DEFAULT_MID_PW_ROBOTEQ+(int)(u_3*(DEFAULT_MAX_PW_ROBOTEQ-DEFAULT_MIN_PW_ROBOTEQ)/2.0);

pws[0] = max(min(pws[0], DEFAULT_MAX_PW_ROBOTEQ), DEFAULT_MIN_PW_ROBOTEQ);
pws[1] = max(min(pws[1], DEFAULT_MAX_PW_ROBOTEQ), DEFAULT_MIN_PW_ROBOTEQ);
pws[2] = max(min(pws[2], DEFAULT_MAX_PW_ROBOTEQ), DEFAULT_MIN_PW_ROBOTEQ);

selectedchannels[0] = 1;
selectedchannels[1] = 1;
selectedchannels[2] = 1;

return SetAllPWMsRoboteq(pRoboteq, selectedchannels, pws);
}

// ROBOTEQ must be initialized to 0 before (e.g. ROBOTEQ roboteq; memset(&roboteq, 0, sizeof(ROBOTEQ));)!
inline int ConnectRoboteq(ROBOTEQ* pRoboteq, char* szCfgFilePath)
{
Expand Down

0 comments on commit 274268e

Please sign in to comment.